0

My Ubuntu 16.04 system connects to a LAN by Ethernet w/ DHCP (say 10.128.10.2).

When I unplug that Ethernet cord, I want my machine to switch to a local static ip (say 192.168.10.2) on that same interface.

I tried the following in etc/network/interface but it didnt work:

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

auto enp0s31f6
iface enp0s31f6 inet dhcp

auto enp0s31f6:1
iface enp0s31f6:1 inet static
address 192.168.10.2
netmask 255.255.255.0

What am i doing wrong?

  • You will need a process to monitor enp0s31f6 and when disconnected, then force a change of the IP address. – K7AAY Feb 12 at 21:12

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.