The Linux administrator may encounter various problems at work. If you need to set different Linux CIDR blocks to access this job, it is still a bit difficult to hear. Description of this example: The 10.0.0.0/24 CIDR Block and 192.168.2.0/24 CIDR block access each other and help you understand the solution to this problem.
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 the local machine (IP: 10.0.0.120) and remote machine (IP: 192.168.2.80) can access each other.
[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 routing rules
[Root @ localhost root] # route del-net 192.168.2.0/24 eth0
- Comprehensive Analysis of Linux system management command w
- Summary of Linux shortcut keys
- Linux compression command 1) tar
- Summary all Linux compression and decompression commands
- Detailed introduction to Linux software package dependency