Linux-自搭網(wǎng)關(guān)
在有外網(wǎng)機(jī)器上
#啟動iptables service iptables start chkconfig iptables on #偽裝請求 iptables -t nat -A POSTROUTING -s 10.1.0.0 /16 -j MASQUERADE #保存規(guī)則, 避免重啟丟失 /etc/init .d /iptables save #設(shè)置允許轉(zhuǎn)發(fā) sysctl -w net.ipv4.ip_forward=1 #允許轉(zhuǎn)發(fā) vi /etc/sysctl .conf 中加入 net.ipv4.ip_forward=1 然后保存 #查看現(xiàn)有nat規(guī)則 iptables -t nat --list |
在只有內(nèi)網(wǎng)的機(jī)器
#增加默認(rèn)路由, 需要先刪除老路由, 重啟后不需要 ip route add default via 10.1.5.11 或者: (重啟后不需要) route add default gw 10.1.5.11 eth0 route del default gw 10.1.5.1 #改網(wǎng)關(guān), 重啟后自動設(shè)置缺省路由 vi /etc/sysconfig/network-scripts/ifcfg-eth0 中將 gateway改為 10.1.5.11 ip route flush cache |
posted on 2013-01-10 00:01 Scud(飛云小俠) 閱讀(805) 評論(0) 編輯 收藏 所屬分類: 其他