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...
172.16.100.0
network with a192.168.3.11
IP? Also, have you checked the routes (tryroute -n
).172.16.100.0
was the result of bad copying and pasting, sory