FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
1,068 views 1 comments
by
Hi,

I would like an overview of the WAN interface in my application.
How can I get the information of WAN interface, IP address, network mask, Gateway, DNS servers and uptime with SSH commands?

2 Answers

0 votes
by anonymous

Hello,

There are several ways, depends on what you need. For general interface info use on of these commands (output syntax is different):

  • ifconfig <IF_NAME> 
  • ip a show <IF_NAME>

Replace <IF_NAME> with the name of the required WAN interface:

  • wwan0 - mobile WAN
  • eth1 - wired WAN

To print only the required values, use the commands listed below:

WAN IP address:

  • ifconfig <IF_NAME> | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1 }'

Netmask:

  • ifconfig <IF_NAME> | grep 'Mask:' | cut -d: -f4 | awk '{ print $1 }'

WAN IP address/netmask:

  • ip a show <IF_NAME> | grep 'inet ' | awk '{ print $2 }'

Default gateway:

  • ip route | grep 'default' | awk '{ print $3}'

DNS server(s):

  • cat /tmp/resolv.conf.auto | grep 'nameserver' | awk '{ print $2 }'

Remember to replace <IF_NAME> with the actual interface name where required.

Hope this helps, good luck!

Best answer
by anonymous
curl ifconfig.io

this will give you the address you appear as to the world, lots of operators use sNAT etc
0 votes
by anonymous
Hello, try:

ifstatus wan

this command outputs json formated information. Also there are more interfaces, it depends on router, you can list them by command:

ubus list network.interface.*