nat6: silent error output

This commit is contained in:
Bard 2024-04-08 06:02:01 +08:00 committed by GitHub
parent 34672d93ef
commit 17eb5419a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -14,7 +14,7 @@ interface() {
device=$(uci -q show network.$alias_interface.device | grep -o "'.*'" | awk -F"'" '{print $2}') device=$(uci -q show network.$alias_interface.device | grep -o "'.*'" | awk -F"'" '{print $2}')
if [ -z $(uci -q show network.$alias_interface.device) ]; then if [ -z $(uci -q show network.$alias_interface.device) ]; then
ipaddr=$(uci -q show network.$alias_interface.ipaddr | grep -o "'.*'" | awk -F"'" '{print $2}') ipaddr=$(uci -q show network.$alias_interface.ipaddr | grep -o "'.*'" | awk -F"'" '{print $2}')
device=$(ifconfig | grep -B 1 $ipaddr | head -1 | awk '{print $1}') device=$(ifconfig | grep -B 1 $ipaddr 2>/dev/null | head -1 | awk '{print $1}')
fi fi
fi fi
if [ $(ifconfig $device | grep -c "inet6 addr") -gt 0 ]; then if [ $(ifconfig $device | grep -c "inet6 addr") -gt 0 ]; then
@ -56,6 +56,8 @@ EOF
start() { start() {
[ "$(uci -q get firewall.@defaults[0].nat6)" != 1 ] && return 0 [ "$(uci -q get firewall.@defaults[0].nat6)" != 1 ] && return 0
interface interface
[ -z "$device" ] && logger -p error -t network -s "nat6: DHCPv6 interface device not configured, IPv6 NAT failed." && exit 0
[ -z "$gateway" ] && logger -p error -t network -s "nat6: DHCPv6 gateway not found, IPv6 NAT failed." && exit 0
common_config common_config
ip -6 r add default via $gateway dev $device 2>/dev/null ip -6 r add default via $gateway dev $device 2>/dev/null
nft delete table ip6 nat 2>/dev/null nft delete table ip6 nat 2>/dev/null