0

I'm trying to flip flop the IP addresses on eth0 and eth0:1 with as little downtime as possible.

So far I have tried changing the IP addresses in /etc/network/interfaces, then running ifdown eth0:1 && ifdown eth0 && ifup eth0 && ifup eth0:1

This gave me

RTNETLINK answers: Cannot assign requested address
RTNETLINK answers: Cannot assign requested address
RTNETLINK answers: File exists
ifup: failed to bring up eth0

And left me with no interfaces up

Next I tried

ip address del 192.168.0.9 dev eth0:1 && ip address del 192.168.0.3 dev eth0 && ip address add 192.168.0.9/28 brd + dev eth0 && ip address add 192.168.0.3/28 brd + dev eth0:1

That left me with eth0 up, but with no assigned IP.

finally I tried editing /etc/network/interfaces to swap the IP addresses and then ran service networking restart. This also left me with no interfaces up.

/etc/network/interfaces

auto eth0
allow-hotplug eth0
iface eth0 inet static
    address 192.168.0.9
    netmask 255.255.255.240
    gateway 192.168.0.1

auto eth0:1
allow-hotplug eth0:1
iface eth0:1 inet static
    address 192.168.0.3
    netmask 255.255.255.240

ifconfig

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.3  netmask 255.255.255.240  broadcast 192.168.0.15
        inet6 fe80::ba27:ebff:febd:bcd6  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:bd:bc:d6  txqueuelen 1000  (Ethernet)
        RX packets 1071  bytes 73561 (71.8 KiB)
        RX errors 0  dropped 3  overruns 0  frame 0
        TX packets 1150  bytes 111382 (108.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.9  netmask 255.255.255.240  broadcast 192.168.0.15
        ether b8:27:eb:bd:bc:d6  txqueuelen 1000  (Ethernet)

migrated from serverfault.com Mar 19 at 22:57

This question came from our site for system and network administrators.

  • Might I ask why you need to do this? Since these are stacked interfaces, the same physical port will still respond to traffic from both addresses. Can you share the issue that is forcing you to have to change this on the fly? – datUser Mar 20 at 2:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.