Ubuntu: How can I remove a secondary IP address?



Question:

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 10.99.0.10      netmask 255.255.0.0      gateway 10.99.0.1  

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 127.0.0.1/8 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 10.99.0.10/16 brd 10.99.255.255 scope global enp0s3         valid_lft forever preferred_lft forever      inet 10.99.1.31/16 brd 10.99.255.255 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.


Solution:1

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!


Solution:2

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

interface eth0      static ip_address=192.168.3.51      static routers=192.168.3.1      static domain_name_servers=168.126.63.1  

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
Previous
Next Post »