How to check the default gateway Linux (Ubuntu | Debian | Centos) CLI

This is a quick reference guide on how to check the default gateway on Linux Based Operating Systems.

2. ip route or ip r

[root@vps1 ~]# ip r
default via 10.0.125.254 dev ens3
10.0.125.0/24 dev ens3 proto kernel scope link src 10.0.125.11
[root@vps1 ~]# ip route
default via 10.0.125.254 dev ens3
10.0.125.0/24 dev ens3 proto kernel scope link src 10.0.125.11
[root@vps1 ~]#

Thank you for reading and please feel free to leave any feedback.

How to check the routing table Linux (Ubuntu | Debian | Centos) CLI

This is a quick reference guide on how to check the routing table on Linux Based Operating Systems.

1. route -n

[root@vps1 ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.125.254    0.0.0.0         UG    0      0        0 ens3
10.0.125.0      0.0.0.0         255.255.255.0   U     0      0        0 ens3
172.16.5.0      10.0.125.253    255.255.255.0   UG    0      0        0 ens3

2. netstat -rn

[root@vps1 ~]#  netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         10.0.125.254    0.0.0.0         UG        0 0          0 ens3
10.0.125.0      0.0.0.0         255.255.255.0   U         0 0          0 ens3
172.16.5.0      10.0.125.253    255.255.255.0   UG        0 0          0 ens3

3. ip route list

[root@vps1 ~]# ip route list
default via 10.0.125.254 dev ens3
10.0.125.0/24 dev ens3 proto kernel scope link src 10.0.125.11
172.16.5.0/24 via 10.0.125.253 dev ens3

Thank you for reading and please feel free to leave any feedback.