How to query gateway information on Linux: 1. Use the "route -n" command to view; 2. Use the "netstat -r" command to view; 3. Use the "cat /etc/sysconfig/network" command to check; 4. Use the "ip route show" command to check.
#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
Linux query gateway information
Method 1
Execute the following command
route -n
The system returns something similar to the following, judging and obtaining the corresponding internal and external gateway addresses based on the Destination parameter value.
Method 2
Execute the following command
netstat -r
The system returns something similar to the following, judge and merge based on the Destination parameter value Obtain the corresponding intranet and external network gateway addresses.
Method three
Execute the following command
cat /etc/sysconfig/network
The system returns something similar to the following, the value of the GATEWAY parameter is Gateway address.
Method 4
Execute the following command
ip route show
The system returns something similar to the following, the IP behind the default via field That is the gateway IP.
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of How to query gateway information in Linux. For more information, please follow other related articles on the PHP Chinese website!