I would like my Ubuntu VM to have both a private IP and a public IP. The private IP should be supplied by my DHCP server.

Currently I am trying this:

auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet static

The problem is that I can only ping the private IP address, not the public one. When I bring eth0 down I can start pinging the public IP address. So it seems that somehow DHCP is preventing my public IP address from working correctly?

ip route shows:

default via dev eth0
default via dev eth1  metric 100 dev eth1  proto kernel  scope link  src dev eth0  proto kernel  scope link  src

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    0      0        0 eth0         UG    100    0        0 eth1 U     0      0        0 eth1   U     0      0        0 eth0

the routes on my vmhost:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    0      0        0 br925   U     0      0        0 virbr0   U     0      0        0 br925
  • Is the public interface also on the 109.x network? Dec 15, 2013 at 16:21
  • eth1 is on the 109.x network
    – Jochen
    Dec 15, 2013 at 16:26
  • And the routes on your host machine? Dec 15, 2013 at 16:34

2 Answers 2


The main problem is you receive default gateway by DHCP which is established with minimal metric 0. You can not reach public IPs since packets go to the private network.

Try to disable gateway in DHCP.

FYI: SE/Superuser: I don't want my DHCP to be a default gateway


I had to add this to /etc/network/interfaces (in the eth0 section)

up route add -net netmask gw dev eth0
  • You added a route to your private network which fixed a problem ping the public IP from localhost? So now DHCP does not change the metric for your public IP?
    – rjt
    Dec 15, 2013 at 16:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .