Linux Routing and Forwarding experiment (soft routing)

Source: Internet
Author: User
Tags iptables

One. Experimental network topology

(R1,R2 is implemented by adding a dual NIC to the Linux virtual machine for soft routing)

650) this.width=650; "Src=" http://www.178linux.com/users/lin/appdata/local/ynote/data/ldt195175108@163.com/ 6455c7c014454a9a8dfa57ecdde48431/d5b5b5ed3efa4c9d8fa982b268b1f3f8.jpg "style=" Height:auto;vertical-align:middle ; border:0px; "alt=" d5b5b5ed3efa4c9d8fa982b268b1f3f8.jpg "/>

650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20160904/1472987733995657.jpg "title= "1472987733995657.jpg" alt= "3.jpg" width= "655" height= "377" style= "height:377px;vertical-align:middle;border:0px; width:655px; "/>

Two. Environment Preparation:

(The virtual machine NIC needs to be set to bridging mode)

1. Close the NetworkManager:

Service Networknanager Stop

Disable Boot from:

Chkconfig Networknanager off

Empty the Iptables entry:

Iptables-f

Turn on Route forwarding: (0: Disabled, 1: Enabled)

Echo 1 >/proc/sys/net/ipv4/ip_forward

Check that the routing forwarding feature is turned on:

Cat/proc/sys/net/ipv4/ip_forward

Three. Configure the network card:

Configuration file:/etc/sysconfig/network-scripts/ifcfg-eth#

1. Delete ifcfg-eth# old profile and re-establish eth1, eth2 configuration

R1:

Eth1 (intranet):/etc/sysconfig/network-scripts/ifcfg-eth1

Device=eth1

Bootproto=none #禁用dhcp

ipaddr=192.168.48.1

Prefix=24

gateway=192.168.48.1


Eth2 (External network):/etc/sysconfig/network-scripts/ifcfg-eth2

Device=eth2

Bootproto=none #禁用dhcp

ipaddr=10.0.48.1

Prefix=8

gateway=10.0.48.1

R2:

Eth1 (intranet):/etc/sysconfig/network-scripts/ifcfg-eth1

Device=eth1

Bootproto=none #禁用dhcp

ipaddr=172.16.48.1

Prefix=16

gateway=172.16.48.1

Eth2 (External network):/etc/sysconfig/network-scripts/ifcfg-eth2

Device=eth2

Bootproto=none #禁用dhcp

ipaddr=10.0.48.2

Prefix=8

gateway=10.0.48.2

After the configuration is complete, you need to restart the network card:

Service Network restart

2. Add Routing information:

(Direct-attached network does not need to add routing information)

(Non-direct-attached network, GW is the nearest port IP for neighboring routes)

R1:

Route add-net 172.16.0.0/16 GW 10.0.48.2 Dev eth2

R2:

Route add-net 192.168.48.0/24 GW 10.0.48.1 Dev eth2


3. Test:

Add 192.168.48.0/24 and 172.16.48.0/16 in-network host, ping test can be


Linux Routing and Forwarding experiment (soft routing)

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.