Use iptables for port forwarding on the dual Nic of the CentOS server
Source: Internet
Author: User
Two NICs: eth0, 172.18.1.Xeth1, and 211.139.169.X1. New/root/wtrouter. sh file :#! /Bin/shrouteadd-net172.18.2.0netmask255.255.255.0deveth0routeadd-net172.18.1.0netmask255.255 two NICs:
Eth0 = intranet 172.18.1.X
Eth1 = Internet 211.139.169.X
1. create the/root/wtrouter. sh file:
#! /Bin/sh
Route add-net 172.18.2.0 netmask 255.255.255.0 dev eth0
Route add-net 172.18.1.0 netmask 255.255.255.0 dev eth0
Route add-net 192.168.1.0 netmask 255.255.255.0 dev eth0
Route add-net 192.168.0.0 netmask 255.255.255.0 dev eth0
Route add-net 211.139.169.0 netmask 255.255.255.0 dev eth1
Route add default gw 211.139.169.X
2. find the/etc/rc. d/rc. local file, edit it, and add sh/root/wtrouter. sh.
3. restart reboot and check the route in netstat-rn. OK.
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