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 (Cmd+Space, type Terminal, Enter). This one-liner gives you just the gateway address:

route -n get default | grep gateway

Or the classic that prints the whole routing table:

netstat -nr | grep default

The first IPv4 address on the default line is your router. You may also see a second default entry with a long address full of colons, that's IPv6, ignore it for panel-login purposes. Note that macOS does not have the ip command Linux users keep reaching for; muscle memory from Linux is the main reason these lookups fail on a Mac.

No terminal needed if you prefer clicking: System Settings > Wi-Fi > Details next to your network > TCP/IP > Router field. Same number.

Linux

Open a terminal and run:

ip route show default

Output looks like default via 192.168.1.1 dev wlan0 proto dhcp. The address after "via" is your router; the interface after "dev" tells you whether it's your Wi-Fi (wlan0, wlp3s0) or wired (eth0, enp2s0) connection carrying it, useful when both are up.

Alternative commands, depending on what's installed:

CommandWorks On
ip route show defaultAll modern Linux (iproute2)
route -n | grep UGOlder systems with net-tools installed
nmcli dev show | grep GATEWAYAnything running NetworkManager (most desktops)
networkctl statussystemd-networkd systems (servers, some minimal installs)

Where Did ifconfig Go?

If you learned networking any time before roughly 2015, your fingers type ifconfig automatically. On today's Linux distributions the answer is usually "command not found", because ifconfig belongs to the net-tools package that most distros stopped installing by default, its replacement is the ip suite (ip addr for addresses, ip route for routes). You can still apt install net-tools for nostalgia, but scripts should use ip, net-tools hasn't seen serious development in years.

Small twist: on macOS, ifconfig is alive and well and not going anywhere, it just never showed the gateway, only interface addresses. So ifconfig for your local IP, route -n get default for the router. Two commands, two jobs.

While You're There: Your Own Local IP

The gateway commands tell you the router's address. If you also need the address of the machine you're sitting at (for port forwarding rules or SSH from another device), it's ip addr on Linux, look for the inet line under your active interface, or ipconfig getifaddr en0 on macOS for the Wi-Fi interface specifically. Addresses starting 192.168, 10., or 172.16-31 are your local network; 127.0.0.1 is the machine talking to itself and means you're reading the loopback interface, scroll further.

Prefer not to remember any of this? Our router IP tool detects both in the browser.