From 9b399a97a062d2404ec8108bf8e4c09fd57a1600 Mon Sep 17 00:00:00 2001 From: Darren 'Tadgy' Austin Date: Tue, 31 Jul 2018 09:09:28 +0100 Subject: Only add IPALIASES{,6} if the interface came up Signed-off-by: Robby Workman --- rc.inet1 | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/rc.inet1 b/rc.inet1 index e12dfbf..165672c 100644 --- a/rc.inet1 +++ b/rc.inet1 @@ -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 -- cgit v1.2.3