PreferredLIfetime=0 appears to not work in Ubuntu 18.04 systemd networking

Ben Coleman oloryn at benshome.net
Sat Jan 11 21:51:51 UTC 2020


I've got some Ubuntu 18.04 servers where they have 2 different IPv6
addresses, and I want one to be used when making outgoing connections.
From what I've been able to dig up, the way to do this is to set the
Preferred Lifetime of the unwanted address to 0.  Since 18.04 defaults
to systemd network setup, I've tried to do that in /etc/systemd/network/
configuration.  However, specifying PreferredLifetime=0 doesn't seem to
do anything.

My network configuration file looks like this:

----------------------
[Match]
Name=eth0

[Network]
DHCP=no
IPv6PrivacyExtensions=false

# DNS addresses
DNS=173.230.140.5 66.228.59.5 66.228.62.5

Gateway=45.79.220.1
Gateway=fe80::1%eth0

[Address]
# IPv4 gateway and primary address
Address=45.79.220.164/24

[Address]
# Primary address
Address=2600:3c02:e000:e3:f03c:91ff:fee5:e5bf/64

[Address]
# Add second IPv6 address
# (Do not remove the primary address routes to this one)
Address=2600:3c02::f03c:91ff:fee5:e5bf/64
PreferredLifetime=0
----------------------

----------------------
However, both addresses end up showing a preferred lifetime of forever:
$ 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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state
UP group default qlen 1000
    link/ether f2:3c:91:e5:e5:bf brd ff:ff:ff:ff:ff:ff
    inet 45.79.220.164/24 brd 45.79.220.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 2600:3c02::f03c:91ff:fee5:e5bf/64 scope global
       valid_lft forever preferred_lft forever
    inet6 2600:3c02:e000:e3:f03c:91ff:fee5:e5bf/64 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::f03c:91ff:fee5:e5bf/64 scope link
       valid_lft forever preferred_lft forever
----------------------

Any idea what I'm doing wrong, if anything?  Should I be taking a
different approach to this?

Ben
-- 
Ben Coleman oloryn at benshome.net | For the wise man, doing right trumps
http://oloryn.benshome.net/     | looking right.  For the fool, looking
Amateur Radio NJ8J              | right trumps doing right.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20200111/b9f2b5e4/attachment.sig>


More information about the ubuntu-users mailing list