summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarren 'Tadgy' Austin <darren@afterdark.org.uk>2019-11-05 23:28:16 +0000
committerRobby Workman <rworkman@slackware.com>2019-11-06 19:52:24 -0600
commit031f41b62e9761276b2964840c22d6c6666f83be (patch)
tree7a69fbac1d628e132429e827f3536d298d123708
parent1d676fa5d040e268869927de2f0293d7820a3b0f (diff)
downloadslacknetsetup-031f41b62e9761276b2964840c22d6c6666f83be.tar.xz
New configuration methodology - see full commit log.
It occurred to me that IPv6 addresses don't really need to have IP6ALIASES since all IPs are just added to the interface itself. So I've changed the syntax from using IP6ADDR + PREFIXLEN + IP6ALIASES to using just a single IP6ADDRS array, which takes a list of IP addresses with a prefix length in a space separated list. eg: IP6ADDRS[0]="a:b:c:d::1/64 1:2:3::1/48" If the prefix length is omitted a /64 length is assumed and a warning emitted.
-rw-r--r--rc.inet140
-rw-r--r--rc.inet1.conf8
2 files changed, 24 insertions, 24 deletions
diff --git a/rc.inet1 b/rc.inet1
index 9a6fd61..ae9280b 100644
--- a/rc.inet1
+++ b/rc.inet1
@@ -281,31 +281,35 @@ if_up() {
fi
fi
if [ -e /proc/sys/net/ipv6 ] && [ "${USE_DHCP6[$i]}" != "yes" ] && [ "${USE_SLAAC[$i]}" != "yes" ] && \
- [ -n "${IP6ADDR[$i]}" ]; then # add a fixed v6 IP
+ [ -n "${IP6ADDRS[$i]}" ]; then # add fixed v6 IPs
# IPv6's Duplicate Address Detection (DAD) causes a race condition when bringing up interfaces, as
# described here: https://www.agwa.name/blog/post/beware_the_ipv6_dad_race_condition
# Disable DAD while bringing up the interface - but note that this means the loss of detection of a
# duplicate address. It's a trade off, unfortunately.
echo "0" >/proc/sys/net/ipv6/conf/$1/accept_dad
- if [ -z "${PREFIXLEN[$i]}" ]; then
- echo "/etc/rc.d/rc.inet1: no PREFIXLEN set for ${1} - assuming 64" | $LOGGER
- PREFIXLEN[$i]="64"
- fi
- echo "/etc/rc.d/rc.inet1: /sbin/ip -6 address add ${IP6ADDR[$i]}/${PREFIXLEN[$i]#/} dev ${1}" | $LOGGER
- if /sbin/ip -6 address add ${IP6ADDR[$i]}/${PREFIXLEN[$i]#/} dev ${1} && \
- /sbin/ip link set dev ${1} up; then
- # Enable accepting of RA packets if explicitly told to.
- if [ "${USE_RA[$i]}" = "yes" ]; then
- echo "1" >/proc/sys/net/ipv6/conf/$1/accept_ra
+ for v6ip in ${IP6ADDRS[$i]}; do
+ ip="${v6ip%/*}"
+ prefix="${v6ip#*/}"
+ if [ -z "$prefix" ] || [ "$ip" == "$prefix" ]; then
+ echo "/etc/rc.d/rc.inet1: no prefix length set for ${ip} - assuming 64" | $LOGGER
+ prefix="64"
fi
- IF_UP=1
- else
- echo "/etc/rc.d/rc.inet1: failed to set IP ${IP6ADDR[$i]} for ${1}" | $LOGGER
- if (($IF_UP != 1)); then # a v4 address was configured, don't flush it
- /sbin/ip address flush dev ${1}
- /sbin/ip link set dev ${1} down
+ echo "/etc/rc.d/rc.inet1: /sbin/ip -6 address add ${ip}/${prefix} dev ${1}" | $LOGGER
+ if /sbin/ip -6 address add ${ip}/${prefix} dev ${1} && \
+ /sbin/ip link set dev ${1} up; then
+ # Enable accepting of RA packets if explicitly told to.
+ if [ "${USE_RA[$i]}" = "yes" ]; then
+ echo "1" >/proc/sys/net/ipv6/conf/$1/accept_ra
+ fi
+ IF_UP=1
+ else
+ echo "/etc/rc.d/rc.inet1: failed to set IP ${ip} for ${1}" | $LOGGER
+ if (($IF_UP != 1)); then # a v4 address was configured, don't flush it
+ /sbin/ip address flush dev ${1}
+ /sbin/ip link set dev ${1} down
+ fi
fi
- fi
+ done
fi
if (($IF_UP == 1)); then # only do further config if the interface came up
# Add extra IPv4 and v6 addresses to the interface:
diff --git a/rc.inet1.conf b/rc.inet1.conf
index 2e2a0be..73ced0f 100644
--- a/rc.inet1.conf
+++ b/rc.inet1.conf
@@ -51,16 +51,12 @@ GATEWAY=""
# =============================================================================
# IPv6 config information for eth0:
-IP6ADDR[0]=""
-PREFIXLEN[0]=""
-IP6ALIASES[0]=""
+IP6ADDRS[0]=""
USE_SLAAC[0]=""
USE_DHCP6[0]=""
# IPv6 config information for eth1:
-IP6ADDR[1]=""
-PREFIXLEN[1]=""
-IP6ALIASES[1]=""
+IP6ADDRS[1]=""
USE_SLAAC[1]=""
USE_DHCP6[1]=""