這篇文章敘述在Ubuntu下架設一個非常簡單的NAT環境:
- eth0是一張連到網路的網卡
- eth1是一張進行NAT的網卡,其網路線連到另一台電腦的網卡(或一個Router)
- 首先,安裝shorewall和dnsmasq:
sudo aptitude install shorewall dnsmasq
- 調整/etc/network/interfaces,加上:
auto eth1
iface eth1 inet static
address 192.168.1.254
netmask 255.255.255.0 - sudo /etc/init.d/networking restart
- 複製shorewall的two interfaces範例:
cd /usr/share/doc/shorewall-common/examples/two-interfaces
sudo cp * /etc/shorewall/ - 修改 shorewall.conf: (7/22發現)
cd /etc/shorewall/
sudo gunzip shorewall.conf.gz
確定覆蓋檔案
sudo vim shorewall.conf
把STARTUP_ENABLED改成Yes - 用你喜歡的編輯器修改/etc/shorewall/rules,加上:
DNS/ACCEPT loc $FW - 選擇性:如果你希望你的Ubuntu仍然可以上網,修改/etc/shorewall/policy
把$FW net REJECT info 改成$FW net ACCEPT - 修改/etc/default/shorewall,把startup從0調成1
- sudo /etc/init.d/shorewall restart
- 修改/etc/dnsmasq.conf,加上:
interface=eth1
dhcp-range=192.168.1.1,192.168.1.100,12h - sudo /etc/init.d/dnsmasq restart