From 55df802f269dc1ef38e9aa860002892d25fc721d Mon Sep 17 00:00:00 2001 From: bin456789 Date: Sun, 3 Sep 2023 20:00:11 +0800 Subject: [PATCH] =?UTF-8?q?core:=20=E4=BF=AE=E5=A4=8D=E6=9C=AA=E4=BC=A0?= =?UTF-8?q?=E9=80=92mac=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- alpine-network.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/alpine-network.sh b/alpine-network.sh index 38f929c..e8ac34d 100644 --- a/alpine-network.sh +++ b/alpine-network.sh @@ -95,10 +95,12 @@ if { $dhcpv4 || $dhcpv6 || $slaac; } && [ ! -e /etc/resolv.conf ]; then fi # 如果ipv4/ipv6不联网,则删除该协议的dns -if $ipv4_has_internet && ! $ipv6_has_internet; then - sed -i '/^[[:blank:]]*nameserver[[:blank:]].*:/d' /etc/resolv.conf -elif ! $ipv4_has_internet && $ipv6_has_internet; then - sed -i '/^[[:blank:]]*nameserver[[:blank:]].*\./d' /etc/resolv.conf +if [ -e /etc/resolv.conf ]; then + if $ipv4_has_internet && ! $ipv6_has_internet; then + sed -i '/^[[:blank:]]*nameserver[[:blank:]].*:/d' /etc/resolv.conf + elif ! $ipv4_has_internet && $ipv6_has_internet; then + sed -i '/^[[:blank:]]*nameserver[[:blank:]].*\./d' /etc/resolv.conf + fi fi # 如果联网了,但没获取到默认 DNS,则添加我们的 DNS @@ -113,6 +115,7 @@ fi # 传参给 trans.start $dhcpv4 && echo 1 >/dev/dhcpv4 || echo 0 >/dev/dhcpv4 +echo $mac_addr >/dev/mac_addr echo $ipv4_addr >/dev/ipv4_addr echo $ipv4_gateway >/dev/ipv4_gateway echo $ipv6_addr >/dev/ipv6_addr