Routing subsystem -- Scope, subsystem scope

Source: Internet
Author: User

Routing subsystem -- Scope, subsystem scope
Scope

Scope is similar to Scope. Routing and IP addresses can be used to specify the Scope to tell the kernel that they are meaningful and usable in those cases.

There are two types of Scope: the Scope of the route and the Scope of the IP address.
Routing Scope:The distance to the destination network.
IP address Scope:It indicates how far the IP address has reached the local host.

Common ScopeIP address common Scope

Host:Indicates that the address is only used for internal communication of the host. Example: 127.0.0.1
Link:Indicates that the address is meaningful within the LAN (Link Layer interconnection), such as the subnet broadcast address.
Global:Indicates that the address can be used anywhere. (This is the default Scope for most addresses)

*Note: ** Scope does not reflect the difference between a routable (public) address and a non-routable (private) address. The Scope of 10.0.0.1 and 165.2.2.2 may be a link or a global domain. The broadcast address and change address are used by the kernel to develop a suitable Scope.

Common routing Scope

Host:The destination address of the route is the local host.
Link:The destination address of the route is the local network.
Global:The route indicates that the destination address exceeds the next hop.

Application of Scope

Routing Scope and IP address Scope are widely used in routing code and other parts of the kernel.
Scope of IP addresses
First, we need to know that for Linux, IP addresses belong to hosts rather than interfaces. In this way, the host has two interfaces, such as eth0 and eth1 (for example, the Wan port in the routing period is eth0: 202.202.202.202 and the lan port is eth1: 192.168.1.1) and the two IP addresses (202.202.202.202.202 and 192.168.1.1) all belong to the host, even though they are configured on different interfaces. In this way, if no further configuration is made, we will consider the ARP response: assume that the vro from eth0 (that is, the wan port) the router will respond when receiving an address request with the IP address 192.168.1.1 (that is, the wan side has a host ping 192.168.1.1. (Of course we can configure it through the ARP_IGNORE feature ).
The IP address belongs to the host, so when there are multiple IP addresses to our host, when the host needs to transmit data outside, which IP address is selected as the source IP address, you need to determine. You can configure different scopes for IP addresses.
Routing Scope
Let's take a look at the application of the routing Scope:

In the figure, host A needs to send messages to host B. The Scope of the first route is A link and the destination address is 10.0.1.0/24. host a cannot use this route to reach host B. The Scope of the second route is global. host a reaches the gateway 10.0.1.1 through eth0 and is transmitted to host B through the gateway.
A larger Scope for routing can ensure that packets can reach farther places.

The implementation of Scope in Linux is described in Linux Kernel

The Linux kernel uses enumeration constants to represent the Scope:

Enum rt_scope_t {RT_SCOPE_UNIVERSE = 0, // scope is the global all remote non-direct connection destination/* User defined values */RT_SCOPE_SITE = 200, // scope RT_SCOPE_LINK = 253, // scope is the link RT_SCOPE_HOST = 254, // scope is the local RT_SCOPE_NOWHERE = 255 // The code is regarded as invalid scopte };

Routing Scope
The routing Scope is saved in the fa_scope field of the struct fab_alias struct.

Struct fab_alias {struct list_head fa_list; struct fab_info * fa_info; u8 fa_tos; u8 fa_type; u8 fa_scope; // route Scope u8 fa_state; # ifdef define struct limit rcu; # endif };

IP address Scope
The IP address Scope is stored in the struct in_ifaddr.

Struct destination {struct destination * ifa_next; struct in_device * ifa_dev; struct rcu_head; _ be32 ifa_local; _ be32 ifa_address; _ be32 ifa_mask; _ be32 ifa_broadcast; unsigned char ifa_scope; // the IP address's Scope unsigned char ifa_flags; unsigned char ifa_prefixlen; char ifa_label [IFNAMSIZ];};
Relationship between routing Scope and threat Scope

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.