Default gateway (III)
Network map
  localnet  +-------------------------------------+  vmnet  +--------------------+
------------|eth0          gateway            eth1|---------|eth0            vm  |
            |192.168.1.44           192.168.56.101|         |192.168.56.102      |
            +-------------------------------------+         +--------------------+
Default gateway
Probably in the host that has to use the gateway – in our case a virtual machine called vm – there isn’t configured any default gateway because it is only connected to a network and only needs to comunicate with other hosts in that network.
However if we want to reach hosts in some other networks, we must add a default gateway which in our case will be the server we are configuring right now. So all the outlined steps will happen in the virtual machine vm.
(root@vm)_$: route add default gw 192.168.56.101 dev eth0
If we want to make this change permanent:
/etc/network/interfaces:
------------------------
auto eth0
iface eth0 inet static
    address 192.168.56.102
    network 192.168.56.0
    netmask 255.255.255.0
    gateway 192.168.56.101      <===
Check
From the vm host we must be able to reach:
- The gateway
 
(root@vm)_$: ping 192.168.56.101
- Another host in the 
vmnetnetwork 
(root@vm)_$: ping 192.168.56.103
- Another host in the 
localnetnetwork 
(root@vm)_$: ping 192.168.1.1
- 
    
Another host in the internet
We cannot ping
www.google.combecause we don’t have name resolution, but if we happen to know the IP address for a Google host, we should be able to reach it 
(root@vm)_$: ping 173.194.35.147