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/03/10 16:03] – [Get WAN L2 device] add vgaetera | docs:guide-developer:network-scripting [2023/07/19 09:34] (current) – [Get WAN gateway for unmanaged default route] add vgaetera | ||
|---|---|---|---|
| Line 112: | Line 112: | ||
| * There is a pending patch: https:// | * There is a pending patch: https:// | ||
| - | ==== Available | + | ==== Available |
| - | Flags can be added to a proto handler in '' | + | Flags can be added to a proto handler in '' |
| + | The information about all loaded protocols can be obtained by calling //ubus call network get_proto_handlers// | ||
| ^ Name ^ Name in //ubus call network get_proto_handlers// | ^ Name ^ Name in //ubus call network get_proto_handlers// | ||
| Line 124: | Line 125: | ||
| | no_proto_task | no_task | <color # | | no_proto_task | no_task | <color # | ||
| - | ==== Error Codes ==== | + | ==== Error codes ==== |
| - | If errors for interfaces occur, the json object in //ifstatus interfacename// | + | If errors for interfaces occur, the json object in //ifstatus interfacename// |
| + | If there are no errors, this attribute is not existing. | ||
| ^ CODE ^ Meaning ^ | ^ CODE ^ Meaning ^ | ||
| Line 182: | Line 184: | ||
| * '' | * '' | ||
| - | It seems to avoid race conditions in protos. We can register the following type of dependencies by calling: | + | It seems to avoid race conditions in protos. |
| + | We can register the following type of dependencies by calling: | ||
| * '' | * '' | ||
| * '' | * '' | ||
| Line 205: | 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 214: | Line 240: | ||
| network_find_wan NET_IF | network_find_wan NET_IF | ||
| network_find_wan6 NET_IF6 | network_find_wan6 NET_IF6 | ||
| - | network_get_physdev | + | network_get_physdev |
| - | network_get_physdev | + | network_get_physdev |
| - | echo "${NET_PDEV}" | + | echo "${NET_L2D}" |
| - | echo "${NET_PDEV6}" | + | echo "${NET_L2D6}" |
| </ | </ | ||
| Line 227: | Line 253: | ||
| network_find_wan NET_IF | network_find_wan NET_IF | ||
| network_find_wan6 NET_IF6 | network_find_wan6 NET_IF6 | ||
| - | network_get_device | + | network_get_device |
| - | network_get_device | + | network_get_device |
| - | echo "${NET_DEV}" | + | echo "${NET_L3D}" |
| - | echo "${NET_DEV6}" | + | echo "${NET_L3D6}" |
| # 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 269: | Line 295: | ||
| uci get network.wan.gateway | uci get network.wan.gateway | ||
| uci get network.wan6.ip6gw | uci get network.wan6.ip6gw | ||
| + | </ | ||
| + | |||
| + | ==== Get WAN prefix ==== | ||
| + | <code bash> | ||
| + | # Runtime configuration | ||
| + | . / | ||
| + | network_flush_cache | ||
| + | network_find_wan6 NET_IF6 | ||
| + | network_get_prefix6 NET_PFX6 " | ||
| + | echo " | ||
| + | |||
| + | # Persistent static configuration | ||
| + | uci get network.wan6.ip6prefix | ||
| + | </ | ||
| + | |||
| + | ==== Get WAN gateway for unmanaged default route ==== | ||
| + | <code bash> | ||
| + | # Runtime configuration | ||
| + | ubus call network.interface dump \ | ||
| + | | jsonfilter -e " | ||
| + | [' | ||
| </ | </ | ||