Query about supported commands in OpenWrt

Dear gentlemen,

Is there any way to show the complete list of supported console commands in OpenWRT and its modifiers?

By example, Ping, ARP, etc...

I am looking for the commands that help me to create a file that contain the Hostname, IP and MAC Address of all devices connected to the LAN or WiFi form the router.

Any idea?



cat /tmp/dhcp.leases

@iplaywithtoys thanks.

But and if the LAN device has static IP. How can I do that?



With an ARP cache query.

ip n show|grep br-lan

(br-lan match can be any of the local interface zones)

phuque991, thanks by your answer.

This command show the MAC and IP Address but how can I obtain the hostname to those MAC's and IP Address?



Hostnames advertised by the machine requesting dhcp are saved in the file referenced by @iplaywithtoys above. Static IPs hostnames, if configured in the router might have static entries in your DNS.

In short, there's no single command to do what you want. You'll have to script them yourself.

Some devices do not send a hostname when they DHCP. A static device will not DHCP, thus dnsmasq cannot know its hostname.

The first situation can be addressed by putting a 'config host' in your /etc/config/dhcp to associate a hostname with the device's MAC address. This works whether or not you also assign the host a reserved IP address. I prefer not to reserve or statically assign any IP addresses, and address by name. When the network changes, DHCP will automatically ensure that everyone has a unique IP.

Is there any way to show the complete list of supported console commands in OpenWRT and its modifiers?

no, you could get the list of commands by hitting tab tab, but that will give
you thousands of commands (far too many to be useful), each of the commands has
a man page, each of which ranges from a screenful to hundreds of screens worth
of information.

each package that you install then adds additional commands to this list.

These are Linux systems, so look at books on Linux administration (they tend to
be the thousand page monsters), that will give you an introduction on the
commands, but this is just an introduction.

I am looking for the commands that help me to create a file that contain the
Hostname, IP and MAC Address of all devices connected to the LAN or WiFi form
the router.

you can get the list of MAC addresses connected to wifi easily.

the list of MAC addresses connected to the wired lan is a bit harder (because
it's possible for things to be connected to the wired lan and never talk to the
router, unusual, but possible)

Translating these to IP addresses can be done via the arp table, but only for
things that have talked to the router.

It could also be done by looking at DHCP leases, but only for things that have
requested DHCP addresses (commonly everything on the network, but it's not a
requirement unless you have 802.1x setup)

getting hostnames is a third step, DHCP can issue hostnames, or report hostnames
provided by the client, but that doesn't necessarily match the hostname set on
the system (but may be good enough for your purposes)

In short, the network doesn't work the way you think it does, but looking at the
DHCP lease information may give you the info you are looking for on your
network (where it's a reasonable assumption that you don't have anyone with a
lot of network knowledge trying to hide from you)

David Lang

@iplaywithtoys / @phuque991 / @mk24 / @dlang very thanks by your answers...

Well, I pose you my idea...

I am thinking in a project to home network, where don't there private DNS habitually.

I need create, for example, a text file that contain the MAC, IP and Hostname of the LAN / WiFi devices with DHCP and Static IP Addresses from the router, assuming that the router is de Default Gateway of the LAN and the devices are generating traffic to the Internet throught this router, or do a Ping from the router to the LAN network IP addresses, and later I will treat this file to other purposes.

I know that there is no a single command that generate this information and I need to do a script with the commands that generate each part of the information that later I will cross to obtain me text file with the MAC, IP and Hostname.

For example, if I do a Ping to entire LAN IP network and then use the ip command, I obtain some information (I am doing this from a Linux becouse I haven't a router with OpenWRT to hand):

root@Linux:/# ip neighbour show
. dev enp0s10 lladdr 00:26:73:23:bb:59 STALE dev enp0s10  FAILED dev enp0s10 lladdr 40:b0:34:39:a9:76 DELAY dev enp0s10  FAILED dev enp0s10  FAILED dev enp0s10  FAILED dev enp0s10 lladdr 00:09:0f:09:00:11 STALE

I have already the alives MAC and IP addresses and now need a command that report me the hostname and the IP or MAC addresses to cross with the previous information and I will generate the file with the results.

But there is a command or little installable application in this router that give me the hostname and the other parameter that I need to cross both informations.

I hope I raised my idea well.



MAC address - layer 2
IP address - layer 3
Hostname - layer 7

Cross-referencing MAC and IP address is easy. You've already done it.

Cross-referencing IP address with hostname depends on other factors. The device doing the query has to have one of:

  • A static entry in a hosts file
  • A pointer to a DNS server which knows about the target (the DNS server could be on the same device)

If the static entry does not exist, or if the DNS server does not know about the target, then you will not be able to automate your query. You'll have to do a laborious manual exercise in data collection.

this is somewhat akin to firing a cannon at a mosquitto but there's on openwrt package for
nmap: https://nmap.org/

# cat /tmp/dhcp.leases | grep "1" | awk '{gsub("*","\\*"); gsub( "_","\\_" ); printf "Date Acquired: " ; system("date \"+%d/%m/%Y %T\" -d \"@$(( "$1" - 43200))\"");printf "Device Name: " $4 "\nIP Assigned: " $3 "\nMAC Address: " toupper($2)"\nDevice State: "; system("./get_ping "$4" 1") ;printf "\n\n" }'

Where "/get_ping" is like this:



ping ${DEVICE} -w 1 -q &>/dev/null; [ $? == 0 ] && echo -en "Up" || echo -en "Down"
if [ -z ${NL} ];then
	echo -en "\n"

Hope this can help you.

You can get close with what has been discussed here. A couple other "challenges" that might not be obvious are:

  • A single MAC address can be associated with multiple IP addresses, even within IPv4 or IPv6 taken alone.
  • There is no such thing as "associated" for Ethernet


Sure, with very fat bullets...