I am running Debian squeeze in a virtual machine (VirtualBox). The machine has two interfaces:
- eth0 in "Host-only" mode so that the machine is accessible from the outside; and
- eth1 in "NAT" mode so that the machine can access the Internet.
Furthermore, I am running dnsmasq on the host machine to assign static IP addresses to the virtual machines (VirtualBox provides IP addresses for NAT).
The virtual machine runs sshd and mysql. At boot time, sometimes both services fail to start:
sshd[1145]: Set /proc/self/oom_adj from 0 to -17
sshd[1145]: Server listening on 0.0.0.0 port 22.
sshd[1145]: Server listening on :: port 22.
sshd[1145]: Received signal 15; terminating.
sshd[1299]: Set /proc/self/oom_adj from -17 to -17
sshd[1299]: Server listening on 0.0.0.0 port 22.
sshd[1299]: Server listening on :: port 22.
sshd[1301]: Set /proc/self/oom_adj from -17 to -17
sshd[1301]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use.
sshd[1301]: error: Bind to port 22 on :: failed: Address already in use.
sshd[1301]: fatal: Cannot bind any address.
And:
mysqld: 121012 10:36:24 [ERROR] Can't start server: Bind on TCP/IP port: Cannot assign requested address
mysqld: 121012 10:36:24 [ERROR] Do you already have another mysqld server running on port: 3306 ?
mysqld: 121012 10:36:24 [ERROR] Aborting
I observed that each time the services fail, DHCPDISCOVER on eth0 comes after the failure. When the services start successfully, DHCPDISCOVER comes before.
I assume that Debian does not wait for both interfaces to have received an IP address. Is there any way to force Debian to wait for DHCP on both interfaces?
Update on request by user warl0ck
Contents of file /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp
# routing for VPN
post-up route add -net x.x.20.0 netmask 255.255.255.0 gw x.x.10.1
pre-down route del -net x.x.20.0 netmask 255.255.255.0 gw x.x.10.1
# 2nd interface for NAT
allow-hotplug eth1
iface eth1 inet dhcp
