At Tue, 18 Nov 2025 20:40:14 +0700, Robert Elz <[email protected]> wrote: Subject: Re: Is it possible to completely disable ipv6 in NetBSD 10 > > more simply, just as: > > /sbin/ifconfig "$int" | > while read word arg stuff > do > case $word in > inet6) > > > ;; > esca > done > > ? In some situations that might be doubtful, as you'd be changing what > output the initial ifconfig is generating, while it is is still producing > it (nominally anyway) - but ifconfig doesn't work like that, it will have > obtained the complete info for the interface, before it starts writing > anything, so later changes will have no effect. > > The form using the command substitution extracts all of the v6 addresses > from the ifconfig output, and adds them as words for the for loop, before > that loop starts running, so would be, in other cases, safer.
Thanks!
I had an uncomfortable feeling about needing the command substitution,
but I hadn't analysed it yet.
> Do quote expansions, almost always - most people would also
> quote the $word - but that is one situation where it isn't really
> needed - another is in assignments, like X=$word
I didn't quote $int because it's not quoted anywhere else in that
function.
I agree it's a good habit to quote variable expansions used in command
lines, but in this case $int is set by "for int in $tmp;" so I think
that also means that, like $word, it really won't need quoting.
> ps: it is also stated in ifconfig(8)
>
> delete does not work for IPv6 addresses.
> Use -alias with explicit IPv6 address instead.
>
> That is, the
>
> /sbin/ifconfig "$int" inet6 delete "$arg"
>
> should probably be written as
>
> /sbin/ifconfig "$int" inet6 "$arg" -alias
>
> just to be safer - though personally I doubt that almost anyone
> truly understands how the ifconfig code actually works - I certainly
> don't, it is all just black magic.
For all the test cases I've tried so far, which are admittedly very few,
the "delete" form has worked reliably.
I just tested the "-alias" form on a link-local address and that did
work equally well. I actually didn't expect that it would, but....
Looking at the timing of when that wording was added to ifconfig(8) I'm
guessing the underlying implementation has changed since, especially
since it is stated so emphatically that "delete does not work for IPv6"
while with the current implementation it does seems to work for some, if
not all, cases.
I don't understand how the command-line parser works, but skimming over
the code makes me think "delete" is more or less an alias of sorts for
"-alias".
As a bit of a side-note, I think /etc/rc.d/network is still highly
prejudiced towards IPv4. For example /etc/ifaliases can only be "inet"
addresses, nothing else. IPv6 addresses are not removed on "stop".
Dhcpcd can be started three different ways, and parts of the code don't
account for this. It probably needs a deeper design and implementation
review.
Another side note, it looks like FreeBSD doesn't auto-configure a
link-local address. I have a FreeBSD VM running in parallel on the same
host as my -current daily VM. I'm not sure what "nd6 options" really
means, but I'm guessing it is "IPv6 neighbour discovery" and the
"IFDISABLED" bit means that the interface has it disabled, which would
be by default as I don't think I did anything to make it that way. I
just have 'ifconfig_xn0="inet 10.0.1.144/24" ' in /etc/rc.conf:
xn0: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0
mtu 1500
options=3<RXCSUM,TXCSUM>
ether 00:16:3e:52:a7:0a
inet 10.0.1.144 netmask 0xffffff00 broadcast 10.0.1.255
media: Ethernet manual
status: active
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
--
Greg A. Woods <[email protected]>
Kelowna, BC +1 250 762-7675 RoboHack <[email protected]>
Planix, Inc. <[email protected]> Avoncote Farms <[email protected]>
pgpVlrAgpqwJs.pgp
Description: OpenPGP Digital Signature
