diff options
author | Darren 'Tadgy' Austin <darren@afterdark.org.uk> | 2018-07-31 09:09:28 +0100 |
---|---|---|
committer | Robby Workman <rworkman@slackware.com> | 2018-11-25 19:46:15 -0600 |
commit | 9b399a97a062d2404ec8108bf8e4c09fd57a1600 (patch) | |
tree | 7599994c176ee399cacfa6fb15f1d1d66501094a | |
parent | a8e6cd3e191ff46cef2525e914a5a64c135d5f84 (diff) | |
download | slacknetsetup-9b399a97a062d2404ec8108bf8e4c09fd57a1600.tar.xz |
Only add IPALIASES{,6} if the interface came up
Signed-off-by: Robby Workman <rworkman@slackware.com>
-rw-r--r-- | rc.inet1 | 44 |
1 files changed, 23 insertions, 21 deletions
@@ -250,27 +250,29 @@ if_up() { debug_log "${1} interface is not configured in /etc/rc.d/rc.inet1.conf" return fi - # Add extra IPv4 and v6 addresses, if defined, to the interface: - if [ -n "${IPALIASES[$i]}" ]; then - num=0 - for ipalias in ${IPALIASES[$i]}; do - ip="${ipalias%/*}" - nm="${ipalias#*/}" - [ -z "$nm" ] || [ "$ip" == "$nm" ] && nm="24" - echo "/etc/rc.d/rc.inet1: /sbin/ip -4 address add ${ip}/${nm} dev ${1} label ${1}:${num}" | $LOGGER - /sbin/ip -4 address add ${ip}/${nm} dev ${1} label ${1}:${num} - num=$(($num + 1)) - done - fi - if [ -n "${IPALIASES6[$i]}" ]; then - for ipalias in ${IPALIASES6[$i]}; do - ip="${ipalias%/*}" - nm="${ipalias#*/}" - [ -z "$nm" ] || [ "$ip" == "$nm" ] && nm="64" - # Unluke IPv4, v6 addresses don't get a label: - echo "/etc/rc.d/rc.inet1: /sbin/ip -6 address add ${ip}/${nm} dev ${1}" | $LOGGER - /sbin/ip -6 address add ${ip}/${nm} dev ${1} - done + # Add extra IPv4 and v6 addresses, if defined, to the interface only if it came up: + if (($IF_UP == 1)); then + if [ -n "${IPALIASES[$i]}" ]; then + num=0 + for ipalias in ${IPALIASES[$i]}; do + ip="${ipalias%/*}" + nm="${ipalias#*/}" + [ -z "$nm" ] || [ "$ip" == "$nm" ] && nm="24" + echo "/etc/rc.d/rc.inet1: /sbin/ip -4 address add ${ip}/${nm} dev ${1} label ${1}:${num}" | $LOGGER + /sbin/ip -4 address add ${ip}/${nm} dev ${1} label ${1}:${num} + num=$(($num + 1)) + done + fi + if [ -n "${IPALIASES6[$i]}" ]; then + for ipalias in ${IPALIASES6[$i]}; do + ip="${ipalias%/*}" + nm="${ipalias#*/}" + [ -z "$nm" ] || [ "$ip" == "$nm" ] && nm="64" + # Unlike IPv4, v6 addresses don't get a label: + echo "/etc/rc.d/rc.inet1: /sbin/ip -6 address add ${ip}/${nm} dev ${1}" | $LOGGER + /sbin/ip -6 address add ${ip}/${nm} dev ${1} + done + fi fi # Force an MTU (possibly over-riding that set by DHCP): if [ -n "${MTU[$i]}" ]; then |