Finding Routers Automatically for Bash Script Configuration

Hello,

I am currently creating a bash script to configure my OPENWRT routers.

The goal is to connect to my routers via SSH, each with its own IP. I would like my script to detect the routers in a room without knowing the gateway IP where the routers are connected and then list each router for me.

I had already thought of a solution such as:

Using the arp -a command on my Windows, I retrieve the information that interests me, which is:

Interface: 192.168.1.55 --- 0xe
  Internet Address      Physical Address      Type
  192.168.1.1           10-06-45-c1-96-20     dynamic
  192.168.1.2           dc-2c-6e-9d-0e-dd     dynamic

Then I can retrieve the physical address and compare it with a known MikroTik address table:

I simplified my idea because my concern is not there.

Actually, the biggest problem I have is with Linux and especially my WSL. The arp -a or arp command on Linux does not give the same output as on Windows at all.

So I wanted to know if you have any solutions to suggest to me to easily retrieve the addresses of my routers? I would also like not to need to know the gateway where the routers are (192.168.1.X), but if it causes too much complication, I can use it just in case.

I hope I have been clear, thank you for your attention!

Have a great day!

Finally, I used a fairly simple technique; you just need to create an alias of your Windows ARP with the path to arp.exe. Since it's within a bash script, you need to create a function, otherwise it won't work:

bash

arp() {
    "/mnt/c/Windows/System32/arp.exe" "$@"
}

arp -a

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.