igb1: flags=8863<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 description: WAN options=4e0002b<RXCSUM,TXCSUM,VLAN_MTU,JUMBO_MTU,RXCSUM_IPV6,TXCSUM_IPV6,NOMAP> ether ac:1f:6b:83:22:f7 inet6 fe80::ae1f:6bff:fe83:22f7%igb1 prefixlen 64 scopeid 0x2 inet6 2604:5500:30c8:0:ae1f:6bff:fe83:22f7 prefixlen 64 autoconf inet6 2604:5500:30c8::662 prefixlen 128 inet 136.30.119.91 netmask 0xfffffc00 broadcast 136.30.119.255 media: Ethernet autoselect (1000baseT <full-duplex>) status: active nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
em0: flags=8863<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 description: WAN options=481059b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,LRO,VLAN_HWFILTER,NOMAP> ether ab:cd:ef:12:34:56 inet6 fe80::x%em0 prefixlen 64 scopeid 0x1 inet6 2a02:908::x prefixlen 64 autoconf inet6 2a02:3102::x prefixlen 64 detached autoconf inet6 2a02:3102::x prefixlen 64 autoconf inet6 2a02:908::x prefixlen 128 inet 84.119.xxx.xxx netmask 0xfffffc00 broadcast 84.119.171.255 media: Ethernet autoselect (1000baseT <full-duplex>) status: active nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
#!/bin/shINTERFACE=$(ifconfig | grep -B1 'description: WAN' | head -n1 | cut -w -f 1 | tr -d ':,')IPv6=$(ifconfig "${INTERFACE}" | grep inet6 | grep -v autoconf | grep -v "inet6 fe80" | cut -w -f 3)/sbin/ifconfig "${INTERFACE}" inet6 prefer_source "${IPv6}"