diff options
author | Patrick J Volkerding <volkerdi@slackware.com> | 2021-03-01 20:10:44 +0000 |
---|---|---|
committer | Eric Hameleers <alien@slackware.com> | 2021-03-02 08:59:52 +0100 |
commit | 07ac5d43e50cb2039f37b4e9447c4e52789c9fb2 (patch) | |
tree | 9b2ebc687d19203f8b4ebe1ab2a0b6c485454a3b /source/n/network-scripts/scripts/rc.inet1 | |
parent | fa458b65d9d4c5e933622574d999915ecda37a25 (diff) | |
download | current-07ac5d43e50cb2039f37b4e9447c4e52789c9fb2.tar.gz current-07ac5d43e50cb2039f37b4e9447c4e52789c9fb2.tar.xz |
Mon Mar 1 20:10:44 UTC 202120210301201044
a/e2fsprogs-1.46.2-x86_64-1.txz: Upgraded.
a/etc-15.0-x86_64-14.txz: Rebuilt.
/etc/hosts: added IPv6 loopback addresses.
a/hwdata-0.345-noarch-1.txz: Upgraded.
ap/hplip-3.20.6-x86_64-7.txz: Rebuilt.
Fixed desktop file to show category and icon properly.
Thanks to upnort and ArTourter.
d/git-2.30.1-x86_64-3.txz: Rebuilt.
Make sure the bash-completion file is installed in the proper location.
Thanks to Robby Workman.
d/python-setuptools-54.0.0-x86_64-1.txz: Upgraded.
d/vala-0.50.4-x86_64-1.txz: Upgraded.
l/imagemagick-7.0.11_2-x86_64-1.txz: Upgraded.
l/python-pillow-8.1.1-x86_64-1.txz: Upgraded.
n/network-scripts-15.0-noarch-13.txz: Rebuilt.
Well, apparently there was a newer branch of this than the one that was
sitting in my usual pending queue, so here it is. This also includes some
additional documentation on the new features. NOTE: In order to use SLAAC
to configure IPv6, you'll need to have USE_SLAAC[x]="yes" for the interface
in rc.inet1.conf. This is to ensure that nobody is surprised to find their
machine fully exposed to the internet - better safe than sorry.
Thanks to Darren "Tadgy" Austin and Robby Workman.
n/wireless_tools-30.pre9-x86_64-4.txz: Rebuilt.
This package contains some updates to rc.wireless and rc.wireless.conf.
Thanks to Darren "Tadgy" Austin.
xfce/mousepad-0.5.3-x86_64-1.txz: Upgraded.
Diffstat (limited to '')
-rw-r--r-- | source/n/network-scripts/scripts/rc.inet1 | 128 | ||||
-rw-r--r-- | source/n/network-scripts/scripts/rc.inet1.conf | 67 |
2 files changed, 96 insertions, 99 deletions
diff --git a/source/n/network-scripts/scripts/rc.inet1 b/source/n/network-scripts/scripts/rc.inet1 index f63f93ed7..755e7efec 100644 --- a/source/n/network-scripts/scripts/rc.inet1 +++ b/source/n/network-scripts/scripts/rc.inet1 @@ -47,7 +47,7 @@ i=0 while [ $i -lt $MAXNICS ]; do IFNAME[$i]=${IFNAME[$i]:=eth${i}} - i=$(($i+1)) + i=$((i+1)) done debug_log "List of interfaces: ${IFNAME[*]}" @@ -130,7 +130,7 @@ virtif_create() { done } -# Function to destory virtual interfaces +# Function to destroy virtual interfaces virtif_destroy() { # argument is 'i' - the position of this interface in the VIRTIFNAME array. for i in $(seq 0 $((${#VIRTIFNAME[@]} - 1))); do @@ -159,7 +159,7 @@ br_open() { debug_log "/sbin/ip link set dev ${IFNAME[$1]} type bridge $IFOPT" /sbin/ip link set dev ${IFNAME[$1]} type bridge $IFOPT fi - done <<<"${IFOPTS[$i]}|" # The | on the end is required. + done <<<"${IFOPTS[$i]/%|*([[:blank:]])}|" # The | on the end is required. debug_log "/sbin/ip link set dev ${IFNAME[$1]} up" /sbin/ip link set dev ${IFNAME[$1]} up } @@ -206,7 +206,7 @@ bond_create() { debug_log "/sbin/ip link set dev ${IFNAME[$1]} type bond $IFOPT" /sbin/ip link set dev ${IFNAME[$1]} type bond $IFOPT fi - done <<<"${IFOPTS[$1]}|" # The | on the end is required. + done <<<"${IFOPTS[$1]/%|*([[:blank:]])}|" # The | on the end is required. } # Function to destroy a bond. @@ -235,7 +235,7 @@ if_up() { i=0 while [ $i -lt $MAXNICS ]; do [ "${IFNAME[$i]}" = "${1}" ] && break - i=$(($i+1)) + i=$((i+1)) done # If "i" is greater or equal to "MAXNICS" at this point, it means we didn't # find an entry in IFNAME array corresponding to "${1}", which likely means @@ -288,7 +288,7 @@ if_up() { debug_log "/sbin/ip link set dev ${1} type vlan $IFOPT" /sbin/ip link set dev ${1} type vlan $IFOPT fi - done <<<"${IFOPTS[$i]}|" # The | on the end is required. + done <<<"${IFOPTS[$i]/%|*([[:blank:]])}|" # The | on the end is required. elif [ -z "${BONDNICS[$i]}" ] && [ -z "${BRNICS[$i]}" ]; then # Only apply IFOPTS for a physical interface if it's not been handled # by a higher level interface. @@ -297,7 +297,7 @@ if_up() { debug_log "/sbin/ip link set dev ${1} $IFOPT" /sbin/ip link set dev ${1} $IFOPT fi - done <<<"${IFOPTS[$i]}|" # The | on the end is required. + done <<<"${IFOPTS[$i]/%|*([[:blank:]])}|" # The | on the end is required. fi # Set hardware address: if [ -n "${HWADDR[$i]}" ]; then @@ -350,7 +350,6 @@ if_up() { # Note: ARM users should make use of the DHCP_NOIPV4LL[x]="yes" parameter in rc.inet1.conf - this is the correct # way to get the behaviour they seek. [ "${DHCP_NOIPV4LL[$i]}" = "yes" ] && DHCP_OPTIONS+=("-L") - [ -n "${DHCP_IPADDR[$i]}" ] && DHCP_OPTIONS+=("-r" "${DHCP_IPADDR[$i]}") echo "${1}: polling for DHCP server" # 15 seconds should be a reasonable default DHCP timeout. 30 was too much. debug_log "/sbin/dhcpcd -t ${DHCP_TIMEOUT[$i]:-15} ${DHCP_OPTIONS[*]} ${1}" @@ -389,7 +388,7 @@ if_up() { /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 + if ((IF_UP != 1)); then echo "${1}: timed out" info_log "${1}: failed to auto configure after ${SLAAC_TIMEOUT[$i]} seconds" debug_log "/sbin/ip address flush dev ${1}" @@ -398,27 +397,8 @@ if_up() { /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 - info_log "${1}: setting fixed IPv4 address" - if [ -z "${NETMASK[$i]}" ]; then - info_log "${1}: no NETMASK set for primary IP ${IPADDR[$i]} - assuming 24 (aka, 255.255.255.0)" - NETMASK[$i]="24" - fi - debug_log "/sbin/ip -4 address add ${IPADDR[$i]}/${NETMASK[$i]#/} broadcast + dev ${1}" - if /sbin/ip -4 address add ${IPADDR[$i]}/${NETMASK[$i]#/} broadcast + dev ${1} && \ - /sbin/ip link set dev ${1} up; then - IF_UP=1 - else - info_log "${1}: failed to set IP ${IPADDR[$i]}" - debug_log "/sbin/ip address flush dev ${1}" - /sbin/ip address flush dev ${1} - debug_log "/sbin/ip link set dev ${1} down" - /sbin/ip link set dev ${1} down - fi - fi - if [ -e /proc/sys/net/ipv6 ] && [ "${USE_DHCP6[$i]}" != "yes" ] && [ "${USE_SLAAC[$i]}" != "yes" ] && \ - [ -n "${IP6ADDRS[$i]}" ]; then # add fixed v6 IPs - info_log "${1}: setting fixed IPv6 addresses" + if [ -e /proc/sys/net/ipv6 ] && [ -n "${IP6ADDRS[$i]}" ]; then # add v6 IPs + info_log "${1}: setting IPv6 addresses" # 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 @@ -433,8 +413,7 @@ if_up() { PREFIX="64" fi debug_log "/sbin/ip -6 address add $IP/$PREFIX dev ${1}" - if /sbin/ip -6 address add $IP/$PREFIX dev ${1} && \ - /sbin/ip link set dev ${1} up; then + 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 debug_log "${1}: unconditionally accepting IPv6 RA" @@ -443,7 +422,7 @@ if_up() { IF_UP=1 else info_log "${1}: failed to set IP $IP" - if (($IF_UP != 1)); then # a v4 address was configured, don't flush it + if ((IF_UP != 1)); then # a v4 address was configured, don't flush it debug_log "/sbin/ip address flush dev ${1}" /sbin/ip address flush dev ${1} debug_log "/sbin/ip link set dev ${1} down" @@ -455,27 +434,55 @@ if_up() { debug_log "${1}: resetting IPv6 DAD to default" cat /proc/sys/net/ipv6/conf/default/accept_dad >/proc/sys/net/ipv6/conf/${1}/accept_dad fi - if (($IF_UP == 1)); then # only do further config if the interface came up - info_log "${1}: setting fixed IPv4 alias addresses" - # Add extra IPv4 addresses to the interface: - if [ -n "${IPALIASES[$i]}" ]; then - NUM=0 - for IPALIAS in ${IPALIASES[$i]}; do - IP="${IPALIAS%/*}" - NM="${IPALIAS#*/}" - if [ -z "$NM" ] || [ "$IP" == "$NM" ]; then - info_log "${1}: no netmask set for alias IP $IP - assuming 24 (aka, 255.255.255.0)" - NM="24" - fi - debug_log "/sbin/ip -4 address add $IP/$NM broadcast + dev ${1} label ${1}:$NUM" - if /sbin/ip -4 address add $IP/$NM broadcast + dev ${1} label ${1}:$NUM; then - NUM=$(($NUM + 1)) - else - info_log "${1}: failed to add alias IP $IP" - fi - done + if [ -n "${IPADDRS[$i]}" ] || [ -n "${IPADDR[$i]}" ]; then # add v4 IPs + info_log "${1}: setting IPv4 addresses" + # Only use IPADDR if no dynamic configuration was done. + if [ "${USE_DHCP[$i]}" == "yes" ] || [ "${USE_DHCP6[$i]}" == "yes" ] || [ "${USE_SLAAC[$i]}" == "yes" ]; then + V4IPS="${IPADDRS[$i]}" + else + V4IPS="${IPADDRS[$i]} ${IPADDR[$i]}${NETMASK[$i]:+/${NETMASK[$i]}}" fi - # Force an MTU (possibly over-riding that set by DHCP or RA): + for V4IP in $V4IPS; do + IP="${V4IP%/*}" + NM="${V4IP#*/}" + if [ -z "$NM" ] || [ "$IP" == "$NM" ]; then + info_log "${1}: no netmask set for IP $IP - assuming 24 (aka, 255.255.255.0)" + NM="24" + fi + debug_log "/sbin/ip -4 address add $IP/$NM broadcast + dev ${1}" + if /sbin/ip -4 address add $IP/$NM broadcast + dev ${1} && /sbin/ip link set dev ${1} up; then + IF_UP=1 + else + info_log "${1}: failed to set IP $IP" + if ((IF_UP != 1)); then # if at least one address was configured, don't flush the device + debug_log "/sbin/ip address flush dev ${1}" + /sbin/ip address flush dev ${1} + debug_log "/sbin/ip link set dev ${1} down" + /sbin/ip link set dev ${1} down + fi + fi + done + fi + if ((IF_UP == 1)) && [ -n "${IPALIASES[$i]}" ]; then # Only apply IPALIASES onto an up interface + info_log "${1}: setting extra IPv4 addresses" + NUM=0 + for EXTRAIP in ${IPALIASES[$i]}; do + IP="${EXTRAIP%/*}" + NM="${EXTRAIP#*/}" + if [ -z "$NM" ] || [ "$IP" == "$NM" ]; then + info_log "${1}: no netmask set for alias IP $IP - assuming 24 (aka, 255.255.255.0)" + NM="24" + fi + debug_log "/sbin/ip -4 address add $IP/$NM broadcast + dev ${1} label ${1}:$NUM" + if /sbin/ip -4 address add $IP/$NM broadcast + dev ${1} label ${1}:$NUM; then + NUM=$((NUM + 1)) + else + info_log "${1}: failed to add alias IP $IP" + fi + done + fi + if ((IF_UP == 1)); then + # Force an MTU (possibly overriding that set by DHCP or RA): if [ -n "${MTU[$i]}" ]; then info_log "${1}: setting custom MTU" debug_log "/sbin/ip link set dev ${1} mtu ${MTU[$i]}" @@ -506,7 +513,7 @@ if_down() { i=0 while [ $i -lt $MAXNICS ]; do [ "${IFNAME[$i]}" = "${1}" ] && break - i=$(($i+1)) + i=$((i+1)) done if [ $i -ge $MAXNICS ]; then info_log "${1}: skipping - you might need to increase MAXNICS" @@ -518,12 +525,12 @@ if_down() { info_log "${1}: stopping dhcpcd" # When using -k, dhcpcd requires some command line options to match those used to invoke it: if [ "${USE_DHCP[$i]}" = "yes" ] && [ "${USE_DHCP6[$i]}" != "yes" ]; then # only v4 dhcp - DHCP_OPTIONS="-4" + DHCP_OPTIONS=( -4 ) elif [ "${USE_DHCP[$i]}" != "yes" ] && [ "${USE_DHCP6[$i]}" = "yes" ]; then # only v6 dhcp - DHCP_OPTIONS="-6" + DHCP_OPTIONS=( -6 ) fi - debug_log "/sbin/dhcpcd $DHCP_OPTIONS -k -d ${1}" - /sbin/dhcpcd $DHCP_OPTIONS -k -d ${1} 2>/dev/null || info_log "${1}: failed to stop dhcpcd" + debug_log "/sbin/dhcpcd ${DHCP_OPTIONS[*]} -k -d ${1}" + /sbin/dhcpcd "${DHCP_OPTIONS[*]}" -k -d ${1} 2>/dev/null || info_log "${1}: failed to stop dhcpcd" fi # Disable v6 IP auto configuration and RA before trying to clear the IP from the interface: if [ -e /proc/sys/net/ipv6 ]; then @@ -618,7 +625,7 @@ start() { stop() { echo "Stopping the network interfaces..." gateway_down - for (( i = $MAXNICS - 1; i >= 0; i-- )); do + for (( i = MAXNICS - 1; i >= 0; i-- )); do if_down ${IFNAME[$i]} done virtif_destroy @@ -630,6 +637,9 @@ stop() { ### MAIN ### ############ +# extglob is required for some functionallity. +shopt -s extglob + case "${1}" in start|up) # "start" (or "up") brings up all configured interfaces: start diff --git a/source/n/network-scripts/scripts/rc.inet1.conf b/source/n/network-scripts/scripts/rc.inet1.conf index 5081ee5bb..0daee7017 100644 --- a/source/n/network-scripts/scripts/rc.inet1.conf +++ b/source/n/network-scripts/scripts/rc.inet1.conf @@ -17,49 +17,45 @@ # ============================================================================= -# IPv4 config information for eth0: -IPADDR[0]="" -NETMASK[0]="" -IPALIASES[0]="" +# IPv4 config options for eth0: +IPADDRS[0]="" USE_DHCP[0]="" -DHCP_HOSTNAME[0]="" -# IPv6 config information for eth0: +# IPv6 config options for eth0: IP6ADDRS[0]="" USE_SLAAC[0]="" USE_DHCP6[0]="" +# Generic options for eth0: +DHCP_HOSTNAME[0]="" -# IPv4 config information for eth1: -IPADDR[1]="" -NETMASK[1]="" -IPALIASES[1]="" +# IPv4 config options for eth1: +IPADDRS[1]="" USE_DHCP[1]="" -DHCP_HOSTNAME[1]="" -# IPv6 config information for eth1: +# IPv6 config options for eth1: IP6ADDRS[1]="" USE_SLAAC[1]="" USE_DHCP6[1]="" +# Generic options for eth1: +DHCP_HOSTNAME[1]="" -# IPv4 config information for eth2: -IPADDR[2]="" -NETMASK[2]="" -IPALIASES[2]="" +# IPv4 config options for eth2: +IPADDRS[2]="" USE_DHCP[2]="" -DHCP_HOSTNAME[2]="" -# IPv6 config information for eth2: +# IPv6 config options for eth2: IP6ADDRS[2]="" USE_SLAAC[2]="" USE_DHCP6[2]="" +# Generic options for eth2: +DHCP_HOSTNAME[2]="" -# IPv4 config information for eth3: -IPADDR[3]="" -NETMASK[3]="" -IPALIASES[3]="" +# IPv4 config options for eth3: +IPADDRS[3]="" USE_DHCP[3]="" -DHCP_HOSTNAME[3]="" -# IPv6 config information for eth3: +# IPv6 config options for eth3: IP6ADDRS[3]="" USE_SLAAC[3]="" USE_DHCP6[3]="" +# Generic options for eth3: +DHCP_HOSTNAME[3]="" # IPv4 default gateway IP address: GATEWAY="" @@ -68,7 +64,7 @@ GATEWAY6="" # ============================================================================= -# Example of how to configure a bond (link aggrigation) interface. +# Example of how to configure a bond (link aggregation) interface. # Note the addition of the BONDNICS and BONDMODE parameters. # BONDNICS is a space delimited list of interfaces to add to this bond. The # BONDNICS interfaces will be brought up and configured while bringing up the @@ -107,9 +103,7 @@ GATEWAY6="" # for a standard VLAN to be configured. #IFNAME[0]="eth0.10" #IFOPTS[0]="" -#IPADDR[0]="192.168.10.1" -#NETMASK[0]="24" -#IPALIASES[0]="" +#IPADDRS[0]="192.168.10.1/24" #USE_DHCP[0]="" #DHCP_HOSTNAME[0]="" #IP6ADDRS[0]="" @@ -128,9 +122,7 @@ GATEWAY6="" #IFNAME[0]="br0" #BRNICS[0]="eth0" #IFOPTS[0]="" -#IPADDR[0]="192.168.0.1" -#NETMASK[0]="24" -#IPALIASES[0]="" +#IPADDRS[0]="192.168.0.1/24" #USE_DHCP[0]="" #DHCP_HOSTNAME[0]="" @@ -160,8 +152,7 @@ GATEWAY6="" # Uncomment the lines you need and fill in your data. You may not need all of # these for your wireless network. #IFNAME[4]="wlan0" -#IPADDR[4]="" -#NETMASK[4]="" +#IPADDRS[4]="" #USE_DHCP[4]="yes" #DHCP_HOSTNAME[4]="icculus-wireless" #DHCP_KEEPRESOLV[4]="yes" @@ -188,15 +179,11 @@ GATEWAY6="" # can be found in the ip-link(8) man page in # the approprite section for the interface # type being configured. -#IPALIASES[4]="192.168.5.10/24" # A space delimited list of CIDR formatted IP - # aliases to assign to the interface after it - # has come up. If no /<prefix> is given after - # the IP address, /24 will be used as default. #HWADDR[4]="00:01:23:45:67:89" # Overrule the card's hardware MAC address #MTU[4]="" # The default MTU is 1500, but you might need # 1360 when you use NAT'ed IPSec traffic. #PROMISCUOUS[4]="yes" # Set promiscuous mode on the interface. -#DHCP_TIMEOUT[4]=15 # The default timeout for the DHCP client to +#DHCP_TIMEOUT[4]="15" # The default timeout for the DHCP client to # wait for server resonse is 15 seconds, but # you might want a shorter or longer wait. #DHCP_KEEPRESOLV[4]="yes" # If you don't want /etc/resolv.conf overwritten @@ -215,7 +202,7 @@ GATEWAY6="" # Increase the timeout if required. #USE_RA[4]="yes" # Accept router advertisements even when SLAAC # is disabled on the interface. -#WLAN_ESSID[4]=DARKSTAR # An example of how you can override _any_ +#WLAN_ESSID[4]="DARKSTAR" # An example of how you can override _any_ # parameter defined in rc.wireless.conf, by # prepending 'WLAN_' to the parameter's name. # Useful with multiple wireless interfaces. @@ -229,7 +216,7 @@ GATEWAY6="" #WLAN_WPADRIVER[4]="ndiswrapper"# Tell wpa_supplicant to specifically use the # ndiswrapper driver (if you leave this empty # the 'wext' driver is used by default) -#WLAN_WPAWAIT[4]=30 # In case it takes long for the WPA association +#WLAN_WPAWAIT[4]="30" # In case it takes long for the WPA association # to finish, you can increase the wait time # (defaults to 10 seconds) |