標籤:linux nat 實現上網
1、環境
[[email protected] ~]# 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
[[email protected] ~]# 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
linux NAT 配置實現上網