Network improvement: better IPv6 handling

This commit is contained in:
bergware
2023-07-04 15:55:16 +02:00
parent 42875c1a68
commit e5b25761ea
4 changed files with 9 additions and 10 deletions
@@ -49,8 +49,8 @@ $include = $include6 = $address = $address6 = $gateway = $gateway6 = $unset = $p
$wide = false;
foreach ($custom as $network) {
if (in_array($network,$slaves)) continue;
$ip4 = exec("ip -4 addr show $network|awk '/inet /{print $2;exit}'");
$ip6 = exec("ip -6 addr show $network scope global|awk '/inet6 /{print $2;exit}'");
$ip4 = exec("ip -br -4 addr show $network scope global|awk '{print $3}'");
$ip6 = exec("ip -br -6 addr show $network scope global|awk '{print $3}'");
$gw4 = $ip4 ? exec("ip -4 route show dev $network default|awk '{print $3;exit}'") : '';
$gw6 = $ip6 ? exec("ip -6 route show dev $network default|awk '{print $3;exit}'") : '';
$route4 = $ip4 ? exec("ip -4 route show dev $network $ip4|awk '{print $1;exit}'") : '';
+4 -4
View File
@@ -20,10 +20,10 @@ $etc = '/etc/wireguard';
$tmp = '/tmp/list.tmp';
unset($subnets,$hosts,$subnets6,$hosts6,$vtuns,$filter,$docker);
exec("ip -4 route show scope link|awk '/^[^d].+ dev (eth|br|bond)[0-9]+/{print \$1}'",$subnets);
exec("ip -4 addr show scope global|awk '/inet .+ (eth|br|bond)[0-9]+/{split(\$2,ip,\"/\");print ip[1]}'",$hosts);
exec("ip -6 route show type unicast|grep -Pv 'expires|shim-'|awk '/^[^dfm:]/{print \$1}'",$subnets6);
exec("ip -6 addr show scope global|grep -PA2 ': (eth|br|bond)\d+'|awk '/inet6 .+ (global|noprefixroute) \$/{split(\$2,ip,\"/\");print ip[1]}'",$hosts6);
exec("ip -4 route show scope link|awk '/^[^d].+ dev (eth|br|bond)[0-9]+(\\.[0-9]+)?/{print \$1}'",$subnets);
exec("ip -6 route show type unicast|awk '\$0 !~ \"expires\" && \$3 !~ \"^shim-\" && /^[^dfm:]/{print \$1}'",$subnets6);
exec("ip -br -4 addr show scope global|awk '/^(br|bond|eth)[0-9]+(\\.[0-9]+)?/{split(\$3,ip,\"/\");print ip[1]}'",$hosts);
exec("ip -br -6 addr show scope global|awk '/^(br|bond|eth)[0-9]+(\\.[0-9]+)?/{split(\$3,ip,\"/\");print ip[1]}'",$hosts6);
exec("ls --indicator-style=none $etc/wg*.conf*|grep -Po wg[0-9]+",$vtuns);
exec("docker network ls --filter driver='macvlan' --filter driver='ipvlan' --format='{{.Name}}' 2>/dev/null",$filter);