How Do You Find The Default Gateway of Your Linux Server?

Problem scenarios:  Either you are using CentOS 7.x (and ifconfig is even not a command) or you are using ifconfig and different flags (like -v for verbose), but you cannot find the default gateway.  How do you know if you have a default gateway even configured on a Linux server?

Solution  The "ifconfig" command cannot show the default gateway.  To find the default gateway on your Linux server, there are three different commands:

​ip route
netstat -rn 
route -n

The "ip route" command will show the result by displaying "default via x.x.x.x..."  The x.x.x.x is the IP address of the default gateway.

Leave a comment

Your email address will not be published. Required fields are marked *