Forum Moderators: bakedjake

Message Too Old, No Replies

Setting up default routes

         

martin

4:45 pm on Sep 24, 2003 (gmt 0)

10+ Year Member



Up until recently I didn't really need to mess with routing, it was all happening by itself. I'm running a Debian and I have my interfaces configured in /etc/network/interfaces with a gateway entry which was used before for the default gateway.

For some reason, I think after I added some entries in my hosts file like 10.0.0.1 ad.doubleclick.net and a reject route for the 10.0.0.0 network the default routing configuration stopped working.

I now have to run something like this to get it to work:

net=`route -n ¦ awk '{ print $1; }' ¦ grep -e "^0\.0\.0\.0"`
if [! "$net" ]; then
route add -net 0.0.0.0 gw emo $eth
fi

net=`route -n ¦ awk '{ print $1; }' ¦ grep "192.168.0.0"`
if [! "$net" ]; then
route add -net 192.168.0.0 netmask 255.255.255.0 $eth
fi

net=`route -n ¦ awk '{ print $1; }' ¦ grep "10.0.0.0"`
if [! "$net" ]; then
route add -net 10.0.0.0 netmask 255.0.0.0 reject
fi

net=`route -n ¦ awk '{ print $1; }' ¦ grep "64.94.110.11"`
if [! "$net" ]; then
route add -host 64.94.110.11 reject
fi

The problem is that for some reason the default route isn't set on the first run and I have to run the script twice to get it to work... but anyway that's a kind of a workaround. I was wondering if there's a cleaner way to set up routing, I tried /etc/gateways but it doesn't work.

martin

2:25 pm on Sep 25, 2003 (gmt 0)

10+ Year Member



Actually I found the reason why it fails to set the routes on the first run, if I just move the 0.0.0.0 route last it works from a single run.