Ubuntu: How can I remove a secondary IP address?


I'm running Ubuntu Server 17.04. All packages are up to date.

The contents of my /etc/network/interfaces is as follows:

$ cat /etc/network/interfaces  # This file describes the network interfaces available on your system  # and how to activate them. For more information, see interfaces(5).    source /etc/network/interfaces.d/*    # The loopback network interface  auto lo  iface lo inet loopback    # The primary network interface  auto enp0s3  iface enp0s3 inet static      address      netmask      gateway  

But if I run ip addr I see a secondary address:

$ ip addr  1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000      link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00      inet scope host lo         valid_lft forever preferred_lft forever      inet6 ::1/128 scope host         valid_lft forever preferred_lft forever  2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000      link/ether 00:a0:98:35:c1:cd brd ff:ff:ff:ff:ff:ff      inet brd scope global enp0s3         valid_lft forever preferred_lft forever      inet brd scope global secondary enp0s3         valid_lft forever preferred_lft forever      inet6 fe80::2a0:98ff:fe35:c1cd/64 scope link         valid_lft forever preferred_lft forever  

There are no files or folders in /etc/network/interfaces.d/. How can I permanently remove the secondary IP address? It reappears after every reboot.


Turns out that even though dhcp was not enabled in /etc/network/interfaces, dhcpcd.service was still running and assigning an IP. I fixed this with

systemctl stop dhcpcd  systemctl disable dhcpcd  

and rebooted. Secondary IP gone!


In case you set static IP on eth0 (or wlan0) at file /etc/dhcpcd.conf like;

interface eth0      static ip_address=      static routers=      static domain_name_servers=  

then you go to /etc/network/interfaces and check if you set your eth0 (or wlan0) as dhcp as:

iface eth0 dhcp  

then you change it to

iface eth0 manual  

This will fix it.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »