I have changed the IP but after reboot,old IP is still there

Kernels & Hardware, configuring network, installing services

I have changed the IP but after reboot,old IP is still there

Postby knopfler » 2020-05-25 06:37

Hello everybody and thanks for reading this

I have a Debian 9 server with one IP, If I type ip a I see this:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group defaul
(...)
2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:ee:e5:7c brd ff:ff:ff:ff:ff:ff
inet x.x.x.x/24 brd x.x.x.255 scope global ens192
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:feee:e57c/64 scope link
valid_lft forever preferred_lft forever


Where x.x.x.x is the IP of the server. And the/etc/network/interfaces file is this:

# 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


Then I added a second IP:

2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:ee:e5:7c brd ff:ff:ff:ff:ff:ff
inet x.x.x.x/24 brd x.x.x.255 scope global ens192
valid_lft forever preferred_lft forever
inet y.y.y.y/26 scope global ens192:1
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:feee:e57c/64 scope link
valid_lft forever preferred_lft forever


And the/etc/network/interfaces file is:

# 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
iface ens192:1 inet static
address y.y.y.y
netmask y.y.y.192
auto ens192:1


Where y.y.y.y is the new IP.

Then I delete the old IP:

ip addr del x.x.x.x/24 dev ens192


And all works fine with the new IP, the old one does not work anymore. But, if I restart the server, old IP appears and start to work.

What I have to do to delete the old IP forever even if i restart the server?

Thank you
knopfler
 
Posts: 1
Joined: 2020-05-25 06:28

Re: I have changed the IP but after reboot,old IP is still t

Postby andre@home » 2020-05-25 09:11

Apperently your DHCP is still running and thats the one who fills out the "old ip adress" after a reboot.

So you really have to disable DCHP.
Code: Select all
update-rc.d -f dhcpd remove

https://superuser.com/questions/547114/ ... still-runs
andre@home
 
Posts: 392
Joined: 2011-10-02 08:00

Re: I have changed the IP but after reboot,old IP is still t

Postby p.H » 2020-05-28 10:02

knopfler wrote:And the/etc/network/interfaces file is:

It means that ens192 is not configured in this file. Maybe in /etc/network/interfaces.d/*, or by NetworkManager.

knopfler wrote:iface ens192:1 inet static

IP aliases such as ens192:1 are now an obsolete and useless notation.
If ens192 was configured by NetworkManager and you configure it (not ens192:1) in /etc/network/interfaces, NetworkManager will ignore it.

knopfler wrote:Then I delete the old IP:
Code: Select all
ip addr del x.x.x.x/24 dev ens192

You are aware that ip command effect is not persistent across reboots, are you ?

andre@home wrote:So you really have to disable DCHP.
Code: Select all
update-rc.d -f dhcpd remove

You are confusing dhcpcd (DHCP client) and dhcpd (DHCP server).
It is better to disable a DHCP client in the network configuration than in init scripts.
p.H
 
Posts: 1438
Joined: 2017-09-17 07:12


Return to System configuration

Who is online

Users browsing this forum: PsySc0rpi0n and 15 guests

fashionable