Project

General

Profile

Revision 839ddca2

ID839ddca284ba0645e1db6b78e0d0803d7701cbb5
Parent fd806bc1
Child 923d57af, 6a6e1853

Added by Marc Dequènes 6 months ago

Improve multihoming script

- better detect if a link is up
(previous method did not work for PPP links)
- allow to specify sources addresses
(not always directly associated with the link)

View differences:

ansible/roles/dc-base/files/init.d/multihoming
118 118
    # skip if link is down
119 119
    Z=TABLE_${T}_GW_DEV
120 120
    GW_DEV="${!Z}"
121
    if ! ethtool ${GW_DEV} | grep -q "Link detected: yes"; then
121
    if ! ip link show ${GW_DEV} | grep "UP,LOWER_UP"; then
122 122
      continue
123 123
    fi
124 124

  
......
130 130
    done
131 131

  
132 132
    # source routing
133
    SRC_IP4_LIST=$(iface_ip4_list ${GW_DEV})
133
    Z=TABLE_${T}_SUBNET_IP4
134
    SRC_IP4_LIST="${!Z}"
135
    if [ -z "${SRC_IP4_LIST}" ]; then
136
      SRC_IP4_LIST=$(iface_ip4_list ${GW_DEV})
137
    fi
134 138
    for IP in ${SRC_IP4_LIST}; do
135 139
      P=$(free_rule_number)
136 140
      ip rule add from ${IP} prio ${P} table ${T}
137 141
    done
138
    SRC_IP6_LIST=$(iface_ip6_list ${GW_DEV})
142
    Z=TABLE_${T}_SUBNET_IP6
143
    SRC_IP6_LIST="${!Z}"
144
    if [ -z "${SRC_IP6_LIST}" ]; then
145
      SRC_IP6_LIST=$(iface_ip6_list ${GW_DEV})
146
    fi
139 147
    for IP in ${SRC_IP6_LIST}; do
140 148
      P=$(free_rule_number)
141 149
      ip -6 rule add from ${IP} prio ${P} table ${T}

Also available in: Unified diff