8413 questions

9899 answers


14199 members

0 votes
837 views 5 comments


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


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


For main WAN interface use:

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


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


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.

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

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 and the 'status' message returns WAN IP as something like - then it's wired. If the message returns an IP from another subnet, like - 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

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

# 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

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
Works for me so far.