diff options
author | Darren 'Tadgy' Austin <darren@afterdark.org.uk> | 2018-08-11 19:29:45 +0100 |
---|---|---|
committer | Robby Workman <rworkman@slackware.com> | 2018-11-25 19:54:31 -0600 |
commit | 0d0d986cf498b6c07b18fc4e9aa53e175a16b169 (patch) | |
tree | 71cb386c629a0b034aeb725438ab0b03d10f0723 | |
parent | f68ac2636c9129984600257b059d38018877244f (diff) | |
download | slacknetsetup-0d0d986cf498b6c07b18fc4e9aa53e175a16b169.tar.xz |
Move AUTOCONF6 block to favour dynamic configuration over fixed IP
This is more in line with Slackware tradition
Signed-off-by: Robby Workman <rworkman@slackware.com>
-rw-r--r-- | rc.inet1 | 48 |
1 files changed, 23 insertions, 25 deletions
@@ -174,7 +174,7 @@ if_up() { # Disable Router Advertisment for this interface until it's needed: echo "0" >/proc/sys/net/ipv6/conf/$1/accept_ra IF_UP=0 - # Slackware historically favours DHCP over fixed IP to configure interfaces, so keep that tradition: + # Slackware historically favours dynamic configuration over fixed IP to configure interfaces, so keep that tradition: if [ "${USE_DHCP[$i]}" = "yes" ] || [ "${USE_DHCP6[$i]}" = "yes" ]; then # use dhcpcd to bring interface up # Declare DHCP_OPTIONS array before adding new options to it: declare -a DHCP_OPTIONS=() @@ -202,9 +202,28 @@ if_up() { /sbin/ip link set dev ${1} down fi fi + if [ "${USE_DHCP6[$i]}" != "yes" ] && [ "${USE_AUTOCONF6[$i]}" = "yes" ]; then # configure interface via stateless auto config + echo "/etc/rc.d/rc.inet1: using Router Advertisement stateless auto configuration for ${1}" | $LOGGER + # Enable accepting of router advertisment packets, and auto configuration of interfaces: + echo "1" >/proc/sys/net/ipv6/conf/$1/accept_ra + echo "1" >/proc/sys/net/ipv6/conf/$1/autoconf + # Bring the interface up: + /sbin/ip link set dev ${1} up + echo "Waiting for router announcement on ${1}..." + for ((j = 30; j--;)); do # wait a max of 15 seconds for the interface to configure + /sbin/ip -6 address show dynamic dev ${1} 2>/dev/null | grep -Ewq 'inet6' && { IF_UP=1; break; } + sleep 0.5 + done + if (($IF_UP != 1)); then + echo "Timed out!" + echo "/etc/rc.d/rc.inet1: failed to auto configure ${1} after 15 seconds" | $LOGGER + /sbin/ip address flush dev ${1} + /sbin/ip link set dev ${1} down + fi + fi if [ "${USE_DHCP[$i]}" != "yes" ] && [ -n "${IPADDR[$i]}" ]; then # add a fixed v4 IP to the interface if [ -z "${NETMASK[$i]}" ]; then - echo "/etc/rc.d/rc.inet1: no NETMASK set for ${1} - assuming /24 (aka, 255.255.255.0)" | $LOGGER + echo "/etc/rc.d/rc.inet1: no NETMASK set for ${1} - assuming 24 (aka, 255.255.255.0)" | $LOGGER NETMASK[$i]="24" fi echo "/etc/rc.d/rc.inet1: /sbin/ip -4 address add ${IPADDR[$i]}/${NETMASK[$i]#/} broadcast + dev ${1}" | $LOGGER @@ -217,9 +236,9 @@ if_up() { /sbin/ip link set dev ${1} down fi fi - if [ "${USE_DHCP6[$i]}" != "yes" ] && [ -n "${IPADDR6[$i]}" ]; then # add a fixed v6 IP to the interface + if [ "${USE_DHCP6[$i]}" != "yes" ] && [ "${USE_AUTOCONF6[$i]}" != "yes" ] && [ -n "${IPADDR6[$i]}" ]; then # add a fixed v6 IP if [ -z "${PREFIX6[$i]}" ]; then - echo "/etc/rc.d/rc.inet1: no PREFIX6 set for ${1} - assuming /64" | $LOGGER + echo "/etc/rc.d/rc.inet1: no PREFIX6 set for ${1} - assuming 64" | $LOGGER PREFIX6[$i]="64" fi echo "/etc/rc.d/rc.inet1: /sbin/ip -6 address add ${IPADDR6[$i]}/${PREFIX6[$i]#/} dev ${1}" | $LOGGER @@ -234,27 +253,6 @@ if_up() { fi fi fi -# FIXME: Remove the ipaddr6 test? - if [ "${USE_DHCP6[$i]}" != "yes" ] && [ -z "${IPADDR6[$i]}" ] && \ - [ "${USE_AUTOCONF6[$i]}" = "yes" ]; then # interface should configure itself via stateless auto config - echo "/etc/rc.d/rc.inet1: using Router Advertisement stateless auto configuration for ${1}" | $LOGGER - # Enable accepting of router advertisment packets, and auto configuration of interfaces: - echo "1" >/proc/sys/net/ipv6/conf/$1/accept_ra - echo "1" >/proc/sys/net/ipv6/conf/$1/autoconf - # Bring the interface up: - /sbin/ip link set dev ${1} up - echo "Waiting for router announcement on ${1}..." - for ((j = 30; j--;)); do # wait a max of 15 seconds for the interface to configure - /sbin/ip -6 address show dynamic dev ${1} 2>/dev/null | grep -Ewq 'inet6' && { IF_UP=1; break; } - sleep 0.5 - done - if (($IF_UP != 1)); then - echo "Timed out!" - echo "/etc/rc.d/rc.inet1: failed to auto configure ${1} after 15 seconds" | $LOGGER - /sbin/ip address flush dev ${1} - /sbin/ip link set dev ${1} down - fi - fi if (($IF_UP == 1)); then # only do further config if the interface came up # Add extra IPv4 and v6 addresses to the interface: if [ -n "${IPALIASES[$i]}" ]; then |