作者:
要順利完成 NAT 必要條件: 1.已經(jīng)安裝兩塊網(wǎng)卡,并且在 Linux 中已經(jīng)驅(qū)動(dòng) 2.您已經(jīng)將第一片卡(eth0)網(wǎng)絡(luò)配置設(shè)好了! 附注: 1.登入成 root 才可以執(zhí)行安裝! 2.我們?cè)谶@范例是設(shè)定eth1當(dāng)對(duì)內(nèi)的網(wǎng)關(guān)(Gateway) 3.eth1 組態(tài)設(shè)定: IP: 172.20.1.254 NETMASK: 255.255.0.0 采用 B CLASS! 4.您其他的Client端電腦想要對(duì)外連線, IP范圍可以為 172.20.x.x (當(dāng)然x不可以超過254羅!) (172.20.1.254不可使用!因?yàn)橐呀?jīng)當(dāng)GATEWAY了!) NETMASK: 255.255.0.0 GATEWAY: 172.20.1.254 DNS: 網(wǎng)路上任何一臺(tái)DNS皆可! 例: 168.95.1.1 這樣就可以上網(wǎng)啦! 廢話不多說,我們開始設(shè)置吧! 首先要設(shè)定IP: Step 1: (1)echo \'1\' > /proc/sys/net/ipv4/ip_forward Step 2: (1)編輯 /etc/sysconfig/network 檔案, (2)將 FORWARD_IPV4 這一項(xiàng)改 \'true\'。 Step 3: (1)編輯 /etc/sysconfig/network-scripts/ifcfg-eth1 檔, 如果這個(gè)檔案不存在,請(qǐng)確定您的系統(tǒng)有抓到第二張網(wǎng)路卡! (2)將 IPADDR 這一項(xiàng)改 \'172.20.1.254\' (3)將 NETMASK 這一項(xiàng)改 \'255.255.0.0\' (4)將 ONBOOT 這一項(xiàng)改 \'yes\' (5)存檔離開! Step 4: (1)編輯 /etc/rc.d/init.d/ipchains 檔案, 將以下檔案內(nèi)容 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)執(zhí)行 /usr/sbin/setup 程式,選 \'System services\' 這一項(xiàng). 找到 \'[ ] ipchains\' 按下空白鍵選取!選取之後應(yīng)該變成 這樣 \'[*] ipchains\'。選擇\'OK\'再離開即可! Step 5: /sbin/shutdown -r now 重新開機(jī)吧!
|
|