From 17eb5419a3f4f5eb95a48ba9d698735a75640ce4 Mon Sep 17 00:00:00 2001 From: Bard Date: Mon, 8 Apr 2024 06:02:01 +0800 Subject: [PATCH] nat6: silent error output --- files/nat6.init | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/files/nat6.init b/files/nat6.init index fd8042c..ee10d83 100644 --- a/files/nat6.init +++ b/files/nat6.init @@ -14,7 +14,7 @@ interface() { device=$(uci -q show network.$alias_interface.device | grep -o "'.*'" | awk -F"'" '{print $2}') if [ -z $(uci -q show network.$alias_interface.device) ]; then 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 if [ $(ifconfig $device | grep -c "inet6 addr") -gt 0 ]; then @@ -56,6 +56,8 @@ EOF start() { [ "$(uci -q get firewall.@defaults[0].nat6)" != 1 ] && return 0 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 ip -6 r add default via $gateway dev $device 2>/dev/null nft delete table ip6 nat 2>/dev/null