1

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.

4
  • Why are you trying to get one IP address via DHCP and one manually? Commented Aug 22, 2020 at 14:35
  • @MichaelHampton, this is the config given by the ISP, i.e., OVH. Each IP is added to the main NIC. I tried to (1) dhcp4:no and set addresses:111. & 222., (2) dhcp4:yes without addresses:, and (3) remove the match:macaddress:set-name entry set, but none of that works... I'm note sure what's happening on their end... Commented Aug 23, 2020 at 7:56
  • You can just configure all the addresses manually. OVH will not change them unless you add or delete one from your account. Commented Aug 23, 2020 at 13:52
  • Sure, I'd love that option, but how to do that with a single NIC using Netplan? Commented Aug 24, 2020 at 9:16

1 Answer 1

0

I ended up writing a one-liner script that sets valid_lft and preferred_lft to forever, 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.

/usr/sbin/ip addr change 111.111.111.111 dev ens3 valid_lft forever preferred_lft forever 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.