Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem. First of all, I wan to set up a server on Ubuntu 14.04. I have 2 interfaces: eth0 for dhcp server and eth1 for internet connection. But if I connect to two networks at the same time, there isn't internet on PC. So I have to choose between server and internet. That's terrible, can anyone tell me how to close this issue?


auto lo eth0 eth1

iface lo inet loopback

iface eth0 inet static

sudo route outputs:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         UG    0      0        0 eth1     *        U     1      0        0 eth1

UPD: ifconfig outputs:

eth0      Link encap:Ethernet  HWaddr 90:e6:ba:46:1d:50  
          inet6 addr: fe80::92e6:baff:fe46:1d50/64 Scope:Link
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1110 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:184287 (184.2 KB)

eth1      Link encap:Ethernet  HWaddr 00:04:75:98:5f:da  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::204:75ff:fe98:5fda/64 Scope:Link
          RX packets:14498 errors:0 dropped:0 overruns:2 frame:0
          TX packets:13096 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:9710708 (9.7 MB)  TX bytes:1840400 (1.8 MB)
          Interrupt:18 Base address:0x4c00 

lo        Link encap:Local Loopback  
          inet addr:  Mask:
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:4398 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4398 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:527890 (527.8 KB)  TX bytes:527890 (527.8 KB)
share|improve this question
Is network manager configuring your devices? Show output of nmcli dev status also can you ping – meccooll Jun 21 '14 at 5:33
up vote 1 down vote accepted

Configuring the output of ifconfig and the comments given to my first answer, I think that the problem is related to way you configure your NIC's in /etc/network/interfaces.

As you don't have any specific configuration for eth1 in /etc/network/interfaces, I suppose that your modem is giving to your server the IP info via DHCP. As per the route ouput, you get your default gateway pointing to the modem so to Internet.

But on your /etc/network/interfaces file for the eth0 you have also a default gateway configured (statement gateway

You cannot have two default gateway on a system. The assignment of the default gateway on eth1 disable the static configuration of eth0, reason why there is no IP for eth0 in the ifconfig output and why Internet works and the internal network no more.

You will have to remove the line gateway and try again.

By doing so, of course, if you have more than one subnet on the internal LAN you won't be able to reach them anymore. Unless you configure static route towards all of these subnets on your server :

sudo route add -net A.B.C.D gw

you can add the route command in a script saved under /etc/network/if-up.d to be run each time an interface goes up.

share|improve this answer

From what I understand of your post, you are connecting to Internet via eth1 and to your internal network via eth0. And your server is then playing the role of DHCP server and default gateway for your PC's to go the Internet.

First, on the PC, check that they've received correctly all DHCP settings, including the gateway. From your question, I assume it should be

Secondly, be sure that your eth1 is well connected to the Internet and well configured; this is obviously depending of your ISP.

Finally, the most important operation, you will have to enable IP forwarding between your two interfaces on the server. Without this, packet won't be routed between your PC's and the Internet :

Manual set-up :

sudo echo 1 > /proc/sys/net/ipv4/ip_forward

To have the IP forward flag automatically setup at boot time uncomment the line #net.ipv4.ip_forward=1 in /etc/sysctl.conf

You will have also to ensure that there are no IPtables firewall rules that block the traffic. Do :

iptables -L -n

to get a list of rules if any. I would first try this setup with all firewall rules disabled :

iptables -F

share|improve this answer
No, I'm trying to set up PXE server. Computers in my local network get IPs correctly (they are booting). But there isn't internet neither on server nor (of course) on clients. – Andreikkaa Jun 10 '14 at 12:30
So, for now I only have to fix internet connection on server. – Andreikkaa Jun 10 '14 at 12:32
@user3452627: could you please add the output of ifconfig to your question. And also, specify how your are connected to Internet. – Benoit Jun 10 '14 at 12:33
Sure. I'm connected via modem. – Andreikkaa Jun 10 '14 at 12:39
@user3452627: does this modem gives an IP address to your server via DHCP ? – Benoit Jun 10 '14 at 13:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.