RedHat 6.1 NAT 十分钟内设定完成参考文件

/ns/wz/net/data/20020311140724.htm

要顺利完成 NAT 必要条件:
1.已经安装两块网卡,并且在 Linux 中已经驱动
2.您已经将第一片卡(eth0)网络配置设好了!

附注:

1.登入成 root 才可以执行安装!

2.我们在这范例是设定eth1当对内的网关(Gateway)

3.eth1 组态设定:
IP: 172.20.1.254
NETMASK: 255.255.0.0
采用 B CLASS!

4.您其他的Client端电脑想要对外连线,
IP范围可以为 172.20.x.x (当然x不可以超过254罗!)
(172.20.1.254不可使用!因为已经当GATEWAY了!)
NETMASK: 255.255.0.0
GATEWAY: 172.20.1.254
DNS: 网路上任何一台DNS皆可! 例: 168.95.1.1
这样就可以上网啦!

废话不多说,我们开始设置吧!
首先要设定IP:

Step 1:
(1)echo \'1\' > /proc/sys/net/ipv4/ip_forward

Step 2:
(1)编辑 /etc/sysconfig/network 档案,
(2)将 FORWARD_IPV4 这一项改 \'true\'。

Step 3:
(1)编辑 /etc/sysconfig/network-scripts/ifcfg-eth1 档,
如果这个档案不存在,请确定您的系统有抓到第二张网路卡!
(2)将 IPADDR 这一项改 \'172.20.1.254\'
(3)将 NETMASK 这一项改 \'255.255.0.0\'
(4)将 ONBOOT 这一项改 \'yes\'
(5)存档离开!

Step 4:
(1)编辑 /etc/rc.d/init.d/ipchains 档案,
将以下档案内容 copy 到 /etc/rc.d/init.d/ipchains 里面!
-----------------Start of the file-------------------
#! /bin/sh
#
# chkconfig: - 55 55
# description: Written by Guang-Lin Liu. (leo@news.ncit.edu.tw)

# Source function library.
... /etc/rc.d/init.d/functions

# Get config.
... /etc/sysconfig/network

# Check that networking is up.
if [ ${NETWORKING} = "yes" ]
then
/sbin/depmod -a
/sbin/modprobe ip_masq_ftp
/sbin/modprobe ip_masq_raudio
/sbin/modprobe ip_masq_irc
/sbin/modprobe ip_masq_autofw
/sbin/modprobe ip_masq_cuseeme
/sbin/modprobe ip_masq_portfw
/sbin/modprobe ip_masq_quake
/sbin/modprobe ip_masq_vdolive
/sbin/modprobe ip_masq_user
/sbin/modprobe ip_masq_mfw
/sbin/ipchains -P forward DENY
/sbin/ipchains -A forward -s 172.20.0.0/16 -j MASQ
exit 0
fi
------------------End of the file------------------

(2)chmod 755 /etc/rc.d/init.d/ipchains
(3)执行 /usr/sbin/setup 程式,选 \'System services\' 这一项.
找到 \'[ ] ipchains\' 按下空白键选取!选取之後应该变成
这样 \'[*] ipchains\'。选择\'OK\'再离开即可!
Step 5:
/sbin/shutdown -r now
重新开机吧!