How to turn on the forwarding function of Linux dual NIC

Source: Internet
Author: User

Original address: http://blog.csdn.net/lllzd/article/details/8587624 Description: In the "Arm Development Board made of USB card (Rndis/ethernet Gadget)" Base mini2440 into a USB card *********************************************************/

A Linux server that connects two different network segments via two network cards,

a:192.168.xxx.xxx

B:172.24.xxx.xxx,

Thus, the interconnection between a network segment and B network segment is realized. The reason that the Linux machine can be set to implement the packet forwarding function.

To run without starting the machine:

#echo "1" >/proc/sys/net/ipv4/ip_forward

Opens the package forwarding feature.

If you want the package forwarding feature to take effect automatically after the system starts, you need to modify the/etc/sysctl.conf file to add a line:

   # Controls IP packet forwarding
     Net.ipv4.ip_forward = 1

Add the correct static route:
route add-net 192.168.76.0 netmask 255.255.255.0 Dev eth0 route add-net 172.24.178.0 netmask 255.255.255.0 Dev Eth1< Span style= "LINE-HEIGHT:26PX; font-family: Song, Arial ">
After the above two steps, if the network can not achieve interoperability, need to verify the configuration of the route, including back and forth two directions, be sure to set the Linux machine as a gateway.

If you want to set up Linux as a router, turn on the NAT function of Iptables:

 /sbin/iptables-t nat-a postrouting-o eth0-j masquerade

The above statement eth0 the network connection or Internet connection. Execute the following command, Rules for saving iptables:

  service iptables save

View routing table:

  Netstat-rn

view iptables rule:

< Span style= "FONT-SIZE:14PX; line-height:26px; Color: #666666; Font-family: Song body, Arial ">  iptables-l

How to turn on the forwarding function of the Linux dual network adapter

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.