Ubuntu: changes to /etc/network/interfaces not working?


This is my /etc/network/interfaces file

I'm trying to add 2 virtual interfaces which connect to 2 different routers of 2 different ISPs

auto lo  iface lo inet loopback    iface eth2 inet static          address          netmask          gateway    dns-nameservers    iface eth3 inet static          address          netmask          gateway  

I've tried all these commands and none of them work

sudo /etc/init.d/networking restart  sudo /etc/init.d/networking reload`  

And these

sudo ifconfig eth2 down  sudo ifconfig eth2 up  

I get an error :

eth2: ERROR while getting interface flags: No such device

I've tried inserting manged=false in /etc/NetworkManager/NetworkManager.conf

and then restarting sudo service network-manger restart

When I type ifconfig -a

All I get is

eth0      Link encap:Ethernet  HWaddr fc:aa:14:4d:11:22              inet addr:  Bcast:  Mask:            inet6 addr: fe80::feaa:14ff:fe4d:1122/64 Scope:Link            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1            RX packets:8027656 errors:0 dropped:2 overruns:0 frame:0            TX packets:20898303 errors:0 dropped:0 overruns:0 carrier:0            collisions:0 txqueuelen:1000             RX bytes:553970620 (553.9 MB)  TX bytes:1471000436 (1.4 GB)    lo        Link encap:Local Loopback              inet addr:  Mask:            inet6 addr: ::1/128 Scope:Host            UP LOOPBACK RUNNING  MTU:65536  Metric:1            RX packets:1837917 errors:0 dropped:0 overruns:0 frame:0            TX packets:1837917 errors:0 dropped:0 overruns:0 carrier:0            collisions:0 txqueuelen:0             RX bytes:240925560 (240.9 MB)  TX bytes:240925560 (240.9 MB)  

My Question is : How can I add interfaces eth2 & eth3?


Ok, if you have one nic you can add virtual interfaces on this way

auto eth0  iface eth0 inet static     address     netmask     gateway     up ip addr add dev eth0 label eth0:1     down ip addr del dev eth0 label eth0:1     up ip route add via dev eth0:1 metric 20     down ip route del via dev eth0:1 metric 20  

In your question eth0 is in net range 192.168.1.xxx and eth3 is also in that range, meybe is enough to have only one interface in one network range?

You can add eth0:2 on the same way like eth0:1 if you need one more virtual interface

But this will work only in two cases.

  1. your pc is connected to switch and both router is also connected on the same switch. On this way pc can reach both router

  2. you router have primary and secondary ip address on interface

Edit 1

You must edit /etc/NetworkManager/NetworkManager.conf

sudo nano /etc/NetworkManager/NetworkManager.conf  

This will open the ‘NetworkManager.conf’ file in our text editor.

Now change:




After changes reload network service

sudo service networking restart  

Or if this did not work, try

sudo ifdown eth0 && sudo ifup eth0


To add a virtual interface type the following command in your Linux Terminal
For example,
ifconfig eth0:1 netmask up This will create a new virtual interface named eth0:1 and assigns the IP Address

To Make this Virtual Interface Permenant Create a new file /etc/sysconfig/network-scripts/ifcfg-eth0:1 with the following contents


Type service network-manager restart after editing to apply changes.

To Up and Down the Virtual Interface, use the following commands ifup eth0:1 and ifdown eth0:1


Using eth2 will tell the system to use another adapter but you only have one. to define virtual adapters you should use eth0:<number>.

Try this one:

auto lo  iface lo inet loopback    iface eth0:1 inet static          address          netmask          gateway    dns-nameservers    iface eth0:2 inet static          address          netmask          gateway  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »