Fix IPv6 static address assignment

This commit is contained in:
bergware
2023-11-30 23:59:36 +01:00
parent 8aa102b595
commit 0434cf2700
2 changed files with 5 additions and 5 deletions

View File

@@ -93,7 +93,7 @@ min6(){
wipe(){
WET=($*)
# remove temporary (privacy extensions) and host ipv6 addresses
for TMP in $(ip -br -6 addr show scope global temporary dev $WET 2>/dev/null | sed -r 's/metric [0-9]+//' | awk '{$1=$2="";print}'); do
for TMP in $(ip -br -6 addr show scope global temporary dev $WET 2>/dev/null | sed -r 's/metric [0-9]+//g' | awk '{$1=$2="";print}'); do
for i in ${!WET[@]}; do
[[ ${WET[$i]} == $TMP || (${WET[$i]} =~ '::' && ${WET[$i]#*/} == 128) ]] && unset 'WET[i]'
done
@@ -110,7 +110,7 @@ show(){
case $# in
1) ip -br addr show scope global to $1 2>/dev/null | awk '{print $1;exit}';;
2) ip -br addr show scope global $1 $2 2>/dev/null | awk '{print $3;exit}';;
3) if [[ $1 == -6 ]]; then main $(ip -br -6 addr show scope global $2 $3 2>/dev/null | sed -r 's/metric [0-9]+//' | awk '{$2="";print;exit}'); else ip -br -4 addr show scope global $2 $3 2>/dev/null | awk '{print $3;exit}'; fi;;
3) if [[ $1 == -6 ]]; then main $(ip -br -6 addr show scope global $2 $3 2>/dev/null | sed -r 's/metric [0-9]+//g' | awk '{$2="";print;exit}'); else ip -br -4 addr show scope global $2 $3 2>/dev/null | awk '{print $3;exit}'; fi;;
esac
}
@@ -220,7 +220,7 @@ check(){
else
[[ -z $DENY6 && -n $NET1 && $NET1 != '0' && -z $(good $NET1) ]] && IPV6=yes BIND+=($NET1)
fi
done <<< $(ip -br -6 addr show scope global | sed -r 's/metric [0-9]+//' | awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/{$2="";print}' | sort)
done <<< $(ip -br -6 addr show scope global | sed -r 's/metric [0-9]+//g' | awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/{$2="";print}' | sort)
# add loopback interface
if [[ "smb nfs" =~ "$CALLER" ]]; then
[[ $IPV4 == yes ]] && BIND+=(127.0.0.1)

View File

@@ -241,8 +241,8 @@ if [[ -z $interface || "eth0 br0 bond0" =~ $interface ]]; then
# find management interface
[[ -e /sys/class/net/bond0 ]] && dev=bond0 || dev=eth0
[[ -e /sys/class/net/br0 ]] && dev=br0
IPv4=$(ip -br -4 addr show $dev scope global|sed -r 's/metric [0-9]+//'|awk '{print $3;exit}')
IPv6=$(ip -br -6 addr show $dev scope global|sed -r 's/metric [0-9]+//'|awk '{print $NF;exit}')
IPv4=$(ip -br -4 addr show $dev scope global|sed -r 's/metric [0-9]+//g'|awk '{print $3;exit}')
IPv6=$(ip -br -6 addr show $dev scope global|sed -r 's/metric [0-9]+//g'|awk '{print $NF;exit}')
# show current IP assignment
[[ -n $IPv4 ]] && echo " IPv4 address: ${IPv4%/*}" >>/etc/issue || echo " IPv4 address: not set" >>/etc/issue
[[ -n $IPv6 ]] && echo " IPv6 address: ${IPv6%/*}" >>/etc/issue || echo " IPv6 address: not set" >>/etc/issue