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,532 views 5 comments
by

Hi,

How to get the interface type of WAN using UCI-command with RUT955?

for example, the result of running this command uci get network.wan  is  interface

but how to get the type of this interface (Wired, Mobile, Wi-Fi, ...etc) using UCI command?

Thanks in advance and with best regards

by

Update for the question:

How to get the interface type of WAN using any Kind of command lines with RUT955? not necessarily with UCI

the screen shots below give an explanation about what I need:

2 Answers

0 votes
by anonymous

Hi,

For main WAN interface use:

  • uci get network.wan.ifname
For WAN failover interfaces:
  • uci get network.wan2.ifname
or
  • uci get network.wan3.ifname
by

Hi,

but these commands do not give the interface type. I need to know through which medium the router is connecting to the internet.

is it via Wired, Mobile, Wi-Fi, ...etc

the screen shots below give an explanation about what I need

by anonymous

Then you won't be able to check it with UCI. It's used for checking or changing the config files. Since the config files remain static after network changes (or most changes for that matter), UCI will not show you which one is in use currently.

The closest you can get to checking the WAN interface with SMS is by using the status message and attempting to identify the interface based o the WAN IP address.

by
Thanks very much for the answer. please, could you give more details about how to achieve that using status message? I will be very thankful to get clear steps to perform that.

Best regards
by anonymous

You may have misunderstood. One of the things contained in the 'status' message is the router's WAN IP address. In some cases it could be possible to say which interface is in use by looking at the IP address.

For example, if you are that your wired WAN network is 192.168.2.0/24 and the 'status' message returns WAN IP as something like 192.168.2.122 - then it's wired. If the message returns an IP from another subnet, like 10.160.0.89 - then it's possibly mobile.

This is easy to determine only if you have good knowledge of the networks your router may use, but it doesn't specifically tell you which interface you're using. So in short - there's no direct way.


Though you can add a rule to Status → Events Log → Events Reporting that informs you automatically of which interface is used when they do change:

0 votes
by anonymous

Although this thread is pretty old I stumpled across the same issue and came up with a really quick 'n dirty solution.

I created a file getwanif.sh with the following content

#!/bin/sh
# get first hop from a traceroute to a public place (e.g. google.com)
# -f    First number of hops
# -m    Max number of hops
# -w    Time to wait for a response
# -q    Number of probes per hop
# tail to get the last line
# awk to print the 2nd word/column
FIRSTHOPIP=`traceroute -f 1 -m 1 -w 3 -q 1 google.com | tail -n 1 | awk '{print $2}'`

# get the device name where the IP is assigned as first gateway
# the are different notations for the routes (default or all) hence we look for "dev [a-z0-9]" and print the next word/column after that using awk
# and lastly since there are multiple lines where this matches we only take the last one
FIRSTHOPDEV=`ip route show table main | grep ${FIRSTHOPIP} | grep -o '\bdev\ [a-z0-9]*' | awk '{print $2}' | tail -n 1`

# print out the device name
echo ${FIRSTHOPDEV}


This is not pretty and can be simplified a lot but it is quite self explanatory when cou concatenate lot of grep and awk :-)

root@rut:~# /tmp/getwanif.sh
wlan0
root@rut:~#
Works for me so far.