]> git.pld-linux.org Git - projects/rc-scripts.git/blob - lib/ifup-routes
drop raidutils (raidstart, /etc/raidtab) support. our geninitrd doesn't support it...
[projects/rc-scripts.git] / lib / ifup-routes
1 #!/bin/sh
2 #
3 #       $Id$
4 #
5 # Adds static routes which go through device $DEVICE
6 # Called from ifup-post.
7
8 if [ ! -f /etc/sysconfig/static-routes -a ! -f /etc/sysconfig/static-routes6 ]; then
9         return
10 fi
11
12 # note the trailing white space character in the grep gets rid of aliases
13 grep -E "^($DEVICE|any)[[:blank:]]" /etc/sysconfig/static-routes | while read device args; do
14         if [[ "$args" = *:* ]]; then
15                 if is_no "$IPV6_NETWORKING"; then
16                         continue
17                 fi
18         else
19                 if is_no "$IPV4_NETWORKING"; then
20                         continue
21                 fi
22         fi
23         /sbin/ip route add $args dev $REALDEVICE
24 done
25
26 if ! is_no "$IPV6_NETWORKING"; then
27         grep -E "^($DEVICE|any)[[:blank:]]" /etc/sysconfig/static-routes6 | while read device args; do
28                 /sbin/ip -6 route add $args dev $REALDEVICE
29         done
30 fi
31
32 # based on information from http://avahi.org/wiki/AvahiAutoipd#Routes
33 if is_yes "$ZEROCONF" && ! /sbin/ip link show dev $REALDEVICE | grep -q POINTOPOINT ; then
34         # metric based on device ifindex, so the same route may be added to
35         # multiple devices. Big, so it won't conflict with anything else.
36         if [ -f /sys/class/net/$REALDEVICE/ifindex ] ; then
37                 metric="$(cat /sys/class/net/$REALDEVICE/ifindex)"
38                 metric=$(($metric + 1000))
39         else
40                 metric=1000
41         fi
42
43         # default route in default table, so it won't override default
44         # route set by other means
45         /sbin/ip route add default metric $metric dev $REALDEVICE table default
46
47         # add 169.254.0.0/16 route if not already present on the device
48         current=$(/sbin/ip route show 169.254.0.0/16 dev $REALDEVICE)
49         if [ -z "$current" ] ; then
50                 /sbin/ip route add 169.254.0.0/16 metric $metric dev $REALDEVICE
51         fi
52
53         unset metric
54         unset current
55 fi
This page took 0.035082 seconds and 3 git commands to generate.