For the record, the fact that Debian's startup tends to fail in the presence of smart switches that try to do spanning-tree detection gets really annoying when you have production machines that depend on NFS servers being available.
Technically, this would be solvable by building a proper hosts file on each server, but that's what DNS is for.
So, I'm going to try a script like this on each server during the startup sequence, to try to delay the startup until the default gateway comes up:
#!/bin/bash -e
found_addr=0
loop_count=0
gw=$(/bin/netstat -rn | awk '/^0.0.0.0/{print $2}')
echo "Gateway is $gw"
echo "Waiting for $gw to appear in the arp table."
while [ $found_addr -eq 0 ]; do
echo "Triggering arp lookup with a single ping"
/bin/ping -c 1 -q $gw >/dev/null || true
info=$(/usr/sbin/arp -n $gw | grep "^$gw")
addr=$(echo "$info" | awk '{print $1}')
hwtype=$(echo "$info" | awk '{print $2}')
echo "hwtype = $hwtype, addr = $addr"
if [ "$hwtype" = "ether" ]; then
found_addr=1
fi
loop_count=$(expr $loop_count + 1)
if [ $loop_count -gt 120 ];
then
echo "120 passes through the loop and nothing happening."
echo "Giving up and moving on."
exit 0
fi
if [ $found_addr -eq 0 ]; then
sleep 1
fi
done
Thursday, April 6, 2006
Subscribe to:
Post Comments (Atom)
3 comments:
We've found that this can be somewhat mitigated (at least on Cisco gear) by setting the variable "spanning-tree-port-fast" (or something like that, I'm not a netadmin) on the switch.
Beware though; if you set that on a trunked switch port you'll wind up with a really bad network (arp? don't remember) storm that'll nuke the whole network. Just use it on end-server ports.
Bill is right, When you are working with switches and are using spanning tree its a good idea to enable port fast on ports that are going to have workstations or servers on them. That way you dont have to sit and wait the whole STP process before the port comes up.
Thanks for the information, it was very helpful.
Post a Comment