Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
docs:guide-developer:network-scripting [2022/01/31 10:31] – add LAN interface example. @wulfy23 mercygroundabyssdocs:guide-developer:network-scripting [2023/07/19 09:34] (current) – [Get WAN gateway for unmanaged default route] add vgaetera
Line 210: Line 210:
 Replace automatic WAN detection with explicit interface definition if necessary. Replace automatic WAN detection with explicit interface definition if necessary.
  
-==== Get LAN interface ====+==== Get LAN address ====
 <code bash> <code bash>
 +# Runtime configuration
 +NET_IF="lan"
 . /lib/functions/network.sh . /lib/functions/network.sh
 network_flush_cache network_flush_cache
-network_get_ipaddr addr  "lan+network_get_ipaddr NET_ADDR "${NET_IF}
-network_get_ipaddrs6 addrs6 "lan+network_get_ipaddr6 NET_ADDR6 "${NET_IF}
-echo "ipv4:$addr+echo "${NET_ADDR}
-echo "ipv6:$addrs6"+echo "${NET_ADDR6}"
 </code> </code>
  
 ==== Get WAN interface ==== ==== Get WAN interface ====
 <code bash> <code bash>
 +# Runtime configuration
 . /lib/functions/network.sh . /lib/functions/network.sh
 network_flush_cache network_flush_cache
Line 305: Line 308:
 # Persistent static configuration # Persistent static configuration
 uci get network.wan6.ip6prefix uci get network.wan6.ip6prefix
 +</code>
 +
 +==== Get WAN gateway for unmanaged default route ====
 +<code bash>
 +# Runtime configuration
 +ubus call network.interface dump \
 +| jsonfilter -e "$['interface'][*]['inactive']
 +['route'][*]['target'='0.0.0.0','mask'='0','nexthop']"
 </code> </code>
  
  • Last modified: 2022/01/31 10:31
  • by mercygroundabyss