Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Jul 2020 17:10:27 +0200
From:      Michael Gmelin <freebsd@grem.de>
To:        Niclas Zeising <zeising+freebsd@daemonic.se>
Cc:        net@FreeBSD.org
Subject:   Re: Specifying link-local address in rc.conf
Message-ID:  <20200707171027.4556a126@bsd64.grem.de>
In-Reply-To: <20200707120835.4834198e@bsd64.grem.de>
References:  <713e1f3e-4dd9-8dcf-c6d2-15c684bdce5b@daemonic.se> <a6a05909-a11d-42c9-2e62-9fc50b38c9f3@daemonic.se> <20200707120835.4834198e@bsd64.grem.de>

next in thread | previous in thread | raw e-mail | index | archive | help


On Tue, 7 Jul 2020 12:08:35 +0200
Michael Gmelin <freebsd@grem.de> wrote:

> On Mon, 6 Jul 2020 22:58:54 +0200
> Niclas Zeising <zeising+freebsd@daemonic.se> wrote:
>=20
> > On 2020-07-06 13:05, Niclas Zeising wrote: =20
> > > Hi!
> > > Is it possible to specify a link-local address in rc.conf, and get
> > > only that link-local address?
> > >=20
> > > When I add a specific link-local address, such as fe80::1/64, to
> > > an interface from the command line, and then add a global uincast
> > > address, it works as expected, I do not get an additional
> > > link-local address. When I try to do the same in rc.conf however,
> > > it does not work. I have added the following:
> > > ifconfig_vtnet0_inet6=3D"inet6 fe80::1/64"
> > > ifconfig_vtnet0_alias0=3D"2001:6b8::1/64"
> > > to rc.conf, but when restarting, I get both fe80::1 and a
> > > EUI64-based link-local address assigned to the interface.=C2=A0 It do=
es
> > > not matter which order I specify the entries in rc.conf.
> > > I have tried changing the sysctl net.inet6.ip6.auto_linklocal to 0
> > > in /etc/sysctl.conf, but that does not work (it seems it takes
> > > effect too late, the interface still has the AUTO_LINKLOCAL flag
> > > set according to ifconfig).
> > > I tried adding -auto_linklocal to the ifconfig_* lines in
> > > /etc/rc.conf, and while this removes the AUTO_LINKLOCAL flag from
> > > the interface, a EUI64 based link-local address is still assigned
> > > to the interface.
> > >=20
> > > While there might not be much of a problem having mulitple
> > > link-local addresses, this is surprising.=C2=A0 Adding a specific
> > > link-local address to an interface, even from rc.conf, shouldn't
> > > mean that the EUI64-one is created.=C2=A0 Perhaps something like
> > > ifconfig_IF_linklocal=3D"" should be added, or this is a bug in
> > > rc.network.=C2=A0 I tried looking through rc.network and related rc
> > > files, but I didn't find anything obvious, and I couldn't really
> > > figure out how addresses are added to interfaces during boot.
> > >=20
> > > This is causing issues when I want for instance rtadvd to use the=20
> > > fe80::1/64 address as source for router advertisements, since it
> > > picks the EUI64 link-local address as source (which means this
> > > also ends up in client routing tables as the default gateway).=C2=A0 I
> > > can work around this problem by adding fe80::1/64 with
> > > prefer_source, but I would prefer if there only was one
> > > link-local address on an interface.
> > >=20
> > > All of this is on FreeBSD 12.1.
> > >=20
> > > Perhaps I'm just missing something, but this behavior feels a
> > > little surprising.
> > >=20
> > > I can share more detailed configuration, and perhaps the whole
> > > virtual machine I'm testing on, if needed.
> > >=20
> > > Regards   =20
> >=20
> > I did some more digging.  It only happens when there's also an=20
> > ifconfig_IF for IPv4 in the /etc/rc.conf.
> >=20
> > Not working configuration (/etc/rc.conf)
> > ifconfig_vtnet0=3D"192.168.0.1/24"
> > ifconfig_vtnet0_ipv6=3D"inet6 fe80::1/64"
> > ifconfig_vtnet0_alias0=3D"inet6 2001:6b8::/64"
> >=20
> > This configuration creates an EUI64-based link-local addess on
> > vtnet0 as well.
> >=20
> > Working configuration (apart from no IPv4)
> > ifconfig_vtnet0_ipv6=3D"inet6 fe80::1/64"
> > ifconfig_vtnet0_alias0=3D"inet6 2001:6b8::/64"" =20
>=20
> >  =20
>=20
> This works:
>=20
> ifconfig_vtnet0=3D"inet6 -auto_linklocal"
> ifconfig_vtnet0_ipv6=3D"up"
> ifconfig_vtnet0_aliases=3D"\
>   inet 192.168.0.1/24 inet6 fe80::1/64 inet6 2001:6b8::/64"
>=20
> # ifconfig vtnet0
> vtnet0: flags=3D8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST>
> metric 0 mtu 1500 options=3D80028<VLAN_MTU,JUMBO_MTU,LINKSTATE>
>         ether 58:9c:fc:0b:99:97
>         inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
>         inet6 fe80::1%vtnet0 prefixlen 64 scopeid 0x2
>         inet6 2001:6b8:: prefixlen 64
>         media: Ethernet 10Gbase-T <full-duplex>
>         status: active
>         nd6 options=3D1<PERFORMNUD>
>=20
> -m
>=20

This works too:

ifconfig_vtnet0=3D"inet"
ifconfig_vtnet0_ipv6=3D"inet6 -auto_linklocal"
ifconfig_vtnet0_aliases=3D"\
  inet 192.168.0.1/24 inet6 fe80::1/64 inet6 2001:6b8::/64"

As well as this:

ifconfig_vtnet0=3D"inet"
ifconfig_vtnet0_ipv6=3D"inet6 -auto_linklocal fe80::1/64"
ifconfig_vtnet0_aliases=3D"inet 192.168.0.1/24 inet6 2001:6b8::/64"

Using `ifconfig_vtnet0=3D"inet 192.168.0.1/24"` adds the auto-generated
link-local address (which is what you seem to try to avoid).

Cheers,
Michael

--=20
Michael Gmelin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20200707171027.4556a126>