routing and defualt gateways

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: JD Austin
Date:  
Subject: routing and defualt gateways
> One one of my Debian systems running kernel 2.4.22 has two nics
> connected to 2 different networks, the problem is that when I have a
> defualt gateway listed for both of the nics in /etc/network/interfaces
> then there is defualt route created automically when the machine
> restarts.
>
> When I enter "ip route", the defualt route looks like "default via
> defualt.gateway.ip dev eth1" and there is one listed for eth0.
>
> I want all connectivity (maily internet access) to go out of eth1 and
> not try to use eth0.
>
> I could create startup script to delete the defualt route statement for
> eth0 which would seem to fix the problem or I could delete the defualt
> gateway listed in /etc/network/interfaces for eth0 although I do not
> want to break any connectivity on that side of the network.
>
>
> Any suggetions?
>
>
> Jim


Im not sure what you're doing with your two networks, but I have a simular
setup at home where I have 2 network cards, 1 connects to the internet
the other forwards through eth0 using ipchains (you'll need to use ip
tables since you're on a 2.4 kernel.. I need to upgrade.)

I created a script that goes into /etc/init.d/ with a symbolic link to it
from /etc/rc?.d/S70<scriptname>
I've replaced ip's with tags/etc below.
In this case Im running a private dns server (so that the local net can
have names/etc) also.
This isn't the cleanest way to do this but it works just fine :)
------------------------------------
#!/bin/sh
#set the environment
#This could be replaced by source /etc/profile if profile options are set
there.
source /home/<someuser>/.bash_profile
# start/stop networking daemons.
case "$1" in
    start)
        echo "starting local network"
        echo "search <yourdomain>.com" > /etc/resolv.conf
        echo "nameserver <LOCALNS IP>" >> /etc/resolv.conf
        echo "#nameserver <ISP DNS IP1>" >> /etc/resolv.conf
        echo "#nameserver <ISP DNS IP2>" >> /etc/resolv.conf
          ifconfig eth0 <eth0 gateway IP> <eth0 IP>
          ifconfig eth1 <eth1 gateway IP> <eth1 IP>
          route add default gw <eth0 gateway IP> netmask 0.0.0.0
          ipchains -F
          ipchains -P forward DENY
          echo 1 > /proc/sys/net/ipv4/ip_forward
          ipchains -A forward -i eth0 -j MASQ
          /etc/init.d/bind stop
          /etc/init.d/bind start
        echo "done."
        ;;
    stop)
        echo "stopping local net"
        #unset eth1
        ifconfig eth1 0.0.0.0 0.0.0.0
        #flush ipchains rules
        ipchains -F
        #kill pump (dhcp client) if it is running
        pump -k
        #pump -i eth0
        echo "search <yourdomain>.com" > /etc/resolv.conf
        echo "nameserver <ISP DNS IP1>" >> /etc/resolv.conf
        echo "nameserver <ISP DNS IP2>" >> /etc/resolv.conf
        ;;
    reload)
        ;;
    *)
        echo "Usage: /etc/init.d/networking {start|stop}"
        exit 1
        ;;
esac


exit 0

--
JD Austin IV
Cell: 480-231-8312
Twin Geckos Technology Services
http://www.twingeckos.com