Add FreeBSD ifconfig support

This commit is contained in:
DotIN13 authored and GitHub committed 2021-11-28 12:53:19 +08:00
1 parent 2c1c547782
commit 3e4451a156
1 file changed
+2 -2
+2 -2
View File
@@ -36,7 +36,7 @@ arWanIp4() {
'Linux')
hostIp=$(ip -o -4 addr list | grep -Ev '\s(docker|lo)' | awk '{print $4}' | cut -d/ -f1 | grep -Ev "$lanIps")
;;
'Darwin')
Darwin|FreeBSD)
hostIp=$(ifconfig | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}' | grep -Ev "$lanIps")
;;
esac
@@ -75,7 +75,7 @@ arWanIp6() {
'Linux')
hostIp=$(ip -o -6 addr list | grep -Ev '\s(docker|lo)' | awk '{print $4,substr($NF,0,length($NF)-3)}' | sed 's/fore/2592000/g' | sort -k 2 -n | cut -d/ -f1 | grep -Ev "$lanIps" | head -n 1)
;;
'Darwin')
Darwin|FreeBSD)
hostIp=$(ifconfig | grep "inet6 " | awk '{print $2}' | grep -Ev "$lanIps" | head -n 1)
;;
esac