What's the impact, if any, on having values greater than zero/forever for valid_lft
and preferred_lft
? Should I worry about this, and if so, how to set it automatically to forever
at boot time (preferably using Netplan)?
root:~# ip a
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether aa:00:11:22:33:44 brd ff:ff:ff:ff:ff:ff
inet 111.111.111.111/32 scope global ens3
valid_lft 86154sec preferred_lft 86154sec
inet 222.222.222.222/32 scope global ens3
valid_lft forever preferred_lft forever
inet6 fe80::aaa:bbb:ccc:ddd/64 scope link
valid_lft forever preferred_lft forever
root:~# ip addr change 111.111.111.111 dev ens3 valid_lft forever preferred_lft forever
root:~# ip a
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether aa:00:11:22:33:44 brd ff:ff:ff:ff:ff:ff
inet 111.111.111.111/32 scope global ens3
valid_lft forever preferred_lft forever
inet 222.222.222.222/32 scope global ens3
valid_lft forever preferred_lft forever
inet6 fe80::aaa:bbb:ccc:ddd/64 scope link
valid_lft forever preferred_lft forever
I am asking this question because I realized that the server default IP address switched from 111.111.111.111
to 222.222.222.222
without manual interraction, i.e., ifconfig -a
displayed this for ens3
:
root:~# ifconfig -a
ens3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 222.222.222.222 netmask 255.255.255.255 broadcast 0.0.0.0
inet6 fe80::aaa:bbb:ccc:ddd prefixlen 64 scopeid 0x20<link>
ether aa:00:11:22:33:44 txqueuelen 1000 (Ethernet)
RX packets 206473 bytes 54232020 (54.2 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 111121 bytes 19855468 (19.8 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
root:~# cat /etc/netplan/*.yaml
network:
version: 2
ethernets:
ens3:
dhcp4: yes
match:
macaddress: aa:00:11:22:33:44
mtu: 1500
set-name: ens3
addresses:
- 111.111.111.111/32
- 222.222.222.222/32
nameservers:
addresses:
- 8.8.8.8
- 4.4.4.4
- 1.1.1.1
- 1.0.0.1
Could valid_lft
and preferred_lft
be the reason of the switch?
If not, how to make sure that the main IP address remains 111.111.111.111
in this configuration? I'm using Virtualmin, and once in a while it flashes a message saying that the main IP addess has been changed to 222.222.222.222
, and offers to modify it from 111.111.111.111
to 222.222.222.222
. At the time, ifconfig
displays 222.222.222.222
as shown above.
Best Answer
I ended up writing a one-liner script that sets
valid_lft
andpreferred_lft
toforever
, run as a service at boot time, after the network service.I do not know if this is the solution to my problem, but since I've done that, the main IP doesn't switch automatically anymore.