In Mandrake I would restart my network by doing this:
service network restart
So I could write a script and run it from /etc/rc.d/rc.local that would try to ping my GATEWAY and until it got a good ping it would sleep then restart then ping then try again.
That script would look something like this:
Code:
#!/bin/bash
GATEWAY=192.168.0.1
PING="100%"
until [ "$PING" = "0%" ]
do
sleep 30
echo "Trying to start network..."
service network restart
PING=`ping -c1 -w2 $GATEWAY 2>/dev/null|grep pack|awk '{print $6}'`
done
The output of the script looks like this.
Code:
./startnet
Trying to start network...
Shutting down interface eth0: [ COOL ]
Shutting down loopback interface: [ COOL ]
Setting network parameters: [ COOL ]
Bringing up loopback interface: [ COOL ]
Bringing up interface eth0: Can't find a dhcp client
[BUMMER]
Trying to start network...
Shutting down loopback interface: [ COOL ]
Setting network parameters: [ COOL ]
Bringing up loopback interface: [ COOL ]
Bringing up interface eth0: Can't find a dhcp client
[BUMMER]
Trying to start network...
Shutting down loopback interface: [ COOL ]
Setting network parameters: [ COOL ]
Bringing up loopback interface: [ COOL ]
Bringing up interface eth0: [ COOL ]
<edit> Of course you may need to change GATEWAY and the sleep value.
Another thing is you would want to ping the GATEWAY first and only run the script if the network is down, otherwise you have a big long delay in your bootup. I guess that could be done in the script too. Let me see.
Code:
#!/bin/bash
GATEWAY=192.168.0.1
PING=`ping -c1 -w2 $GATEWAY 2>/dev/null|grep pack|awk '{print $6}'`
until [ "$PING" = "0%" ]
do
sleep 30
echo "Trying to start network..."
service network restart
PING=`ping -c1 -w2 $GATEWAY 2>/dev/null|grep pack|awk '{print $6}'`
done
Yes the above works better than the really far above.