What is the rc.conf variable for "ip6addrctl prefer_ipv4"?

I'm trying to have the command: # /etc/rc.d/ip6addrctl prefer_ipv4 take effect at system startup. I have tried all of the following, found by various searches, one at a time in /etc/rc.conf but none of them seem to work:
Code:
ip6addrctl_flags="prefer_ipv4"
ip6addrctl_policy="prefer_ipv4"
ipv6_prefer="NO"
It seems that this area has had more than the usual number of changes, based on things like a thread titled "Un-obsolete'ing ipv6_enable" in freebsd-rc@.

This is on 8-STABLE.
 
Too bad, I was hoping it worked :e

/etc/defaults/rc.conf mentions:
Code:
ip6addrctl_enable="YES" # Set to YES to enable default address selection
ip6addrctl_verbose="NO" # Set to YES to enable verbose configuration messages

So it's set by default. If I remember correctly IPv6 will be preferred if IPv6 is enabled. Try setting it to NO (in /etc/rc.conf, don't touch the defaults).
 
SirDice said:
Too bad, I was hoping it worked :e
Me, too. :(

/etc/defaults/rc.conf mentions:
Code:
ip6addrctl_enable="YES" # Set to YES to enable default address selection
ip6addrctl_verbose="NO" # Set to YES to enable verbose configuration messages
That just controls whether /etc/rc.d/ip6addrctl gets run at all during startup. We need to run it to get it to install the prefer_ipv4 table.

Looking at the RELENG-8 version of /etc/rc.d/ip6addrctl is somewhat instructive:
Code:
ip6addrctl_start()
{
        if ifconfig lo0 inet6 >/dev/null 2>&1; then
                # We have IPv6 support in kernel.

                # install the policy of the address selection algorithm.
                if [ -f /etc/ip6addrctl.conf ]; then
                        ip6addrctl flush >/dev/null 2>&1
                        ip6addrctl install /etc/ip6addrctl.conf
                        checkyesno ip6addrctl_verbose && ip6addrctl
                else
                        if checkyesno ipv6_enable; then
                                ip6addrctl_prefer_ipv6
                        else
                                ip6addrctl_prefer_ipv4
                        fi
                fi
        fi
}
So, if there's an /etc/ip6addrctl.conf file, it will be used. If that file doesn't exist, the state of ipv6_enable is checked. If yes, execute the ip6addrctl_prefer_ipv6 routine. If no, execute ip6addrctl_prefer_ipv4 instead. There doesn't seem to be any way to override that.

In version 1.11 of /etc/rc.d/ip6addrctl, there seems to be completely different logic in play, and uses the rc.conf setting of ip6addrctl_policy to control what gets done:
Code:
ip6addrctl_start()
{
	afexists inet6 || return 0

	# install the policy of the address selection algorithm.
	case "${ip6addrctl_policy}" in
	[Aa][Uu][Tt][Oo])
		if [ -r "${config_file}" -a -s "${config_file}" ]; then
			ip6addrctl flush >/dev/null 2>&1
			ip6addrctl install "${config_file}"
			checkyesno ip6addrctl_verbose && ip6addrctl
		else
			if checkyesno ipv6_activate_all_interfaces; then
				ip6addrctl_prefer_ipv6
			else
				ip6addrctl_prefer_ipv4
			fi
		fi
	;;
	ipv4_prefer)
		ip6addrctl_prefer_ipv4
	;;
	ipv6_prefer)
		ip6addrctl_prefer_ipv6
	;;
	[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
		# Backward compatibility when ipv6_prefer=YES
		ip6addrctl_prefer_ipv6
	;;
	[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
		# Backward compatibility when ipv6_prefer=NO
		ip6addrctl_prefer_ipv4
	;;
	*)
		warn "\$ip6addrctl_policy is invalid: ${ip6addrctl_policy}. " \
		    " \"ipv4_prefer\" is used instead."
		ip6addrctl_prefer_ipv4
	;;
	esac
}
 
If IPv6 is working why do you want to prefer IPv4? And if IPv6 doesn't work why not simply disable it?
 
SirDice said:
If IPv6 is working why do you want to prefer IPv4? And if IPv6 doesn't work why not simply disable it?
I have an allocated IPv6 network and all of the systems that are capable of dual-stack operation have both IPv4 and IPv6 addresses allocated. There are some legacy devices that only support IPv4; they're not relevant to this discussion.

I do not have IPv6 outside connectivity yet.

In the default configuration, any attempt to open a connection to an external host that has both an IPv4 and an IPv6 address hangs for an extended period while the IPv6 connection times out*. This makes things like portupgrade take a lot longer, as it tries IPv6 for each master site, then falls back to IPv4. For a port that has had its packages removed from some master sites, this causes a pattern of pause-notfound-pause-moved-pause-notfound-pause-downloading.

Further, this site (forums.freebsd.org) seems to have developed an AAAA record recently, which means that I see this delay here as well.

* Somewhere along the line, IETF apparently decided that implementations should ignore IPv6 ICMP unreachables, which means that a well-behaved router that sends a "you can't get there from here" IPv6 ICMP unreachable to a client will be ignored. See this PDF.

A web search for "prefer ipv4 over ipv6" will display a large number of people looking for the same thing. Since the FreeBSD developers included this feature in /etc/rc.d/ip6addrctl, I'd like to find out how to enable it, rather than discussing why I want to.
 
Makes sense :e

And I suggest getting in touch with the mailing list. Perhaps it's already being planned or we simply haven't figured out how to do it properly ;)
 
SirDice said:
Makes sense :e

And I suggest getting in touch with the mailing list. Perhaps it's already being planned or we simply haven't figured out how to do it properly ;)
Per a reply from hrs@ on freebsd-rc, it isn't hooked up in 8-STABLE, but is in CURRENT.
 
Back
Top