Ubuntu second static IP, ifconfig, /etc/network/interfaces
Is Network Manager managing the interface? I have configured network manager not to touch the interfaces that I manage through /etc/network/interfaces
by having the following in /etc/NetworkManager/NetworkManager.conf
:
[ifupdown]
managed=false
When Network Manager is disabled for sure we can take a look at /etc/network/interfaces
. Interface aliases are no longer recommended, but ip
(8) can add more than one address to one interface. This can be done in /etc/network/interfaces
as follows:
auto eth1
iface eth1 inet static
address 192.168.178.2
netmask 255.255.255.0
gateway 192.168.178.1
up ip addr add 192.168.178.3/24 dev eth1
down ip addr del 192.168.178.3/24 dev eth1
Read the manpage of interfaces(5) and ip(8) for more information.
Related videos on Youtube
Schmoove
Updated on September 18, 2022Comments
-
Schmoove over 1 year
I would like to add a second static IP to my local Ubuntu 11.10 desktop machine and have it automatically available after rebooting. So far I am successfully using ifconfig to to temporarily set up an alias for my primary network interface:
# ifconfig eth1:0 192.168.178.3 up # ifconfig eth1 Link encap:Ethernet HWaddr c8:60:00:ef:a3:d9 inet addr:192.168.178.2 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::ca60:ff:feef:a3d9/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:61929 errors:0 dropped:0 overruns:0 frame:0 TX packets:64034 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:45330863 (45.3 MB) TX bytes:28175192 (28.1 MB) Interrupt:42 Base address:0x4000 eth1:0 Link encap:Ethernet HWaddr c8:60:00:ef:a3:d9 inet addr:192.168.178.3 Bcast:192.168.178.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:42 Base address:0x4000
However, when I add the following to /etc/network/interfaces, the alias is not up and running as expected after a reboot:
# vi /etc/network/interfaces auto eth1:0 iface eth1:0 inet static address 192.168.178.3 netmask 255.255.255.0
I would like to know what to configure to get this to work. As a side note, I am running gnome shell.
-
Dom over 11 yearsIs there network-manager on this machine ? If it is the case, it takes precedence on /etc/network/interfaces
-
Schmoove over 11 yearsThe package network-manager seems to be installed on my system. I just tried configuring the network manager and I failed. I have the feeling the network manager might be buggy or maybe just not intuitive enough for me. I tried Gnome System Settings > Network > Wired > Configure == which opened a window to configure my "Wired connection 1". It allowed me to add a second IP address, but after saving, closing and reopening the dialog, my changes were gone.
-
Schmoove over 11 yearsNow it gets even weirder, I clicked twice on the "Configure" button to open the dialog for editing my "Wired connection 1", the second click opened a completely different dialog, namely an overview of all connections and the option to add a new connection. I added a new connection, messed up a setting, saved, closed, reopened, edited, saved, closed... and my changes are gone again. I give up. If anyone has a solution, please help :)
-
Dom over 11 yearsAs MKzero says : remove Network Manager to come back in standard mode as you want.
-
ptman over 10 yearsWhat's up with your broadcast (bcast) addresses?
-