1、环境
[root@yd-gw ~]# lsb_release -a
LSB Version: :core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 5.10 (Final)
Release: 5.10
Codename: Final
[root@yd-gw ~]# getconf LONG_BIT
32
2.配置IP/DNS等信息
外网:
# ifconfig eth0 | grep "inet addr"
inet addr:222.47.48.25 Bcast:222.47.48.63 Mask:255.255.255.192
内网:
# ifconfig eth1 | grep "inet addr"
inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0
DNS:
# cat /etc/resolv.conf
nameserver 222.47.62.142
nameserver 222.47.29.93
3.打开内核转发功能
echo 1 > /proc/sys/net/ipv4/ip_forward //网卡重启后会恢复为0,所以需要把如下参数更改为“1”
# cat /etc/sysctl.conf | grep ip_forward
net.ipv4.ip_forward = 0
4.配置NAT
# iptables -t nat -A POSTROUTING -s 192.168.1.0/255.255.255.0 -o eth0 -j SNAT --to-source 222.47.48.25
# iptables -D FORWARD 1
# /etc/init.d/iptables save
# /etc/init.d/iptables restart
本文出自 “方寸小山” 博客,请务必保留此出处http://63638790.blog.51cto.com/513514/1559409
原文地址:http://63638790.blog.51cto.com/513514/1559409