1

I am trying to setup my desktop such that I have multiple IP addresses using a single NIC. First, I tried to do this temporarily using ip, this works fine, however is only temporarily. To try to set it up permanently, I have been playing around with the /etc/network/interfaces file, but no luck so far.

All trials I did, either did nothing, or disconnected me from the internet. If it did something, I could see that the two IP addresses were setup using either ip addr or ifconfig. Also, I was able to ping my router. However, no internet.

The thing I tried are based on How can I (from CLI) assign multiple IP addresses to one interface?, How do I add an additional IP address to /etc/network/interfaces?, and Issue with setting up multiple IP addresses on Ubuntu Server.

They all suggest more or less the same things, but I guess I am still missing something. Before changing anything in the interfaces file it looked like this:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

and for my last trial I changed the file into:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eth0
auto eth0:0
# IP-1
iface eth0 inet static
    address 192.168.1.115
    network 192.168.1.0
    netmask 255.255.255.0
    broadcast 192.168.1.255
    gateway 192.168.1.254
# IP-2
iface eth0:0 inet static
name Ethernet alias LAN card
    address 192.168.3.11
    netmask 255.255.255.0
    network 172.16.100.0
    broadcast 192.168.3.255

Does anyone see what I do wrong?


Edit:

After some advice I changed the interface file to:

auto eth0 eth0:1
iface eth0 inet static
    address 192.168.1.115
#    network 192.168.1.0
    netmask 255.255.255.0
    broadcast 192.168.1.255
    gateway 192.168.1.1
iface eth0:1 inet static
    address 192.168.3.200
#    network 192.168.3.0
    netmask 255.255.255.0

Note the two lines in comment, I tried both with and without these lines. I commented these lines out because of the routing table (output of route -n) which is as follow:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.3.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0

I compared the routings table with the single IP address setting and noticed that only the first two lines where there.commenting out the lines in the interface file was my trial to remove the lines from the routing table. Clearly I miss understand something here; this did not happen.

Either way, with or without the lines in comment, the result is still the same, ip addresses are there, but no internet...

2
  • Why do you have a 172.16.100.0 network with a 192.168.3.11 IP? Also, have you checked the routes (try route -n).
    – muru
    May 31, 2016 at 10:00
  • The 172.16.100.0 was the result of bad copying and pasting, sory May 31, 2016 at 12:12

2 Answers 2

0

the manual has the following example:

auto eth0 eth0:1
iface eth0 inet static 
  address 192.168.0.100 
  network 192.168.0.0 
  netmask 255.255.255.0 
  broadcast 192.168.0.255 
  gateway 192.168.0.1 
iface eth0:1 inet static 
 address 192.168.0.200 
 network 192.168.0.0 
 netmask 255.255.255.0
  • the pseudo interface to the same auto line, but I don't know if that matters
  • remove the name tag or indent it properly.
  • your network for the second interface doesn't make sense. it should be a 192 address based on your IP and mask.
1
  • Thanks for the response, I changed the subnet to '1' for the eth0 and to 3 for the eth0:1 interface (see the edit I made in the question). But I guess this should not matter right? Or does this not work for IP addresses with different subnets? Anyway, it did not solve my issue May 31, 2016 at 12:15
0

After some further research, I found that one of my earlier trials did work. The interface file looks like:

auto eth0
iface eth0 inet dhcp

auto eth0:1
iface eth0:1 inet static
address 192.168.3.11
netmask 255.255.255.0
broadcast 192.168.3.255

Note that the network icon in the top right corner of your screen shows that there is no connection, but internet works just fine. Probably this was the thing I missed and concluded that my internet was down because of the network icon.

2
  • as an fyi, that network icon is for network manager. when you set an interface to auto in the interfaces file, network manager no longer manages that interface. hence, network manager tells you that no interfaces are connected because it's not managing any of them
    – Iyad K
    May 31, 2016 at 15:19
  • Ah, makes sense, learning new stuff every day :-). Thanks for the explanation Jun 7, 2016 at 8:33

You must log in to answer this question.

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