How to implement access between different CIDR blocks in Linux

Source: Internet
Author: User
Article Title: how to implement access between different CIDR blocks in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

In this example, the IP address range 10.0.0.0/24 and the IP address range 192.168.2.0/24 are used to access each other.
Step 1: view the local IP address
[Root @ localhost root] # ifconfig
Eth0 Link encap: Ethernet HWaddr 00: 0C: 29: A7: 6E: 77
Inet addr: 10.0.0.120 Bcast: 10.0.0.255 Mask: 255.255.255.0
Up broadcast running multicast mtu: 1500 Metric: 1
RX packets: 2418 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 1293 errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 fig: 100
RX bytes: 1000347 (976.9 Kb) TX bytes: 192592 (188.0 Kb)
Interrupt: 10 Base address: 0x2024
Step 2: Add routing rules
[Root @ localhost root] # route add-net 192.168.2.0/24 eth0

Step 3: View routing rules
[Root @ localhost root] # route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.0.0*255.255.255.0 U 0 0 0 eth0
192.168.2.0*255.255.255.0 U 0 0 0 eth0
169.254.0.0*255.255.0.0 U 0 0 0 eth0

Note: in a route rule, two CIDR blocks must exist at the same time. Otherwise, the IP address of one CIDR block cannot access the IP address of another CIDR block.
Step 4: Check whether mutual access is allowed between the local machine (IP: 10.0.0.120) and remote machine (IP: 192.168.2.80.
[Root @ localhost root] # ping 192.168.2.80
PING 192.168.2.80 (192.168.2.80) 56 (84) bytes of data.
64 bytes from 192.168.2.80: icmp_seq = 1 ttl = 127 time = 5.51 MS
64 bytes from 192.168.2.80: icmp_seq = 2 ttl = 127 time = 3.17 MS

Step 5: Delete a routing rule
[Root @ localhost root] # route del-net 192.168.2.0/24 eth0

 

Related Article

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.