Network map

  localnet  +-------------------------------------+  vmnet  +--------------------+
------------|eth0          gateway            eth1|---------|eth0            vm  |
            | |         |      |
            +-------------------------------------+         +--------------------+

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 dev eth0

If we want to make this change permanent:

auto eth0
iface eth0 inet static
    gateway      <===


From the vm host we must be able to reach:

  • The gateway
(root@vm)_$: ping
  • Another host in the vmnet network
(root@vm)_$: ping
  • Another host in the localnet network
(root@vm)_$: ping
  • Another host in the internet

    We cannot ping because 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