ip forward

Adel ESSAFI adelessafi at gmail.com
Fri Dec 18 14:11:15 UTC 2009


2009/12/18 Tom H <tomh0665 at gmail.com>

> >> Make a new network script
> >> Cat /etc/sysconfig/network-scripts/ifcfg-eth0:0
> >> DEVICE=eth0:0
> >> BOOTPROTO=none
> >> BROADCAST=199.23.200.255
> >> HWADDR=00:11:43:37:06:D5
> >> IPADDR=199.23.200.90
> >> NETMASK=255.255.255.0
> >> NETWORK=199.23.200.0
> >> ONBOOT=yes
> >> TYPE=Ethernet
>
> > I still do not succeed to have the needed result.
>
> Please post the ifcfg-... and route-... files that you have in
> /etc/sysconfig/network-scripts/.
>
> --
> redhat-sysadmin-list mailing list
> redhat-sysadmin-list at redhat.com
> https://www.redhat.com/mailman/listinfo/redhat-sysadmin-list
>



[adel at localhost network-scripts]$ cat ifcfg-eth*
# Broadcom Corporation NetXtreme BCM5755M Gigabit Ethernet PCI Express
DEVICE=eth0
HWADDR=00:18:8b:db:7e:9e
BOOTPROTO=none
TYPE=Ethernet
ONBOOT=yes
USERCTL=no
IPV6INIT=no
NM_CONTROLLED=no
PEERDNS=no
NETMASK=255.255.255.0
IPADDR=192.168.1.100
GATEWAY=192.168.1.1
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.

DEVICE=eth0:0

BOOTPROTO=none

BROADCAST=192.168.10.255

HWADDR=00:18:8b:db:7e:9e

IPADDR=192.168.10.10

NETMASK=255.255.255.0

NETWORK=192.168.10.0

ONBOOT=yes

TYPE=Ethernet

[adel at localhost network-scripts]$ cat  *route*
#! /bin/bash
#
# Drops static routes which go through device $1
if [ -z "$1" ]; then
    echo $"usage: ifup-routes <net-device> [<nickname>]"
    exit 1
fi

# The routes are actually dropped just by setting the link down, so nothing
# needs to be done

MATCH='^[[:space:]]*(\#.*)?$'

# Routing rules
FILES="/etc/sysconfig/network-scripts/rule-$1"
if [ -n "$2" -a "$2" != "$1" ]; then
    FILES="$FILES /etc/sysconfig/network-scripts/rule-$2"
fi

for file in $FILES; do
   if [ -f "$file" ]; then
       { cat "$file" ; echo ; } | while read line; do
       if [[ ! "$line" =~ $MATCH ]]; then
           /sbin/ip rule del $line
       fi
       done
   fi
done
#! /bin/bash
#
# adds static routes which go through device $1
if [ -z "$1" ]; then
    echo $"usage: ifup-routes <net-device> [<nickname>]"
    exit 1
fi

handle_file () {
    . $1
    routenum=0
    while [ "x$(eval echo '$'ADDRESS$routenum)x" != "xx" ]; do
    eval `ipcalc -p $(eval echo '$'ADDRESS$routenum) $(eval echo
'$'NETMASK$routenum)`
    line="$(eval echo '$'ADDRESS$routenum)/$PREFIX"
    if [ "x$(eval echo '$'GATEWAY$routenum)x" != "xx" ]; then
        line="$line via $(eval echo '$'GATEWAY$routenum)"
    fi
    line="$line dev $2"
    /sbin/ip route add $line
    routenum=$(($routenum+1))
    done
}

FILES="/etc/sysconfig/network-scripts/route-$1"
if [ -n "$2" -a "$2" != "$1" ]; then
    FILES="$FILES /etc/sysconfig/network-scripts/route-$2"
fi

MATCH='^[[:space:]]*(\#.*)?$'

for file in $FILES; do
   if [ -f "$file" ]; then
       if egrep -q '^[[:space:]]*ADDRESS[0-9]+=' $file ; then
           # new format
       handle_file $file ${1%:*}
       else
           # older format
           { cat "$file" ; echo ; } | while read line; do
               if [[ ! "$line" =~ $MATCH ]]; then
                   /sbin/ip route add $line
               fi
           done
       fi
   fi
done


# Red Hat network configuration format
NICK=${2:-$1}
CONFIG="/etc/sysconfig/network-scripts/$NICK.route"
[ -f $CONFIG ] && handle_file $CONFIG $1


# Routing rules
FILES="/etc/sysconfig/network-scripts/rule-$1"
if [ -n "$2" -a "$2" != "$1" ]; then
    FILES="$FILES /etc/sysconfig/network-scripts/rule-$2"
fi

for file in $FILES; do
   if [ -f "$file" ]; then
       { cat "$file" ; echo ; } | while read line; do
           if [[ ! "$line" =~ $MATCH ]]; then
           /sbin/ip rule add $line
       fi
       done
   fi
done

-- 
http://ilovefedora.blogspot.com/

-- 

PhD candidate in Computer Science
Address
BP 108, Bureau de poste Tunis republique
1001 Tunis
Tunisia
tel: +216 97 246 706
fax: +216 71 391 166
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/redhat-sysadmin-list/attachments/20091218/980e4b78/attachment.htm>


More information about the redhat-sysadmin-list mailing list