]>
Commit | Line | Data |
---|---|---|
12de71be | 1 | #!/bin/sh |
b0443108 | 2 | # |
b0443108 | 3 | # |
625871bd ER |
4 | # Adds static routes which go through device $DEVICE |
5 | # Called from ifup-post. | |
7742e157 | 6 | |
fa68650b | 7 | if [ ! -f /etc/sysconfig/static-routes -a ! -f /etc/sysconfig/static-routes6 ]; then |
b8c0e37b | 8 | return |
7742e157 | 9 | fi |
a9d7fb92 | 10 | |
11 | # note the trailing white space character in the grep gets rid of aliases | |
a51d5138 | 12 | grep -E "^($DEVICE|any)[[:blank:]]" /etc/sysconfig/static-routes | while read device args; do |
46db3d10 | 13 | if [[ "$args" = *:* ]]; then |
5e6dfc29 JR |
14 | if is_no "$IPV6_NETWORKING"; then |
15 | continue | |
16 | fi | |
17 | else | |
18 | if is_no "$IPV4_NETWORKING"; then | |
19 | continue | |
20 | fi | |
74a7f2e4 | 21 | fi |
5e6dfc29 | 22 | /sbin/ip route add $args dev $REALDEVICE |
12de71be | 23 | done |
f3df266c | 24 | |
fa68650b JR |
25 | if ! is_no "$IPV6_NETWORKING"; then |
26 | grep -E "^($DEVICE|any)[[:blank:]]" /etc/sysconfig/static-routes6 | while read device args; do | |
27 | /sbin/ip -6 route add $args dev $REALDEVICE | |
28 | done | |
29 | fi | |
f3df266c JK |
30 | |
31 | # based on information from http://avahi.org/wiki/AvahiAutoipd#Routes | |
32 | if is_yes "$ZEROCONF" && ! /sbin/ip link show dev $REALDEVICE | grep -q POINTOPOINT ; then | |
33 | # metric based on device ifindex, so the same route may be added to | |
34 | # multiple devices. Big, so it won't conflict with anything else. | |
35 | if [ -f /sys/class/net/$REALDEVICE/ifindex ] ; then | |
36 | metric="$(cat /sys/class/net/$REALDEVICE/ifindex)" | |
37 | metric=$(($metric + 1000)) | |
38 | else | |
39 | metric=1000 | |
40 | fi | |
41 | ||
42 | # default route in default table, so it won't override default | |
43 | # route set by other means | |
44 | /sbin/ip route add default metric $metric dev $REALDEVICE table default | |
45 | ||
46 | # add 169.254.0.0/16 route if not already present on the device | |
47 | current=$(/sbin/ip route show 169.254.0.0/16 dev $REALDEVICE) | |
48 | if [ -z "$current" ] ; then | |
49 | /sbin/ip route add 169.254.0.0/16 metric $metric dev $REALDEVICE | |
50 | fi | |
51 | ||
52 | unset metric | |
53 | unset current | |
54 | fi |