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

next in thread | previous in thread | raw e-mail | index | archive | help
On 2020-07-07 17:10, Michael Gmelin wrote:
>=20
>=20
> On Tue, 7 Jul 2020 12:08:35 +0200
> Michael Gmelin <freebsd@grem.de> wrote:
>=20
>> On Mon, 6 Jul 2020 22:58:54 +0200
>> Niclas Zeising <zeising+freebsd@daemonic.se> wrote:
>>
>>> On 2020-07-06 13:05, Niclas Zeising wrote:
>>>> Hi!
>>>> Is it possible to specify a link-local address in rc.conf, and get
>>>> only that link-local address?
>>>>
>>>> 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 d=
oes
>>>> 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.
>>>>
>>>> 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.
>>>>
>>>> This is causing issues when I want for instance rtadvd to use the
>>>> 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.
>>>>
>>>> All of this is on FreeBSD 12.1.
>>>>
>>>> Perhaps I'm just missing something, but this behavior feels a
>>>> little surprising.
>>>>
>>>> I can share more detailed configuration, and perhaps the whole
>>>> virtual machine I'm testing on, if needed.
>>>>
>>>> Regards
>>>
>>> I did some more digging.  It only happens when there's also an
>>> ifconfig_IF for IPv4 in the /etc/rc.conf.
>>>
>>> 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"
>>>
>>> This configuration creates an EUI64-based link-local addess on
>>> vtnet0 as well.
>>>
>>> Working configuration (apart from no IPv4)
>>> ifconfig_vtnet0_ipv6=3D"inet6 fe80::1/64"
>>> ifconfig_vtnet0_alias0=3D"inet6 2001:6b8::/64""
>>
>>>   =20
>>
>> This works:
>>
>> 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"
>>
>> # 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>
>>
>> -m
>>
>=20
> This works too:
>=20
> 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"
>=20
> As well as this:
>=20
> 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"
>=20
> 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).
>=20
> Cheers,
> Michael
>=20

Thank you for these examples.
I've also found out that
ifconfig_vtnet0=3D""
following what's in your examples also work.

I wonder if this should either be documented better (the manual for=20
rc.conf even brings up the vtnet0_alias0=3D"fe80::1/64" as an example) or=
=20
if the rc scripts dealing with all this should be changed so that if you=20
have both ifconfig_vtnet0=3D"inet ..." and ifconfig_vtnet0_ipv6=3D"inet6=20
..." a link-local address isn't automatically created if one is in rc.con=
f.
The whole handling of network interfaces in rc is (understandably) quite=20
hairy, and I don't know where this would belong, or how to fix it.=20
Maybe it's enough to have ipv6 addresses assigned before ipv4 ones, or=20
perhaps a separate ifconfig_vtnet0_link_local=3D"inet6 ..." should be add=
ed.
I can solve my immediate problems, I'm just thinking out loud about if=20
this is an issue that needs to be solved in a better way, or just be=20
better documented.

Also thank you for the examples using ifconfig_vtnet0_aliases=3D, I was=20
unaware of that option, and have always done _alias0, _alias1 and so on.=20
  This will make things easier for me.

Regards
--=20
Niclas



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?d93a3de5-0e4b-5a09-9956-41ab23bfe33b>