Find Your Router IP on Mac and Linux
Use the terminal to quickly find your Default Gateway on macOS or any Linux distribution. Takes under ten seconds.
macOS
Open Terminal (Applications > Utilities > Terminal or Cmd+Space then type Terminal). Run one of these commands:
netstat -nr | grep default
Or the newer equivalent:
ip route get 1 | grep -oP "via \K\S+"
The IP address after "default via" or "gateway" is your router. Type it in a browser to reach the admin panel.
You can also find the gateway in System Settings > Network > select your Wi-Fi or Ethernet connection > Details > TCP/IP tab > Router field.
Linux
Open a terminal and run:
ip route show default
Output example: default via 192.168.1.1 dev wlan0 proto dhcp. The address after "via" is your router gateway.
Alternative commands that also work:
| Command | Works On |
|---|---|
ip route show default | All modern Linux (iproute2) |
ip route | grep default | All modern Linux |
route -n | grep UG | Older Linux with net-tools |
nmcli dev show | grep GATEWAY | Systems using NetworkManager |
cat /etc/resolv.conf | Often shows gateway in some configs |