summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarren 'Tadgy' Austin <darren@afterdark.org.uk>2018-07-28 03:52:59 +0100
committerRobby Workman <rworkman@slackware.com>2018-11-25 19:09:59 -0600
commitb31ef834247afa5abfcfd56cf214d55bc3fff048 (patch)
treeafb844d9edca62996ea2fb643e9a9cb1b2b3dbb6
parent051271becdf912c7fd96f6f8b0e71627cd4dd1a2 (diff)
downloadslacknetsetup-b31ef834247afa5abfcfd56cf214d55bc3fff048.tar.xz
Add fixed IP configuration block
Signed-off-by: Robby Workman <rworkman@slackware.com>
-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