Saturday, December 21, 2019

ubuntu - Nginx and NSD3 don't start on boot because they cannot use the assigned IP

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.

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...