2

Server is a Xen VPS running Ubuntu 12.04 and neither nginx nor NSD3 come up after reboot. The apparent reason for that is that they're not able to bind to their assigned IP addresses right after boot,

from /var/log/boot.log

* Starting configure network device                                     [ OK ]
* Stopping save kernel messages                                         [ OK ]
* Starting MTA                                                          [ OK ] 
nginx: [emerg] bind() to [2a01:1b0:removed:1c9c]:80 failed (99: Cannot assign requested address)
* Starting nsd3...                                                      [ OK ] 
[...]
* Starting configure virtual network devices                            [ OK ]
* Stopping configure virtual network devices                            [ OK ]

from /var/log/nsd.log

[1351715473] nsd[956]: error: can't bind udp socket: Cannot assign requested address
[1351715473] nsd[956]: error: server initialization failed, nsd could not be started

Everything works fine after a couple of seconds, and both nginx and NSD3 can be started.

It seems to me that the problem is in the wrong boot order, nginx and NSD3 are started before the network configuration can fully take place. I worked around it by putting

# nginx and nsd boot fix
sleep 4
/etc/init.d/nsd3 start
/etc/init.d/nginx start

in /etc/rc.local but that's not a proper solution. What is the right way to handle this issue?

Here's my basic network configuration, from /etc/network/interfaces auto eth0

iface eth0 inet static
  address 89.removed.121
  gateway 89.removed.1
  netmask 255.255.255.0

iface eth0 inet6 static
  up echo 0 > /proc/sys/net/ipv6/conf/all/autoconf
  up echo 0 > /proc/sys/net/ipv6/conf/default/autoconf
  netmask 64
  gateway 2a01:removed:0001
  address 2a01:removed:7c3b
  up ip addr add 2a01:removed:62bd dev eth0 preferred_lft 0
  up ip addr add 2a01:removed:ce6d dev eth0 preferred_lft 0
  up ip addr add 2a01:removed:3e13 dev eth0 preferred_lft 0
  up ip addr add 2a01:removed:1c9c dev eth0 preferred_lft 0

auto lo
iface lo inet loopback

Those awkward up id addr are there because I wanted to add additional IPs but still use the first one for all traffic originating from the server.

Damn Terminal
  • 517
  • 3
  • 7

2 Answers2

1

It seems like nsd3 has to start after netwok. adding $network in the Required-Start part of /etc/init.d/nsd3 file should solve the issue.

han
  • 11
  • 1
1

The easiest fix for this is to not have nginx or nsd bind to a specific IP address, but to listen for any address. For instance in nginx:

listen [::]:80;

The less easy fix is to fix your network interfaces script. The way you have it configured now, your IP addresses are routed to you, but they are not actually bound to the interface in a way that programs can explicitly listen on them. (They only receive traffic for them if they bound to any address, as above.) To do that, you need additional iface sections, instead of the ip route commands.

iface eth0 inet6 static
        address 2001:db8::1234
        netmask 64

iface eth0 inet6 static
        address 2001:db8::5678
        netmask 64

iface eth0 inet6 static
        address 2001:db8::abcd
        netmask 64
Michael Hampton
  • 237,123
  • 42
  • 477
  • 940