How to Find Router IP Address on Linux (6 Easy Methods)
Complete guide for all Linux distributions including Ubuntu, Debian, CentOS, Fedora, Arch, and more
Quick Answer: Fastest Method
Open terminal and type:
ip route | grep default
Your router's IP address will appear after "via"
Distribution Compatibility
Table of Contents
Method 1: ip route Command (Recommended)
The ip route command is the modern, preferred method for viewing routing information on Linux systems. It's part of the iproute2 package, which is installed by default on most modern Linux distributions.
Open Terminal
Access the terminal using any of these methods:
- Keyboard shortcut: Ctrl + Alt + T (most distributions)
- Application menu: Search for "Terminal" or "Console"
- Right-click: Right-click on desktop → "Open Terminal"
- GUI: Activities/Applications → Terminal
📸 Screenshot placeholder: Linux terminal window
Execute ip route Command
Type the following command and press Enter:
ip route
This displays the complete routing table for your system.
📸 Screenshot placeholder: Terminal with ip route output
Locate Default Route
Look for the line that starts with "default" - this shows your router's IP address.
Example Output:
default via 192.168.1.1 dev wlan0 proto dhcp metric 600
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.105 metric 600
In this example, 192.168.1.1 (after "via") is your router's IP address.
Filter for Default Route Only
For a cleaner output showing only the default gateway:
ip route | grep default
This will show only the default route line.
Alternative filtering commands:
ip route show default
Shows default routes specifically
ip route get 8.8.8.8
Shows the route to reach an external IP (reveals gateway)
💡 Pro Tip
The ip command has many useful options. Use ip route help to see all available options, or man ip for comprehensive documentation.
Method 2: route Command (Traditional)
The traditional route command is part of the net-tools package. While considered legacy, it's still widely used and available on most Linux systems. It provides a familiar interface for users coming from other Unix systems.
📋 Availability Note
Some minimal Linux installations may not include net-tools by default. If the command isn't found, you can install it using your distribution's package manager.
Check if route Command is Available
First, verify that the route command is installed:
which route
If it returns a path (like /sbin/route), the command is available.
Install net-tools (if needed)
If the route command is not found, install net-tools:
Ubuntu/Debian:
sudo apt update && sudo apt install net-tools
CentOS/RHEL/Fedora:
sudo yum install net-tools
Or for newer versions:
sudo dnf install net-tools
Arch Linux:
sudo pacman -S net-tools
Execute route Command
Display the routing table:
route -n
The -n flag shows IP addresses instead of resolving hostnames, making output faster and clearer.
Example Output:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 600 0 0 wlan0
192.168.1.0 0.0.0.0 255.255.255.0 U 600 0 0 wlan0
Look for the line with Destination 0.0.0.0 - the Gateway column shows your router's IP.
Filter for Default Gateway
To show only the default gateway:
route -n | grep '^0.0.0.0'
This filters the output to show only the default route (0.0.0.0).
Understanding Route Flags
- U: Route is up (active)
- G: Route is to a gateway (router)
- H: Route is to a host
- D: Route was created by ICMP redirect
- M: Route was modified by ICMP redirect
Method 3: netstat Command
The netstat command is another traditional networking tool that can display routing information. It's part of the net-tools package and provides detailed network statistics and routing tables.
Display Routing Table
Use netstat to show the routing table:
netstat -rn
The -r flag shows routing table, -n shows numerical addresses.
Locate Default Gateway
Look for the default route in the output:
Example Output:
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 wlan0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0
The Gateway column for destination 0.0.0.0 shows your router's IP address.
Alternative netstat Commands
Other useful netstat variations:
Show only default route:
netstat -rn | grep '^0.0.0.0'
Show routing table with hostnames:
netstat -r
Continuous monitoring:
netstat -rn -c
Updates every second (press Ctrl+C to stop)
Method 4: NetworkManager CLI (nmcli)
NetworkManager is the default network management service on many modern Linux distributions. The nmcli command provides a powerful command-line interface to NetworkManager and can display detailed network configuration information.
📋 NetworkManager Availability
Common on: Ubuntu, Fedora, CentOS 7+, openSUSE, Arch Linux
Less common on: Minimal server installations, some embedded systems
Check NetworkManager Status
Verify that NetworkManager is running:
systemctl status NetworkManager
You should see "active (running)" in the output.
Show Active Connections
Display currently active network connections:
nmcli connection show --active
This shows active connections with their names and UUIDs.
Get Detailed Connection Info
Show detailed information for your active connection:
nmcli connection show [connection-name]
Replace [connection-name] with your actual connection name from step 2.
Example for Wi-Fi connection named "MyWiFi":
nmcli connection show "MyWiFi" | grep IP4.GATEWAY
Quick Gateway Lookup
For a quick gateway lookup without specifying connection name:
nmcli device show | grep IP4.GATEWAY
This shows the gateway for all active network devices.
NetworkManager CLI Advantages
- ✅ Shows both IPv4 and IPv6 gateway information
- ✅ Provides detailed connection metadata
- ✅ Can modify network settings
- ✅ Integrates with desktop network managers
- ✅ Supports complex network configurations
Method 5: GUI Network Settings
Most Linux desktop environments provide graphical network management tools. While the exact interface varies between desktop environments, the basic process is similar across different distributions.
Desktop Environment Guides
🟦 GNOME (Ubuntu, Fedora, Debian)
- Open Settings: Click Activities → Settings, or press Super + I
- Navigate to Network: Click "Network" in the left sidebar
- Select Connection: Click on your active connection (Wi-Fi or Wired)
- View Details: Click the gear icon next to your connection
- Find Gateway: Look in the "Details" tab for "Default Route" or "Gateway"
📸 Screenshot placeholder: GNOME Settings Network panel
🔷 KDE Plasma (Kubuntu, openSUSE, Manjaro KDE)
- Open System Settings: Click Application Menu → System Settings
- Navigate to Network: Click "Network" → "Connections"
- Select Connection: Choose your active network connection
- Edit Connection: Click "Edit" or double-click the connection
- View IPv4 Settings: Go to "IPv4" tab to see gateway information
📸 Screenshot placeholder: KDE System Settings Network panel
🐭 XFCE (Xubuntu, Linux Mint XFCE)
- Open Settings Manager: Menu → Settings → Settings Manager
- Network Settings: Click "Network" or "Network Manager"
- Select Interface: Choose your active network interface
- View Properties: Right-click → Properties or Edit
- Check IPv4 Tab: Look for gateway information in IPv4 settings
🌿 Cinnamon (Linux Mint)
- Open System Settings: Menu → System Settings
- Network Settings: Click "Network"
- Select Connection: Click on your active connection
- Connection Details: Click "Options" or gear icon
- IPv4 Settings: Check the IPv4 tab for gateway information
Alternative GUI Tools
nm-connection-editor
NetworkManager's standalone connection editor
nm-connection-editor
wicd-gtk
Alternative network manager with GUI
wicd-gtk
connman-gtk
ConnMan connection manager GUI
connman-gtk
Method 6: /proc Filesystem (Low-level)
The /proc filesystem provides direct access to kernel information, including routing tables. This method works on all Linux systems regardless of installed tools and provides the most fundamental access to network routing information.
View Raw Routing Table
Display the kernel's routing table directly:
cat /proc/net/route
This shows the routing table in hexadecimal format.
Example Output:
Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
wlan0 00000000 0101A8C0 0003 0 0 600 00000000 0 0 0
wlan0 0001A8C0 00000000 0001 0 0 600 00FFFFFF 0 0 0
Decode Hexadecimal Values
The gateway addresses are in hexadecimal format. For the default route (Destination 00000000), convert the Gateway value:
Example conversion for Gateway 0101A8C0:
- 0101A8C0 in hex
- Split into bytes: 01 01 A8 C0
- Convert to decimal: 1 1 168 192
- Reverse byte order: 192.168.1.1
Automated Conversion Script
Use this one-liner to automatically convert and display the default gateway:
awk '/^[^I]/ && $2=="00000000" {printf "%d.%d.%d.%d\n", "0x" substr($3,7,2), "0x" substr($3,5,2), "0x" substr($3,3,2), "0x" substr($3,1,2)}' /proc/net/route
This script finds the default route and converts the gateway to readable IP format.
Alternative /proc Methods
Other useful /proc filesystem locations:
Network interfaces:
cat /proc/net/dev
ARP table:
cat /proc/net/arp
Network statistics:
cat /proc/net/netstat
📝 /proc Filesystem Note
The /proc method provides the most direct access to kernel networking information and works even when networking tools are not installed. However, it requires manual interpretation of hexadecimal values.
Distribution-Specific Methods
Different Linux distributions may have specific tools or configurations that affect how you find network information. Here are distribution-specific tips and tools:
🐧 Ubuntu/Debian Family
Default Tools Available:
- ✅ iproute2 (ip command)
- ✅ NetworkManager (nmcli)
- ⚠️ net-tools (may need installation)
Ubuntu-Specific Commands:
Netplan configuration (Ubuntu 18.04+):
sudo netplan get
Check network configuration files:
ls /etc/netplan/
Legacy network interfaces (older Ubuntu):
cat /etc/network/interfaces
Installation Commands:
sudo apt update && sudo apt install net-tools iproute2
🎩 Red Hat/CentOS/Fedora Family
Default Tools Available:
- ✅ iproute2 (ip command)
- ✅ NetworkManager (nmcli) - CentOS 7+
- ⚠️ net-tools (may need installation)
Red Hat-Specific Commands:
Network scripts (CentOS 6/7):
ls /etc/sysconfig/network-scripts/
Check default gateway in network config:
cat /etc/sysconfig/network
Systemd-networkd (newer systems):
networkctl status
Installation Commands:
⚡ Arch Linux Family
Default Tools Available:
- ✅ iproute2 (ip command)
- ⚠️ NetworkManager (if installed)
- ⚠️ net-tools (manual installation)
Arch-Specific Commands:
Systemd-networkd configuration:
ls /etc/systemd/network/
Check network service status:
systemctl status systemd-networkd
Netctl profiles (Arch-specific):
netctl list
Installation Commands:
sudo pacman -S net-tools iproute2 networkmanager
🦎 openSUSE Family
Default Tools Available:
- ✅ iproute2 (ip command)
- ✅ NetworkManager (nmcli)
- ✅ net-tools (usually pre-installed)
openSUSE-Specific Commands:
YaST network configuration:
sudo yast2 lan
Wicked network service:
wicked show-config
Network configuration files:
ls /etc/sysconfig/network/
Installation Commands:
sudo zypper install net-tools iproute2
Troubleshooting Common Issues
🚫 Command Not Found
Common missing commands:
- route, netstat (net-tools package)
- nmcli (NetworkManager package)
- ip (iproute2 package - rare)
Solutions:
- Install missing packages using your distribution's package manager
- Use alternative commands (e.g., use
ip routeinstead ofroute) - Check if command is in different location:
which [command] - Try with full path:
/sbin/routeor/usr/sbin/route
🔒 Permission Denied
Some commands may require elevated privileges:
- Try with sudo:
sudo ip route - Switch to root user:
su - - Check if user is in network group:
groups - For /proc files, ensure they're readable:
ls -la /proc/net/route
🌐 No Default Route
Possible causes:
- Not connected to any network
- Network interface is down
- DHCP client not running
- Static configuration missing gateway
Solutions:
- Check network interface status:
ip link show - Bring interface up:
sudo ip link set [interface] up - Restart network service:
sudo systemctl restart NetworkManager - Check DHCP client:
sudo dhclient [interface]
🔄 Multiple Gateways
Common scenarios:
- Multiple network interfaces active
- VPN connection active
- Multiple routing entries
Identification:
- Check all routes:
ip route show table all - Check route metrics:
ip route show(lower metric = higher priority) - Check active interfaces:
ip addr show - Test connectivity:
ping -I [interface] 8.8.8.8
Understanding Linux Network Commands
Command Comparison
| Command | Package | Modern/Legacy | Best For |
|---|---|---|---|
ip route |
iproute2 | Modern | General use, scripting |
route |
net-tools | Legacy | Traditional Unix users |
netstat -r |
net-tools | Legacy | Detailed network statistics |
nmcli |
NetworkManager | Modern | Desktop environments |
Understanding Route Output
ip route output format:
default via 192.168.1.1 dev wlan0 proto dhcp metric 600
Field explanations:
- default: Destination (0.0.0.0/0 - all traffic)
- via 192.168.1.1: Gateway IP address
- dev wlan0: Network interface
- proto dhcp: How route was learned (dhcp, static, etc.)
- metric 600: Route priority (lower = higher priority)
Network Interface Names
Common Linux interface naming:
- eth0, eth1: Ethernet interfaces (traditional naming)
- wlan0, wlan1: Wireless interfaces
- enp0s3, enp2s0: Ethernet (predictable naming)
- wlp3s0, wlp2s0: Wireless (predictable naming)
- lo: Loopback interface (127.0.0.1)
What to Do Next
Once you have your router's IP address:
- Test connectivity:
ping 192.168.1.1 - Access web interface: Open browser to
http://192.168.1.1 - Document the information: Save IP for future reference
- Check router documentation: Look up default login credentials
Frequently Asked Questions
Which method should I use?
For most users, ip route | grep default is the best choice. It's modern, fast, and available on virtually all Linux systems. Use GUI methods if you prefer graphical interfaces.
Why do some commands require sudo?
Most network viewing commands don't require sudo, but some system configurations may restrict access. Network modification commands always require elevated privileges for security.
What's the difference between legacy and modern commands?
Legacy commands (route, netstat) are from the net-tools package and use older kernel interfaces. Modern commands (ip) use newer netlink interfaces and are more efficient and feature-rich.
Do these methods work on embedded Linux?
Yes, but embedded systems may have minimal tool sets. The /proc filesystem method works on all Linux systems, regardless of installed packages.
Can I use these commands in scripts?
Absolutely! These commands are perfect for scripting. Use ip route with grep/awk for reliable, parseable output in automated scripts.
What if I have multiple network interfaces?
Linux can have multiple default routes with different metrics. The route with the lowest metric is used. Use ip route show to see all routes and their priorities.