Router – How to Identify if a Device is a Router

ipv4router

I am working on a small project that creates a map of your local network and I need to be able to determine if X.X.X.X is a router or a device connected to it.

My original strategy was to use nmap and using the result of Device type to determine if the device was a router or a computer connected to the network but when I ran this at home using my router as the target IP it returns general purpose rather than router.

Are there any accurate ways to remotely determine if X.X.X.X is a router or not?
Could I be using nmap better? I used nmap -O -v X.X.X.X.

Best Answer

This may be a bit "heavy handed" but sometimes the simplest solutions are best. Simply test to see if it works like a router. (Obviously, Jens Link's solution would be best for IPv6 but for IPv4 this wouldn't be as reliable.)

Change the default gateway on your computer to each discovered IP address and do a traceroute to www.google.com. Even if it routes to another IP on the same network, it is still processing traffic as a router. Non-router devices should just drop/reject/error the traffic.

I would recommend scripting this though, as it would be quite tedious to do manually.

Related Topic