Ubuntu Linux Find Out Default Gateway / Route

How do I find out default gateway IP address (default router IP assigned) for my Ubuntu Linux systems?

A router is nothing but device that moves data between computer networks. If you have an internet connection at home or office, you may have a router installed by your ISP. Some people have all-in-one router that connects to the Internet and shares internet and other LAN resources via WiFi. Typically, the first router in your home/office is used by computer and mobile devices to access internet access. It is also known as a default gateway as it is your gateway to the internet. Let us see how to find out your Gateway on Ubuntu.
Tutorial details
Difficulty level Easy
Root privileges No
Requirements Ubuntu Linux Terminal app
Est. reading time 3 minutes

Ubuntu Linux Finding Out Default Gateway / Route Table

Use the route command or ip command to get default routing table (Gateway) for Ubuntu Linux using the command-line option. Open the terminal and then type the following commands.
route -n
Sample routing table. Always look for UG flag:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface   U     2      0        0 wlan0   U     1      0        0 eth0   U     0      0        0 virbr0     U     1000   0        0 wlan0         UG    0      0        0 wlan0

Destination for is set to via wlan0 interface i.e. is default gateway. If you just type the route command with the -n switch it show word default instead of
Here is what we see:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface     *        U     2      0        0 wlan0     *        U     1      0        0 eth0   *        U     0      0        0 virbr0
link-local      *          U     1000   0        0 wlan0
default         UG    0      0        0 wlan0

Possible flags and their meaning in Ubuntu Linux routing table:

  • U : route is up
  • H : target is a host
  • G : use gateway
  • R : reinstate route for dynamic routing
  • D : dynamically installed by daemon or redirect
  • M : modified from routing daemon or redirect
  • A : installed by addrconf
  • C : cache entry
  • ! : reject route

The ip command

The following command does the same thing as route is now replaced by the ip tool:
ip route show
My routing table on Ubuntu Linux: dev wlan0  proto kernel  scope link  src  metric 2 dev eth0  proto kernel  scope link  src  metric 1 dev virbr0  proto kernel  scope link  src dev wlan0  scope link  metric 1000 
default via dev wlan0  proto static 

Here is another output showing various interfaces, subnets (CIDR) and their gateways:

$ ip route 
default via dev eth0 proto dhcp src metric 100 dev lxdbr0 proto kernel scope link src dev eth0 proto kernel scope link src dev eth0 proto dhcp scope link src metric 100 

Want to see default gateway for the, and IP address? Try:
$ ip -c route get
$ ip -c route get
$ ip -c route get


We explained how to obtain default gateway and routing able on Ubuntu Linux using route and ip commands. However, we strongly recommend that you use the ip command instead of the route command. Please man pages for more information by typing the following man command:
$ man ip
$ man route

See also

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 2 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
2 comments… add one
  • srinivas Jun 24, 2013 @ 7:23

    How to find remote systems gateway from server in the same lan .

    we have multiple gateways in our network like , and .

    how can find out that which system is using which gateway .

  • Polly Rodriquez May 29, 2021 @ 8:55

    I wanted to find out my wifi router IP address but I didn’t know what was it. But I knew Cloudflare IP address so I typed
    $ ip -c route get via dev eth0 src uid 1000 

    Then I typed in my browser and I got router login page. Gracias.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum