·þÎñÆ÷²ÉÓÃubuntu×÷Ϊ²Ù×÷ϵͳ£¬Á½¿éÍø¿¨£¬Ò»¿é½ÓÍâÍø£¨eth0£©£¬Ò»¿é½ÓÄÚÍø£¨eth1£©¡£²ÉÓÃshorewall×÷Ϊ·À»ðǽ¡£
ÅäÖÃÍø¿¨£º
sudo vi /etc/network/interfaces
ubuntuÏÂÉèÖÃshorewall·À»ðǽ
·þÎñÆ÷²ÉÓÃubuntu×÷Ϊ²Ù×÷ϵͳ£¬Á½¿éÍø¿¨£¬Ò»¿é½ÓÍâÍø£¨eth0£©£¬Ò»¿é½ÓÄÚÍø£¨eth1£©¡£²ÉÓÃshorewall×÷Ϊ·À»ðǽ¡£
ÅäÖÃÍø¿¨£º
sudo vi /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# This is a list of hotpluggable network interfaces.
# They will be activated automatically by the hotplug subsystem.
mapping hotplug
script grep
map eth0
# The primary network interface
iface eth0 inet static
address 192.168.2.250
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255
gateway 192.168.2.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 202.96.209.6
auto eth1
iface eth1 inet static
address 192.168.10.254
netmask 255.255.255.0
network 192.168.10.0
broadcast 192.168.10.255
1¡¢°²×°shorewall
sudo apt-get install shorewall
2¡¢¿½±´ÅäÖÃÎļþ
sudo cp /usr/share/shorewall/modules /etc/shorewall
sudo cp /usr/share/doc/shorewall/default-config/policy /etc/shorewall/
sudo cp /usr/share/doc/shorewall/default-config/nat /etc/shorewall/
sudo cp /usr/share/doc/shorewall/default-config/zones /etc/shorewall/
sudo cp /usr/share/doc/shorewall/default-config/maclist /etc/shorewall/
sudo cp /usr/share/doc/shorewall/default-config/blacklist /etc/shorewall/
sudo cp /usr/share/doc/shorewall/default-config/interfaces /etc/shorewall/interfaces
sudo cp /usr/share/doc/shorewall/default-config/rules /etc/shorewall/rules
sudo cp /usr/share/doc/shorewall/default-config/hosts /etc/shorewall/hosts
sudo cp /usr/share/doc/shorewall/default-config/masq /etc/shorewall/masq
3¡¢ÅäÖÃÍø¿¨
sudo vi /etc/shorewall/interfaces
ÔÚµ¹ÊýµÚ¶þÐУ¬Ò²¾ÍÊÇÔÚ ¡°#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE¡± ÕâÒ»ÐÐÖ®ºó¼ÓÉÏ£º
net eth0 detect
loc eth1 detect
4¡¢ÅäÖÃÍøÂç±ðÃû
sudo vi /etc/shorewall/zones
ÔÚµ¹ÊýµÚ¶þÐУ¬Ò²¾ÍÊÇÔÚ ¡°#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE¡± ÕâÒ»ÐÐÖ®ºó¼ÓÉÏ£º
net Net Internet
loc Local Local Networks
5¡¢ÅäÖÃIPαװ£¬Ò²¾ÍÊÇ͸Ã÷´úÀí
sudo vi /etc/shorewall/masq
ÔÚµ¹ÊýµÚ¶þÐУ¬Ò²¾ÍÊÇÔÚ ¡°#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE¡± ÕâÒ»ÐÐÖ®ºó¼ÓÉÏ£º
eth0 eth1
6¡¢ÅäÖòßÂÔ
sudo vi /etc/shorewall/policy
ÔÚ#LAST LINE -- DO NOT REMOVEÕâÒ»ÐÐ×îºó¼ÓÉÏ£º
loc net ACCEPT
net all DROP info
all all REJECT info
7¡¢ÅäÖ÷À»ðǽ¹æÔò
sudo vi /etc/shorewall/rules
ÔÚµ¹ÊýµÚ¶þÐУ¬Ò²¾ÍÊÇÔÚ ¡°#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE¡± ÕâÒ»Ðкó¼ÓÉÏ£º
#incoming traffic (ÓÉ internet È¥ firewall)
AllowSSH net fw
AllowDNS net fw
AllowWeb net fw
AllowSMB net fw
AllowNNTP net fw
AllowNTP net fw
AllowRdate net fw
AllowSMTP net fw
DropPing net fw
#outgoing traffic (ÓÉ firewall È¥ internet)
AllowWeb fw net
AllowDNS fw net
AllowSMTP fw net
AllowSMB fw net
AllowSMTP fw net
AllowNNTP fw net
AllowNTP fw net
AllowRdate fw net
AllowSSH fw net
#open special ports
ACCEPT net fw tcp 9980
8¡¢ÐÞ¸Ä shorewall.conf ×Ô¶¯¿ªÆô IP ת·¢
sudo gedit /etc/shorewall/shorewall.conf
²éÕÒµ½£º
IP_FORWARDING=Keep
ÐÞ¸ÄΪ£º
IP_FORWARDING=On
# ±£´æ¹Ø±ÕÎļþ
9¡¢ÐÞ¸Ä /etc/default/shorewall ×Ô¶¯ÔËÐзÀ»ðǽ
sudo vi /etc/default/shorewall
²éÕÒµ½£º
startup=0
ÐÞ¸ÄΪ£º
startup=1
10¡¢Æô¶¯·À»ðǽ
sudo shorewall start
11¡¢ÖÁ´Ë·À»ðǽÅäÖÃÍê³É¡£