Question: How do I find the default gateway IP of my router in Linux?
In a previous article, I told you about finding IP address in Linux command line. In this quick tip, I’ll show you how to find the default gateway IP in Linux command line.
I am going to use the same IP command that you saw in the old article.
Open a terminal and use the following command:
You should see an output like this:
default via 192.168.0.1 dev wlp1s0 proto dhcp metric 600 169.254.0.0/16 dev wlp1s0 scope link metric 1000 192.168.0.0/24 dev wlp1s0 proto kernel scope link src 192.168.0.105 metric 600
Focus on the line that starts with default. This will give the default gateway IP.
Alternatively and conveniently, you can use the above command in combination with grep command:
ip route | grep default
This will just give the default gateway IP in the output:
default via 192.168.0.1 dev wlp1s0 proto dhcp metric 600
And as you can see, 192.168.0.1 is the default gateway IP in my case.
I hope this quick Linux tip helped you in finding the default gateway IP in Linux command line. Add this website to your feed reader for such regular quick Linux tips.