Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to check the routing table under Linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "how to view the routing table under Linux". It is easy to understand and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn the article "how to view the routing table under Linux".

A routing table is a spreadsheet or class database stored in a router or networked computer. The routing table stores paths to specific network addresses. The routing table contains the topology information around the network, and the main goal is to achieve routing protocols and static routing.

I. View the routing table [root@VM_139_74_centos ~] # route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default gateway 0.0.0.0 UG 2000 eth0 10.0.0.10 10.139.128.1 255.255.255.255 UGH 2000 eth0 10.139.128.00 .0.0.0 255.255.224.0 U 00 0 eth0 link-local 0.0.0.0 255.255.0.0 U 1002 00 eth0 172.17.0.0 0.0.0.0 255.255.0.0 U 00 0 docker0 172.18.0.0 0.0. 0.0 255.255.0.0 U 0 0 0 br-0ab63c131848 172.19.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-bccbfb788da0 172.20.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-7485db25f958 [root@VM _ 139_74_centos ~] # route-n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.139.128.1 0.0.0.0 UG 000 eth0 10.0.0.10 10.139.128.1 255.255.255.255 UGH 2000 eth0 10.139.128.0 0.0.0.0 255.255.224.0 U 00 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 1002 00 eth0 172.17.0.0 0.0.0.0 255.255.0.0 U 00 0 docker0 172.18.0.0 0.0.0.0 255.255.0.0 U 000 br-0ab63c131848 172.19.0.0 0.0.0.0 255.255.0.0 U 000 br-bccbfb788da0 172.20.0.0 0.0.0.0 255.255.0.0 U 000 br-7485db25f958 II. The routing table fields describe the Destination destination network or destination host. When Destination is default (0.0.0.0), it means that this is the default gateway, and all data is sent to this gateway (here is 10.139.128.1) Gateway gateway address. 0.0.0.0 means that the Destination corresponding to the current record is on the same network segment as the local machine, and the network mask in the GenmaskDestination field is not required when communicating through the gateway (two hosts in the same LAN do not need to communicate through the gateway). When Destination is a host, it needs to be set to 255.255.255.255. If it is a default route, it will be set to 0.0.0.0Flags flag U-Up means valid G-Gateway means connection route, if not this field indicates that the directly connected destination address H-Host indicates that the target is a specific host, rather than the table item D generated by the network segment R resuming dynamic routing is dynamically installed by the routing daemon and modified by the routing daemon! Deny routing Metric routing distance, the number of transfers required to reach a specified network, is required for large LAN and WAN settings (not used in the Linux kernel. The number of Ref routing item references (not used in the Linux kernel ) Use the number of times this routing item is looked up by the routing software, such as the name of the Iface network card, such as which network interface eth0; needs to use to go to this network segment. That is, the network card eth0 displays the details.

Third, the type of linux route 1, host route, the route record in the routing table pointing to a single IP address or host name, whose Flags field is H. In the following example, for the host 10.0.0.10, it is routed through the gateway 10.139.128.1:

[root@VM_139_74_centos ~] # route-n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 10.0.10 10.139.128.1 255.255.255.255 UGH 000 eth0.. .2, network routing, the network that the host can reach. In the following example, for the network 10.0.0.0amp 24, it is routed through the gateway 10.139.128.1:

[root@VM_139_74_centos ~] # route-n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 10.0.0.0 10.139.128.1 255.255.255.0 UG 000 eth03, default route. When the destination host's IP address or network is not in the routing table, the packet is sent to the default route (default gateway). The Destination of the default route is default or 0.0.0.0.

[root@VM_139_74_centos ~] # route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default gateway 0.0.0.0 UG 2000 eth0 IV, route command options:

-A: set the address type

-C: print the routing cache of the Linux kernel

-v: display details

-n: do not perform DNS reverse lookup, but directly display IP addresses in numeric form

-display the routing table in e:netstat format

-net: to the routing table of a network

-host: to the routing table of a host

Parameters:

Add: add routing records

Del: delete route record

Target: destination network or destination host

Gw: setting default gateway

Mss: sets the maximum block length (MSS) of TCP, in MB

Window: specifies the size of the TCP window for TCP connections through the routing table

Dev: network interface represented by the routing record

1. Add a host route. When adding a host route, you need to specify the network ID and the host ID. At this time, you need to set netmask 255.255.255.255:

[root@VM_139_74_centos ~] # route add-net 10.0.0.10 netmask 255.255.255.255 gw 10.139.128.1 dev eth0 [root@VM_139_74_centos ~] # route-n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 10.0.0.10 10.139.128.1 255.255.255.255 UGH 000 eth0.. .2, add network route When adding a network route, you only need to specify the network ID and set the mask length through netmask:

[root@VM_139_74_centos ~] # route add-net 10.0.0.0 netmask 255.255.255.0 gw 10.139.128.1 dev eth0 [root@VM_139_74_centos ~] # route-n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 10.0.0.0 10.139.128.1 255.255.255.0 UG 000 eth0.. 3, Add hosts on the same LAN When the gw option is not specified, the added route records do not use gateways:

[root@VM_139_74_centos ~] # route add-net 224.0.0.0 netmask 240.0.0.0 dev eth0 [root@VM_139_74_centos ~] # route-n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 224.0.0.0 240.0.0.0 U 000 eth0.. 4, blocked route

[root@VM_139_74_centos ~] # route add-net 224.0.0.0 netmask 240.0.0.0 reject [root@VM_139_74_centos ~] # route-n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 224.0.0.0-240.0.0.0! 0-0-.5, delete available routes

Route del-net 224.0.0.0 netmask 240.0.0.06, remove masked rout

Route del-net 224.0.0.0 netmask 240.0.0.0 reject7, delete and add settings default gateway, when you add or delete a default gateway, Linux automatically checks the availability of the gateway:

[root@VM_139_74_centos ~] # route add default gw 192.168.1.1 SIOCADDRT: Network is unreachable [root@VM_139_74_centos ~] # route del default gw 192.168.1.1 SIOCDELRT: No such process is all the contents of the article "how to View the routing Table under Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report