Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| docs:guide-developer:network-scripting [2021/08/25 21:09] – [Get WAN6 prefix] vgaetera | docs:guide-developer:network-scripting [2023/07/19 09:34] (current) – [Get WAN gateway for unmanaged default route] add vgaetera | ||
|---|---|---|---|
| Line 208: | Line 208: | ||
| ===== Examples ===== | ===== Examples ===== | ||
| [[https:// | [[https:// | ||
| - | Replace automatic WAN detection with explicit interface definition if required. | + | Replace automatic WAN detection with explicit interface definition if necessary. |
| + | |||
| + | ==== Get LAN address ==== | ||
| + | <code bash> | ||
| + | # Runtime configuration | ||
| + | NET_IF=" | ||
| + | . / | ||
| + | network_flush_cache | ||
| + | network_get_ipaddr NET_ADDR " | ||
| + | network_get_ipaddr6 NET_ADDR6 " | ||
| + | echo " | ||
| + | echo " | ||
| + | </ | ||
| + | |||
| + | ==== Get WAN interface ==== | ||
| + | <code bash> | ||
| + | # Runtime configuration | ||
| + | . / | ||
| + | network_flush_cache | ||
| + | network_find_wan NET_IF | ||
| + | network_find_wan6 NET_IF6 | ||
| + | echo " | ||
| + | echo " | ||
| + | </ | ||
| ==== Get WAN L2 device ==== | ==== Get WAN L2 device ==== | ||
| Line 224: | Line 247: | ||
| ==== Get WAN L3 device ==== | ==== Get WAN L3 device ==== | ||
| - | |||
| - | {{section> | ||
| - | |||
| <code bash> | <code bash> | ||
| # Runtime configuration | # Runtime configuration | ||
| Line 239: | Line 259: | ||
| # Persistent configuration | # Persistent configuration | ||
| - | uci get network.wan.ifname | + | uci get network.wan.device |
| - | uci get network.wan6.ifname | + | uci get network.wan6.device |
| </ | </ | ||
| - | ==== Get WAN IP address ==== | + | ==== Get WAN address ==== |
| <code bash> | <code bash> | ||
| # Runtime configuration | # Runtime configuration | ||
| Line 277: | Line 297: | ||
| </ | </ | ||
| - | ==== Get WAN6 prefix ==== | + | ==== Get WAN prefix ==== |
| <code bash> | <code bash> | ||
| # Runtime configuration | # Runtime configuration | ||
| Line 288: | Line 308: | ||
| # Persistent static configuration | # Persistent static configuration | ||
| uci get network.wan6.ip6prefix | uci get network.wan6.ip6prefix | ||
| + | </ | ||
| + | |||
| + | ==== Get WAN gateway for unmanaged default route ==== | ||
| + | <code bash> | ||
| + | # Runtime configuration | ||
| + | ubus call network.interface dump \ | ||
| + | | jsonfilter -e " | ||
| + | [' | ||
| </ | </ | ||