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