Virtual Box networking

VM Setting

  • preferences
    • Network
    • New NAT
      • Called NetTest
      • Set IP Address of 10.0.20/24

Machine 1

  • Cloned existing machine
  • Set Network as NAT Network network name NetTest

Booted the machine, tested the network - and all working, Internet access.

Disabled GUI Netork

edited /etc/network/interfaces

auth eth0
iface eth0 inet dhcp

then

  • restarted network
    • ALL STILL WORKING
  • rebooted
    • ALL STILL WORKING

Note: Resolv.conf looks like this

nameserver 192.168.1.197
nameserver 192.168.1.1
nameserver 8.8.8.8
search home.ts

Check Routes

Using route -a

```Destination Gateway Genmask Flags Metric Ref Use Iface default 10.0.20.1 0.0.0.0 UG 0 0 0 eth0 10.0.20.0 * 255.255.255.0 U 0 0 0 eth0 link-local * 255.255.0.0 U 1000 0 0 eth0

##Static IP

I want to make this machine static IP....

so interfaces now looks like this

auto lo iface lo inet loopback

auth eth0 iface eth0 inet static address 10.0.20.10 netmask 255.255.255.0 gateway 10.0.20.1 nameserver 10.0.20.1

restarted the network - and guess what **NO INTERNET** connection.

The route output looks ok... 

###Add new Network Adapter

I now 

  * shutdown the VM
  * Add new Network Adapter
    * Adapter 2
      * Network Type 
        *  NAT

Start the machine - and manually startup the eth0 network.

I still have 2 networks

|iface   | Address |
|:-------|:-----------|
| eth0   | 10.0.20.10 |
| eth1   | 10.0.3.15  | 


## Change 10.0.20 Address

I am worried that 10.0.20 is somehow catching a class A mask.... so I want to run on a non-routed network of 172.16.x.x

So I now change VM Network

  * Preferences
    * Network
      * select NetTest
        * Edit Address to 
          *  172.16.1.0/24


 I now booted the VM and could not get anything to work....

 So 

   * DISABLE gui NETWORKING
   * Add entry in interfaces for eth1

 Reboot VM

 I edited the interfaces file... and it now looks like this

 ```bash
 # interfaces(5) file used by ifup(8) and ifdown(8)

iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet static
address 172.16.1.10
netmask 255.255.255.0
gateway 172.16.1.2


 ```

Now all works !!!

#Add new Machine
I cloned a spare machine - set 2 NIC cards, 1 NAT, 2 NAT NETWORK (just as previous machine)

Booted and inside the OS set this network like

  ```bash
 # interfaces(5) file used by ifup(8) and ifdown(8)

iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet static
address 172.16.1.11
netmask 255.255.255.0
gateway 172.16.1.2


 ```


Note: On my private network 1 machine is 172.16.1.10 the other 172.16.1.11

Now I can Ping on the 172 network between the machines - and access the internet via the 10.0.2.x network (the DHCP) network....



#Good Commands

 faster than *route -a*

     netroute -rn

 See the routes - clear output

     ip route show

##Diagnose a route

Use  tcpdump - for example to check the route on **eth1** going to address **10.1.5.202** 

    tcpdump -qnnvvv -i eth1 host 10.1.5.202

Good Output looks like this

tcpdump: listening on eth1, link-type EN10MB (Ethernet), capture size 96 bytes 16:50:35.880941 IP (tos 0x10, ttl 64, id 59563, offset 0, flags [DF], proto: TCP (6), length: 60) 10.1.7.41.41403 > 10.1.5.202.22: tcp 0 16:50:35.881266 IP (tos 0x0, ttl 59, id 0, offset 0, flags [DF], proto: TCP (6), length: 60) 10.1.5.202.22 > 10.1.7.41.41403: tcp 0

Bad Output looks like this 

tcpdump: listening on eth1, link-type EN10MB (Ethernet), capture size 96 bytes 16:50:35.881266 IP (tos 0x0, ttl 59, id 0, offset 0, flags [DF], proto: TCP (6), length: 60) 10.1.5.202.22500 > 10.1.7.41.22: tcp 0

```