How to configure access for different network segments in Linux

Source: Internet
Author: User

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


  1. Comprehensive Analysis of Linux system management command w
  2. Summary of Linux shortcut keys
  3. Linux compression command 1) tar
  4. Summary all Linux compression and decompression commands
  5. Detailed introduction to Linux software package dependency

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.