Page 1 of 1
Best way to get wan ip on cli/ash script?
Posted: Fri Feb 28, 2020 2:41 pm
by agrohe21
I dont see a uci setting or a script for this.
I am currently getting this was. Is it correct? Is there another/better way?
Code: Select all
ip addr list eth1.2|grep inet|awk '{print $2}'|sed 's/\/22//'
Re: Best way to get wan ip on cli/ash script?
Posted: Fri Feb 28, 2020 2:50 pm
by agrohe21
I do see an entry in /var/state/network
that is probably better/safer, right?
network.wan.ipaddr
Re: Best way to get wan ip on cli/ash script?
Posted: Fri Feb 28, 2020 6:04 pm
by Lantis
Network state is ok.
Is this for use in a script? If so, I would import the network functions file and use it.
Code: Select all
source /lib/functions/network.sh
network_find_wan NET_IF
network_get_ipaddr NET_ADDR "${NET_IF}"
echo "${NET_ADDR}"
Re: Best way to get wan ip on cli/ash script?
Posted: Fri Feb 28, 2020 7:36 pm
by agrohe21
Yes, it is for a script. thx for the tip