Subject: Re: Forcing NetBSD to use IPv4
To: Alasdair <alasdair@iprimus.com.au>
From: Robert Elz <kre@munnari.OZ.AU>
List: netbsd-users
Date: 02/17/2007 20:21:18
    Date:        Sat, 17 Feb 2007 22:56:50 +1100
    From:        Alasdair <alasdair@iprimus.com.au>
    Message-ID:  <20070217115650.GA554@localhost.locahost.net>

  | How can you force NetBSD 3.0.1 to use IPv4 only.

For now, as I understand it, the only real way (apart from changing
the rc.d/network script) is to recompile the kernel with INET6
undefined.

That will certainly do it.

Alternatively, and probably quicker, if you look for the line

	if ifconfig lo0 inet6 >/dev/null 2>&1; then

in /etc/rc.d/network, and change it to

	if false; then

(leave the other one there commented out, or something), then
no IPv6 addresses should get configured, which should come
fairly close to what you want.

Lastly, and more for the NetBSD kernel (network) developers
reading this (as it isn't going to help you in the near term)
I had a couple of undergrad students look at this for a project,
which they've just finished.

They have a new sysctl node (net.inet6.disabled - or that's
what it will be after I correct what they did...) which if set
to 1 causes the system to act as if the kernel was compiled
witout INET6 (the one major exception being that the net.inet6
sysctl tree remains visible.)   That is, incoming IPv6 packets
are simply ignored, AF_INET6 sockets can't be created, inet6
addresses can't be configured (and if any get configured before
the sysctl var gets set, they won't be reported to apps).

The sysctl node is "disabled" as values other than 1 can be set
to disable individual facets of the INET6 code, rather than
simply all of it in one lump, but that's probably of more use
for debugging than anything practical (leaving it is cheap
however).

Naturally, this isn't INET6 specific, there's also a net.inet.disabled
net.netiso.disabled (and if only stsctl(8) could handle it)
net.appletalk.disabled (and the same just needs a sysctl node
created for any other protocol, though disabling PF_LOCAL
probably isn't rational).

The code needs a little work to make it KNF compliant (well,
OK, a lot of work ... but there actually isn't much of it)
and a few cleanups - in a month or so I should have it
ready for anyone who wants to take it away, review it, and
if it all seems OK, commit it.

By default, everything remains exactly as it is for the
way the kernel is defined (all net.*.disabled nodes are 0)
and aside from the existence of those nodes, nothing
changes.

kre