[NBLUG/talk] Network/Route config question

Mark Street jet at sonic.net
Fri Feb 13 09:14:00 PST 2004


Check out the ifup script and the network-functions script, see where and how 
the default route is set.

You can add a GATEWAY or GATEWAYDEV variable and these scripts it will set the 
default route for you.  You can set the GATEWAY variable 
in /etc/sysconfig/network or in your definition for the interface 
in /etc/sysconfig/network-scripts/ifcfg-eth0 or whatever you definition is 
named.

examples (you don't need both)
GATEWAY=192.168.1.1
GATEWAYDEV=wlan0
-------------------
from the 'network-functions' script;
add_default_route ()
{
    . /etc/sysconfig/network
    check_default_route && return 0
    find_gateway_dev
    if [ "$GATEWAYDEV" != "" -a -n "${GATEWAY}" -a \
                "${GATEWAY}" != "none" ]; then
        if ! check_device_down $1; then
            if [ "$GATEWAY" = "0.0.0.0" ]; then
                /sbin/ip route add default ${WINDOW:+window $WINDOW} dev 
${GATEWAYDEV}
            else
                /sbin/ip route add default ${WINDOW:+window $WINDOW} via 
${GATEWAY}
            fi
        fi
    elif [ -f /etc/default-route ]; then
        /sbin/ip route add default ${WINDOW:+window $WINDOW} via 
`cat /etc/default-route`
        rm -f /etc/default-route
    fi
}

from 'ifup' script;
 # Set a default route.
    if [ -z "${GATEWAYDEV}" -o "${GATEWAYDEV}" = "${REALDEVICE}" ]; then
        # set up default gateway. replace if one already exists
        if [ -n "${GATEWAY}" -a "`ipcalc --network ${GATEWAY} ${NETMASK} 
2>/dev/null`" = "NETWORK=${NETWORK}" ];
then
            ip route replace default via ${GATEWAY} ${WINDOW:+window $WINDOW} 
${SRC}
        elif [ "${GATEWAYDEV}" = "${DEVICE}" ]; then
            ip route replace default ${SRC} ${WINDOW:+window $WINDOW} dev 
${REALDEVICE}
        fi
    fi

fi




On Friday 13 February 2004 08:44 am, Dave Sisley wrote:
> Hey, everybody:
>
> I've just set up my home computer so that my desktop allows
> masquerading and acts as a gateway for my laptop.  After breaking and
> then reconfiguring my wireless card, the network configuration, etc.,
> etc., I've managed to get it working (including a propoer firewall! [I
> think...]).
>
> For some reason, every time I boot up the laptop, I cannot access
> the internet through my desktop until I have typed the following
> command (with root privileges):
>
> route add default gw jupiter
>
> That adds a line to the output of 'route' that says:
>
> default         jupiter.daveNet 0.0.0.0         UG    0      0        0
> eth0
>
> This line is missing if you run route before running the 'route add... '
> command.
>
> My question is:  In what configuration file does this default info
> belong, so I no longer have to type it in on the command line every
> time I boot?
>
> For the record, I'm running SuSE 8.2 with kernel version 2.4.20-4GB.
>
> Thanks for the help.
>
> -dave.
> _______________________________________________
> talk mailing list
> talk at nblug.org
> http://nblug.org/mailman/listinfo/talk

-- 
Mark Street, D.C.
Red Hat Certified Engineer
Cert# 807302251406074
--
Key fingerprint = 3949 39E4 6317 7C3C 023E  2B1F 6FB3 06E7 D109 56C0
GPG key http://www.streetchiro.com/pubkey.asc



More information about the talk mailing list