summaryrefslogtreecommitdiffstats
path: root/rc.inet1
diff options
context:
space:
mode:
Diffstat (limited to 'rc.inet1')
-rw-r--r--rc.inet135
1 files changed, 25 insertions, 10 deletions
diff --git a/rc.inet1 b/rc.inet1
index 7d37608..07c3f77 100644
--- a/rc.inet1
+++ b/rc.inet1
@@ -212,16 +212,34 @@ if_up() {
done
fi
fi
- elif [ -n "${IPADDR[$i]}" ] || [ -n "${IPADDR6[$i]}" ]; then # use a fixed IP to bring interface up
+ elif [ -n "${IPADDR[$i]}" ] || [ -n "${IPADDR6[$i]}" ]; then # Use a fixed IP to bring interface up
# Disable v6 IP auto configuration.
echo "0" >/proc/sys/net/ipv6/conf/$1/autoconf
- if [ -n "${IPADDR[$i]}" ]; then # skip unconfigured interfaces
- # Set up the network card:
- echo "/etc/rc.d/rc.inet1: /sbin/ip address add ${IPADDR[$i]}/${NETMASK[$i]} broadcast + dev ${1}" | $LOGGER
- /sbin/ip address add ${IPADDR[$i]}/${NETMASK[$i]} broadcast + dev ${1}
- if /sbin/ip link show dev ${1} | grep -wq "state DOWN" ; then
- /sbin/ip link set dev ${1} up # Bring up interface
+ if [ -n "${IPADDR[$i]}" ]; then # Configure interface with a v4 IP
+ if [ -z "${NETMASK[$i]}"; then
+ echo "/etc/rc.d/rc.inet1: no NETMASK set for ${1} - assuming a /24 (aka, 255.255.255.0)"
+ NETMASK[$i]="24"
fi
+ echo "/etc/rc.d/rc.inet1: /sbin/ip -4 address add ${IPADDR[$i]}/${NETMASK[$i]} broadcast + dev ${1}" | $LOGGER
+ /sbin/ip -4 address add ${IPADDR[$i]}/${NETMASK[$i]} broadcast + dev ${1}
+ if [ "$?" != "0" ]; then
+ echo "/etc/rc.d/rc.inet1: failed to a set IP ${IPADDR[$i]} for ${1}"
+ return
+ fi
+ fi
+ if [ -n "${IPADDR6[$i]}" ]; then # Configure interface with a v6 IP
+ if [ -z "${NETMASK6[$i]}"; then
+ echo "/etc/rc.d/rc.inet1: no NETMASK6 set for ${1} - assuming a /64"
+ NETMASK[$i]="64"
+ fi
+ echo "/etc/rc.d/rc.inet1: /sbin/ip -6 address add ${IPADDR6[$i]}/${NETMASK6[$i]} dev ${1}" | $LOGGER
+ /sbin/ip -6 address add ${IPADDR6[$i]}/${NETMASK6[$i]} dev ${1}
+ if [ "$?" != "0" ]; then
+ echo "/etc/rc.d/rc.inet1: failed to a set IP ${IPADDR6[$i]} for ${1}"
+ return
+ fi
+ fi
+ /sbin/ip link set dev ${1} up # Bring up interface
# Add extra IP addresses, if defined, to interface
if [ -n "${IPALIASES[$i]}" ]; then
num=0
@@ -233,9 +251,6 @@ if_up() {
num=$(($num + 1))
done
fi
- else
- debug_log "${1} interface is not configured in /etc/rc.d/rc.inet1.conf"
- fi
elif [ "${USE_STATELESS[$i]}" = "yes" ]; then # interface should configure itself via stateless RA auto config
echo "/etc/rc.d/rc.inet1: using stateless Router Advertisement auto configuration for ${1}" | $LOGGER
echo "1" >/proc/sys/net/ipv6/conf/$1/accept_ra