I'm not sure yet if this is a bug or could become a new feature or I'm simply too stupid, so I'm labeling it a support request. ;)
I added a few IPv6 sites to my experimental Virtualmin. During system boot, I get this -- twice for each v6 IP -- in boot.log
:
[Sun Jul 10 22:01:25 2011] [error] (EAI 9)Address family for hostname not supported: Could not resolve host name 2a01:4f8:101:1ffc::1:20 -- ignoring!
Consequently, Apache is not listening on TCP6 [::]:80.
Performing /etc/init.d/apache2 restart
after boot is complete fixes the issue. Apache does not complain, and starts listening on TCP6.
My assumption is that there is a race condition during boot. Apache is getting started before the /sbin/ifconfig
commands from /etc/network/interfaces
get executed, which set up the additional v6 IP addresses when the interface is up, and thus does not detect its IP addresses yet.
Is there a clean solution to this? As in, aside from just introducing an arbitrary delay during Apache's start, hoping that the v6 IPs are configured before the delay runs out.
Comments
Submitted by JamieCameron on Sun, 07/10/2011 - 15:47 Comment #1
I wonder if perhaps Virtualmin isn't putting the right IPv6 listen directive for the address in the apache config.
What Listen line is it adding for that domain's IPv6 address exactly?
Submitted by Locutus on Mon, 07/11/2011 - 03:34 Comment #2
The global listen directives in
/etc/apache2/ports.conf
are:The main config file ends with:
Interestingly, no mention of the IPv6 addresses yet... Well, "Listen" without address probably means "listen on everything available".
Or... is this maybe correct? Since I do not have more than one vhost that shares the same IPv6 address, but both of the test vhosts are reaching Apache through their individual IP, I suppose that's not a "name virtual host", but an "address virtual host" to Apache.
The two virtual servers in question have this in their vhost config file:
VirtualHost 46.4.181.243:80 (2a01:4f8:101:1ffc::1:20):80
EDIT: I replaced the square brackets around the IPv6 address with round brackets, cause the forum otherwise won't show the line.
That's for the "test7" one. The "test8" has "::1:21" respectively.
Submitted by JamieCameron on Sun, 07/10/2011 - 21:19 Comment #3
Yeah, the "Listen 80" should cause it to listen on all ports.
What about the <virtualhost> block for that domain - what addresses does its first line contain?
Submitted by Locutus on Mon, 07/11/2011 - 03:33 Comment #4
Argh! I actually already posted the virtualhost block, but the forum is hiding it for some reason. I'll try again to make it visible. :P
Edited it. Replaced [ with (, as to hide that "command" from the forum.
Also, please note that Apache does, with the exact same config, start up fine when I re-start it after system boot is complete! Only during boot, the startup produces the errors (which causes it to not listen on TCP6, the rest is okay).
So I'm guessing the config should be okay, but it's rather like the (additional, per-SSL-site) IPv6 addresses are not yet available during boot.
Submitted by JamieCameron on Mon, 07/11/2011 - 11:02 Comment #5
I'm not seeing the <virtualhost> block in your post, sorry. All I need is the first line, and you can remove any < or > characters.
That said, this seems to me like an Ubuntu bug - if IPv6 initialization is being delayed until after Apache starts, then it indicates a problem with one or both init scripts..
Submitted by Locutus on Mon, 07/11/2011 - 15:43 Comment #6
I edited post #2, which already had the virtualhost line, but seemingly the [ ] characters in it confused the forum software. So I replaced them with ( )... just saying so that you don't think there's an error in the file. :)
As for Ubuntu bug... it's possible. Though I'm wondering if anyone else is seeing this issue. Ubuntu is rather widespread, as is Apache, and Virtualmin hopefully too. :)
I'll see if there some way to instruct the init process to wait with the Apache start until all IPv6 addresses have been set.
Submitted by JamieCameron on Mon, 07/11/2011 - 15:26 Comment #7
I guess a hack work-around would be to edit /etc/init.d/apache2 and add a sleep 10 statement somewhere before it start the apache2 process ..
Submitted by JamieCameron on Mon, 07/11/2011 - 15:28 Comment #8
Also, check out http://ubuntuforums.org/showthread.php?t=935955
Submitted by Locutus on Mon, 07/11/2011 - 16:29 Comment #9
It's definitely a race condition. The error messages Apache gives during boot are not always the same. Sometimes it fails for one of the two IPv6 IPs, sometimes for both.
My assumption is that the
ifconfig
command which gets launched in the/etc/network/interfaces
file to add the IPs needs some time "in the background" (i.e. after the executable call returns) to actually bring up the addresses. When Apache starts launching before that is complete... bam.I ended up doing something similar as you suggested. I added this in the "iface" section for the IPv6 eth:
post-up sleep 3
Is not really the "stable" method but seems to work. :)
I guess a stable method might be a script that does the "ifconfig add" and then only returns once the IP address is actually available (parse output of "ifconfig eth1" maybe?), and using that script instead of "ifconfig" in the interfaces file.
Submitted by JamieCameron on Mon, 07/11/2011 - 17:12 Comment #10
I would have expected that the ifconfig commands in /etc/network/interfaces wouldn't return until the IP is ready added ..
Could you also post your
/etc/network/interfaces
file? I'd like to see how ifconfig is being called ..Submitted by Locutus on Mon, 07/11/2011 - 17:23 Comment #11
Yep, certainly:
Note that I added that "post-up" command in the last line myself.
I would have expected that the ifconfig commands in /etc/network/interfaces wouldn't return until the IP is ready added ..
Yeah, quite the same here. But it's my only explanation at this time that it doesn't...
Submitted by JamieCameron on Mon, 07/11/2011 - 18:08 Comment #12
I guess if that sleep works, the best fix would be for Virtualmin to add it automatically. I will do this in the next release..
Submitted by Locutus on Mon, 07/11/2011 - 19:07 Comment #13
Yepp.. Sounds good for now. I'll test this some more with reboots and on another machine, and probably write this mentioned script to see if that idea works too.
In any case, thanks for your help, as usual!
Submitted by JamieCameron on Mon, 07/11/2011 - 19:32 Comment #14
Submitted by Issues on Mon, 07/25/2011 - 21:20 Comment #15
Automatically closed -- issue fixed for 2 weeks with no activity.