From owner-freebsd-net@freebsd.org Tue Jul 7 15:29:52 2020 Return-Path: Delivered-To: freebsd-net@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 18213365147 for ; Tue, 7 Jul 2020 15:29:52 +0000 (UTC) (envelope-from zeising+freebsd@daemonic.se) Received: from mailman.nyi.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 4B1RFW6Jhjz3V3C for ; Tue, 7 Jul 2020 15:29:51 +0000 (UTC) (envelope-from zeising+freebsd@daemonic.se) Received: by mailman.nyi.freebsd.org (Postfix) id D6D113652ED; Tue, 7 Jul 2020 15:29:51 +0000 (UTC) Delivered-To: net@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D69963652EC for ; Tue, 7 Jul 2020 15:29:51 +0000 (UTC) (envelope-from zeising+freebsd@daemonic.se) Received: from mail.daemonic.se (mail.daemonic.se [IPv6:2607:f740:d:20::25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4B1RFQ1lrbz3V7l for ; Tue, 7 Jul 2020 15:29:45 +0000 (UTC) (envelope-from zeising+freebsd@daemonic.se) Received: from cid.daemonic.se (localhost [IPv6:::1]) by mail.daemonic.se (Postfix) with ESMTP id 4B1RFM3DXbz3mgx; Tue, 7 Jul 2020 15:29:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=daemonic.se; h= content-transfer-encoding:content-language:content-type :content-type:in-reply-to:mime-version:user-agent:date:date :message-id:from:from:references:subject:subject:received :received; s=20151023; t=1594135782; bh=H8irjcxVxKyba67IJN+ggwwd 386F2UgtXctfHCkMKS4=; b=k9JRudDDo3yY6n2XdjZBLVY2sWS4195Z6klhn7S/ +CUC6jqfFkvlSgyKgxahhyV4sW5feXanCwYloLIaeM6FlYxdBaybnz/8t9ZAzZPZ xPHuHlkPGnV+BCGMv8124MufnEsvgpCgBkOz7nv08Sq1gkZvfBv8b281Tw8Xl8d7 if8= X-Virus-Scanned: amavisd-new at daemonic.se Received: from mail.daemonic.se ([127.0.0.1]) (using TLS with cipher ECDHE-RSA-AES128-GCM-SHA256) by cid.daemonic.se (mailscanner.daemonic.se [127.0.0.1]) (amavisd-new, port 10587) with ESMTPS id Uf63ZY8NzonS; Tue, 7 Jul 2020 15:29:42 +0000 (UTC) Received: from garnet.daemonic.se (unknown [IPv6:2001:470:dca9:201:c01f:220e:48eb:d4e3]) by mail.daemonic.se (Postfix) with ESMTPSA id 4B1RFL4bsyz3mMv; Tue, 7 Jul 2020 15:29:42 +0000 (UTC) Subject: Re: Specifying link-local address in rc.conf To: Michael Gmelin Cc: net@FreeBSD.org References: <713e1f3e-4dd9-8dcf-c6d2-15c684bdce5b@daemonic.se> <20200707120835.4834198e@bsd64.grem.de> <20200707171027.4556a126@bsd64.grem.de> From: Niclas Zeising Message-ID: Date: Tue, 7 Jul 2020 17:29:42 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200707171027.4556a126@bsd64.grem.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 4B1RFQ1lrbz3V7l X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=daemonic.se header.s=20151023 header.b=k9JRudDD; dmarc=pass (policy=none) header.from=daemonic.se; spf=pass (mx1.freebsd.org: domain of zeising@daemonic.se designates 2607:f740:d:20::25 as permitted sender) smtp.mailfrom=zeising@daemonic.se X-Spamd-Result: default: False [-3.59 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[daemonic.se:s=20151023]; NEURAL_HAM_MEDIUM(-0.93)[-0.928]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; NEURAL_HAM_LONG(-1.03)[-1.033]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_THREE(0.00)[4]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[daemonic.se:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[daemonic.se,none]; NEURAL_HAM_SHORT(-0.63)[-0.630]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; TAGGED_FROM(0.00)[freebsd] X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jul 2020 15:29:52 -0000 On 2020-07-07 17:10, Michael Gmelin wrote: >=20 >=20 > On Tue, 7 Jul 2020 12:08:35 +0200 > Michael Gmelin wrote: >=20 >> On Mon, 6 Jul 2020 22:58:54 +0200 >> Niclas Zeising 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 >> metric 0 mtu 1500 options=3D80028 >> 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 >> status: active >> nd6 options=3D1 >> >> -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