Configure Linux for routing

Source: Internet
Author: User

Configure: Turn off the firewall

LINUX1 Address 1:192.168.10.10/24 address 2:192.168.20.10/24 (do not specify a gateway, as a route, you are the gateway)

LINUX2 Address 1:192.168.20.20/24 address 2:192.168.80.10/24 (do not specify a gateway, as a route, you are the gateway)

Win2003 Address: 192.168.10.100/24 Gateway 192.168.10.10

WinXP Address 1:192.168.80.100/24 Gateway 192.168.80.10

I. Enabling the Linux routing feature

1. configuration file net.ipv4.ip_forwartd=1 Enable routing in/etc/sysctl.conf

[Email protected] ~]# Cat/proc/sys/net/ipv4/ip_forward

0 Ipv4/ip_forward =0 indicates that the routing feature is not enabled

[[email protected] ~]# echo ' 1 ' >/proc/sys/net/ipv4/ip_forward Enable routing feature (Zero effect)

[Email protected] ~]# Cat/proc/sys/net/ipv4/ip_forward
1
[[email protected] ~]# vi/etc/sysctl.conf configuration net.ipv4.ip_forwartd=1 Enable routing feature
[[Email protected] ~]# service network start
[Email protected] ~]# sysctl-p
Net.ipv4.ip_forward = 1
Net.ipv4.conf.default.rp_filter = 1
Net.ipv4.conf.default.accept_source_route = 0
KERNEL.SYSRQ = 0
Kernel.core_uses_pid = 1
Net.ipv4.tcp_syncookies = 1
KERNEL.MSGMNB = 65536
Kernel.msgmax = 65536
Kernel.shmmax = 68719476736
Kernel.shmall = 4294967296

Sysctl-p (display kernel parameters) sysctl configuration and kernel parameters displayed in the/proc/sys directory. You can use Sysctl to set up or reset networking features such as IP forwarding, IP fragment removal, and source routing checks. Users only need to edit the/etc/sysctl.conf file to manually or automatically perform the functions controlled by sysctl.

Two. Set up route forwarding to enable Win2003 and XP to ping each other

1. View the routing table and add static route (Create a route-ethx file, where the EthX must be the name of the network card, the Linux router has more than one network card, that belongs to that one! Belonged to the one that was forwarded out. )

To create a route-eth1 file in Linux1/etc/sysconfig/nework-scripts/route-eth1, add the following:

address1=192.168.80.0

netmask1=255.255.255.0

gateway1=192.168.20.20

Or: Route add-net 192.168.80.0 netmask 255.255.255.0 GW 192.168.20.20

To create a route-eth0 file in Linux2/etc/sysconfig/nework-scripts/route-eth0, add the following:

address1=192.168.10.0

netmask1=255.255.255.0

gateway1=192.168.20.10

Or: Route add-net 192.168.10.0 netmask 255.255.255.0 GW 192.168.20.10

2. Restart the service

[Email protected] ~]# service network restart

Shutting down interface eth0: [OK]
Shutting down interface eth1: [OK]
Close Loopback interface: [OK]
Disable IPV4 packet forwarding: Net.ipv4.ip_forward = 0
Determine
Eject loopback interface: [OK]
Popup interface eth0: [OK]
Popup interface eth1: [OK]

3. View routing Settings
[Email protected] ~]# route-n
Kernel IP Routing Table
Destination Gateway genmask Flags Metric Ref use Iface
192.168.20.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.80.0 192.168.20.20 255.255.255.0 UG 0 0 0 eth1
192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1

[Email protected] ~]# route-n
Kernel IP Routing Table
Destination Gateway genmask Flags Metric Ref use Iface
192.168.20.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.80.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.10.0 192.168.20.10 255.255.255.0 UG 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1

4. (win2003) test passes and routes

C:\Documents and Settings\administrator>pathping 192.168.80.100

Tracing route to WINXP [192.168.80.100]
Over a maximum of hops:
0 Win2003 [192.168.10.100]
1 192.168.10.10
2 192.168.20.20
3 WINXP [192.168.80.100]

5. (WinXP) test passes and routes

C:\Documents and Settings\administrator>pathping 192.168.10.100

Tracing route to 192.168.10.100 over a maximum of hops

0 192.168.80.100
1 192.168.80.10
2 192.168.20.10
3 192.168.10.100

Configure Linux for routing

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.