Home > System Tutorial > LINUX > body text

How CentOS6 implements router function

WBOY
Release: 2024-06-14 09:58:48
Original
307 people have browsed it

How CentOS6 implements router function

Configuration
Configure all IP addresses first as shown in the figure
Configure routing for different machines

Aubin-CentOS1

    route add default gw 10.0.1.1
Copy after login

CentOS-R1

    route add -net 10.0.3.0/24 gw 10.0.2.2
    route add -net 10.0.4.0/24 gw 10.0.2.2
    echo 1 > /proc/sys/net/ipv4/ip_forward                #启用转发功能(可以理解为启用路由功能)
    iptables -F                                           #关闭防火墙
Copy after login

CentOS-R2

    route add -net 10.0.1.0/24 gw 10.0.2.1
    route add -net 10.0.4.0/21 gw 10.0.3.1
    echo 1 > /proc/sys/net/ipv4/ip_forward
    iptables -F
Copy after login

CentOS-R3

    route add -net 10.0.2.0/24 gw 10.0.3.2
    route add -net 10.0.1.0/24 gw 10.0.3.2
    echo 1 > /proc/sys/net/ipv4/ip_forward
    iptables -F
Copy after login

Aubin-CentOS1

    route add default gw 10.0.4.1
Copy after login

The above is the complete configuration, and then use the CentOS1 zone to test and ping the CentOS2 IP address 10.0.4.100. If the ping is successful, all configurations are fine. If there is no pass, please check the following points at the exhibition

0. Although the configuration is simple, it is cumbersome enough. If you encounter problems, please be patient and check the following items.

1. Use route -n to check whether the route is effective.

2.cat /proc/sys/net/ipv4/ip_forward Check whether the output is 1. If it is 0, it means that the forwarding function is not enabled.

Check whether echo 1 > /proc/sys/net/ipv4/ip_forward is executed successfully.

3. Check whether the IP and mask are configured correctly, because it is easy to get confused with multiple IP addresses, so check carefully.

4. Check whether the firewall is turned off and execute iptables -F.

5. If you are doing experiments in a virtual machine environment, check whether the MAC address conflicts

The above is the detailed content of How CentOS6 implements router function. For more information, please follow other related articles on the PHP Chinese website!

source:linuxprobe.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!