How do you view the gateway in Linux using the ‘route’ command?

In Linux, you can use the “route” command to view the gateway. The specific command format is as follows:

route -n

The -n option can display IP addresses in numerical form instead of resolving hostnames.

After executing this command, the system’s current routing table will be displayed, including information such as destination network, gateway, subnet mask, flags, and interface. The gateway is typically located in the “Gateway” column.

In addition, you can also use the ip route command to check the gateway. The specific command format is as follows:

ip route

This will display similar routing table information, including destination network, gateway, subnet mask, flags, and interface.

bannerAds