Shorewall FAQsShorewall CommunityTomEastep2001-2009Thomas M. EastepPermission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License, Version
1.2 or any later version published by the Free Software Foundation; with
no Invariant Sections, with no Front-Cover, and with no Back-Cover
Texts. A copy of the license is included in the section entitled GNU Free Documentation License.This article applies to Shorewall 4.3 and
later. If you are running a version of Shorewall earlier than Shorewall
4.3.0 then please see the documentation for that
release.Installing ShorewallWhere do I find Step by Step Installation and Configuration
Instructions?Answer: Check out the QuickStart Guides.(FAQ 37) I just installed Shorewall on Debian and the
/etc/shorewall directory is almost empty!!!Answer:Once you have installed the .deb package and before you attempt
to configure Shorewall, please heed the advice of Lorenzo Martignoni,
former Shorewall Debian Maintainer:For more information about Shorewall usage on Debian
system please look at /usr/share/doc/shorewall-common/README.Debian
provided by [the] shorewall-common Debian package.If you install using the .deb, you will find that your /etc/shorewall directory is almost empty.
This is intentional. The released configuration file skeletons may be
found on your system in the directory /usr/share/doc/shorewall-common/default-config.
Simply copy the files you need from that directory to /etc/shorewall and modify the
copies.(FAQ 37a) I just installed Shorewall on Debian and I can't find
the sample configurations.Answer: Beginning with
Shorewall 4.0, the samples are in the shorewall-common package and are
installed in /usr/share/doc/shorewall-common/examples/.(FAQ 75) I can't find the Shorewall 4.x shorewall-common RPM.
Where is it?Answer: If you use Simon Matter's
Redhat/Fedora/CentOS rpms, be aware that Simon calls the
shorewall-common RPM
shorewall. So you should download and install the
appropriate shorewall-4.x.y RPM from his
site.Upgrading Shorewall(FAQ 66) I'm trying to upgrade to Shorewall 4.x; where is the
'shorewall' package?Answer: Please see the upgrade issues.(FAQ 66a) I'm trying to upgrade to Shorewall 4.x; do I have to
uninstall the 'shorewall' package?Answer: Please see the upgrade issues.(FAQ 66b) I'm trying to upgrade to Shorewall 4.x: which of
these packages do I need to install?Answer: Please see the upgrade issues.(FAQ 76) I just upgraded my Debian (Ubuntu, Kubuntu, ...) system
and now masquerading doesn't work? What happened?Answer: This happens to people
who ignore our advice and
allow the installer to replace their working
/etc/shorewall/shorewall.conf with one that has
default settings. Failure to forward traffic (such as during masqueraded
net access from a local network) usually means that /etc/shorewall/shorewall.conf
contains the Debian default setting IP_FORWARDING=Keep; it should be
IP_FORWARDING=On.Port Forwarding (Port Redirection)(FAQ 1) I want to forward UDP port 7777 to my personal PC with IP
address 192.168.1.5. I've looked everywhere and can't find how to do
it.Answer: The format of a
port-forwarding rule to a local system is as follows:#ACTION SOURCE DEST PROTO DEST PORT
DNAT net loc:local-IP-address[:local-port] protocolport-numberSo to forward UDP port 7777 to internal system 192.168.1.5, the
rule is:#ACTION SOURCE DEST PROTO DEST PORT
DNAT net loc:192.168.1.5 udp 7777If you want to forward requests directed to a particular address (
external-IP ) on your firewall to an internal
system:#ACTION SOURCE DEST PROTO DEST PORT SOURCE ORIGINAL
# PORT DEST.
DNAT net loc:local-IP-address>[:local-port] protocolport-number - external-IPIf you want to forward requests from a particular Internet address
( address ):#ACTION SOURCE DEST PROTO DEST PORT SOURCE ORIGINAL
# PORT DEST.
DNAT net:address loc:local-IP-address[:local-port] protocolport-number -Finally, if you need to forward a range of ports, in the DEST PORT
column specify the range as
low-port:high-port.(FAQ 1a) Okay -- I followed those instructions but it doesn't
workAnswer: That is usually the
result of one of four things:You are trying to test from inside your firewall (no, that
won't work -- see ).You have a more basic problem with your local system (the
one that you are trying to forward to) such as an incorrect
default gateway (it must be set to the IP address of your
firewall's internal interface; if that isn't possible for some
reason, see FAQ 1f).Your ISP is blocking that particular port inbound or, for
TCP, your ISP is dropping the outbound SYN,ACK response.You are running Mandriva Linux prior to 10.0 final and have
configured Internet Connection Sharing. In that case, the name of
your local zone is 'masq' rather than 'loc' (change all instances
of 'loc' to 'masq' in your rules). You may want to consider
re-installing Shorewall in a configuration which matches the
Shorewall documentation. See the two-interface QuickStart Guide for
details.(FAQ 1b) I'm still having problems with port forwardingAnswer: To further diagnose
this problem:As root, type shorewall reset ("shorewall-lite reset", if you are
running Shorewall Lite). This clears all Netfilter
counters.Try to connect to the redirected port from an external
host.As root type shorewall show nat ("shorewall-lite show nat", if you are
running Shorewall Lite).Locate the appropriate DNAT rule. It will be in a chain
called <source zone>_dnat
(net_dnat in the above examples).Is the packet count in the first column non-zero? If so, the
connection request is reaching the firewall and is being
redirected to the server. In this case, the problem is usually a
missing or incorrect default gateway setting on the local system
(the system you are trying to forward to -- its default gateway
should be the IP address of the firewall's interface to that
system).If the packet count is zero:the connection request is not reaching your server
(possibly it is being blocked by your ISP); oryou are trying to connect to a secondary IP address on
your firewall and your rule is only redirecting the primary IP
address (You need to specify the secondary IP address in the
ORIG. DEST. column in your DNAT rule);
oryour DNAT rule doesn't match the connection request in
some other way. In that case, you may have to use a packet
sniffer such as tcpdump or ethereal to further diagnose the
problem.If the packet count is non-zero, check your log to see if
the connection is being dropped or rejected. If it is, then you
may have a zone definition problem such that the server is in a
different zone than what is specified in the DEST column. At a
root prompt, type "shorewall show zones"
("shorewall-lite show zones") then be sure that
in the DEST column you have specified the first zone in the list that matches
OUT=<dev> and DEST= <ip>from the REJECT/DROP log
message.If everything seems to be correct according to these tests
but the connection doesn't work, it may be that your ISP is
blocking SYN,ACK responses. This technique allows your ISP to
detect when you are running a server (usually in violation of your
service agreement) and to stop connections to that server from
being established.(FAQ 1c) From the Internet, I want to connect to port 1022 on
my firewall and have the firewall forward the connection to port 22 on
local system 192.168.1.3. How do I do that?Answer:In
/etc/shorewall/rules:#ACTION SOURCE DEST PROTO DEST PORT
DNAT net loc:192.168.1.3:22 tcp 1022(FAQ 1d) I have a web server in my DMZ and I use port
forwarding to make that server accessible from the Internet. That
works fine but when my local users try to connect to the server using
the Firewall's external IP address, it doesn't work.Answer: See FAQ 2b.(FAQ 1e) In order to discourage brute force attacks I would
like to redirect all connections on a non-standard port (4104) to port
22 on the router/firewall. I notice that setting up a REDIRECT rule
causes the firewall to open both ports 4104 and 22 to connections from
the net. Is it possible to only redirect 4104 to the localhost port 22
and have connection attempts to port 22 from the net dropped?Answer courtesy of Ryan: Assume
that the IP address of your local firewall interface is 192.168.1.1.
If you configure SSHD to only listen on that interface and add the
following rule then from the net, you will have 4104 listening, from
your LAN, port 22.#ACTION SOURCE DEST PROTO DEST PORT(S)
DNAT net fw:192.168.1.1:22 tcp 4104(FAQ 1f) Why must the server that I port forward to have it's
default gateway set to my Shorewall system's IP address?Answer: Let's take an example.
Suppose thatYour Shorewall firewall's external IP address is
206.124.146.176 (eth0) and its internal IP address is 192.168.1.1
(eth1).You have another gateway router with external IP address
130.252.100.109 and internal IP address 192.168.1.254.You have an FTP server behind both routers with IP address
192.168.1.4The FTP server's default gateway is through the second
router (192.168.1.254).You have this rule on the Shorewall system:#ACTION SOURCE DEST PROTO DEST PORT SOURCE ORIGINAL
# PORT DEST.
DNAT net loc:192.168.1.4 tcp 21 - 206.124.146.176Internet host 16.105.221.4 issues the command ftp
206.124.146.176This results in the following set of events:16.105.221.4 sends a TCP SYN packet to 206.124.146.176
specifying destination port 21.The Shorewall box rewrites the destination IP address to
192.168.1.4 and forwards the packet.The FTP server receives the packet and accepts the
connection, generating a SYN,ACK packet back to 16.105.221.4.
Because the server's default gateway is through the second router,
it sends the packet to that router.At this point, one of two things can happen. Either the second
router discards or rejects the packet; or, it rewrites the source IP
address to 130.252.100.109 and forwards the packet back to
16.105.221.4. Regardless of which happens, the connection is doomed.
Clearly if the packet is rejected or dropped, the connection will not
be successful. But even if the packet reaches 16.105.221.4, that host
will reject it since it's SOURCE IP address (130.252.100.109) doesn't
match the DESTINATION IP ADDRESS (206.124.146.176) of the original SYN
packet.The best way to work around this problem is to change the
default gateway on the FTP server to the Shorewall system's internal
IP address (192.168.1.1). But if that isn't possible, you can work
around the problem with the following ugly hack in
/etc/shorewall/masq:#INTERFACE SOURCE ADDRESS PROTO PORT
eth1:192.168.1.4 0.0.0.0/0 192.168.1.1 tcp 21This rule has the undesirable side effect that it makes all FTP
connections from the net appear to the FTP server as if they
originated on the Shorewall system. But it will force the FTP server
to reply back through the Shorewall system who can then rewrite the
SOURCE IP address in the responses properly.(FAQ 1g) I would like to redirect port 80 on my public IP
address (206.124.146.176) to port 993 on Internet host
66.249.93.111Answer: This requires a vile
hack similar to the one in FAQ 2. Assuming
that your Internet zone is named net and connects
on interface eth0:In /etc/shorewall/rules:#ACTION SOURCE DEST PROTO DEST PORT SOURCE ORIGINAL
# PORT DEST.
DNAT net net:66.249.93.111:993 tcp 80 - 206.124.146.176In /etc/shorewall/interfaces, specify the
routeback option on
eth0:#ZONE INTERFACE BROADCAST OPTIONS
net eth0 detect routebackAnd in /etc/shorewall/masq;#INTERFACE SOURCE ADDRESS PROTO PORT
eth0:66.249.93.111 0.0.0.0/0 206.124.146.176 tcp 993Like the hack in FAQ 2, this one results in all forwarded
connections looking to the server (66.249.93.11) as if they originated
on your firewall (206.124.146.176).(FAQ 1h) How do I set shorewall to allow ssh on port 9022 from
net? SSHD is listening on port 22.Answer: Use this rule.#ACTION SOURCE DEST PROTO DEST
# PORT(S)
REDIRECT net 22 tcp 9022(FAQ 30) I'm confused about when to use DNAT rules and when to
use ACCEPT rules.Answer: It would be a good idea
to review the QuickStart
Guide appropriate for your setup; the guides cover this topic in
a tutorial fashion. DNAT rules should be used for connections that need
to go the opposite direction from SNAT/MASQUERADE. So if you masquerade
or use SNAT from your local network to the Internet then you will need
to use DNAT rules to allow connections from the Internet to your local
network. You also want to use DNAT rules when you intentionally want to
rewrite the destination IP address or port number. In all other cases,
you use ACCEPT unless you need to hijack connections as they go through
your firewall and handle them on the firewall box itself; in that case,
you use a REDIRECT rule.(FAQ 8) I have several external IP addresses and use
/etc/shorewall/nat to associate them with systems in my DMZ. When I add
a DNAT rule, say for ports 80 and 443, Shorewall redirects connections
on those ports for all of my addresses. How can I restrict DNAT to only
a single address?Answer: Specify the external
address that you want to redirect in the ORIGINAL DEST column.Example:#ACTION SOURCE DEST PROTO DEST PORT SOURCE ORIGINAL
# PORT DEST.
DNAT net net:192.168.4.22 tcp 80,443 - 206.124.146.178(FAQ 38) Where can I find more information about DNAT?Answer: Ian Allen has written a
Paper about DNAT and
Linux.(FAQ 48) How do I Set up Transparent HTTP Proxy with
Shorewall?Answer: See Shorewall_Squid_Usage.html.DNS and Port Forwarding/NAT(FAQ 2) I port forward www requests to www.mydomain.com (IP
130.151.100.69) to system 192.168.1.5 in my local network. External
clients can browse http://www.mydomain.com but internal clients
can't.Answer: I have two objections to
this setup.Having an Internet-accessible server in your local network is
like raising foxes in the corner of your hen house. If the server is
compromised, there's nothing between that server and your other
internal systems. For the cost of another NIC and a cross-over
cable, you can put your server in a DMZ such that it is isolated
from your local systems - assuming that the Server can be located
near the Firewall, of course :-)The accessibility problem is best solved using
Split DNS (either use a separate DNS server for local
clients or use Bind
Version 9 views on your main name server)
such that www.mydomain.com resolves to 130.141.100.69 externally and
192.168.1.5 internally. That's what I do here at shorewall.net for
my local systems that use one-to-one NAT.So the best and most secure way to solve this problem is to move
your Internet-accessible server(s) to a separate LAN segment with it's
own interface to your firewall and follow FAQ
2b. That way, your local systems are still safe if your server
gets hacked and you don't have to run a split DNS configuration
(separate server or Bind 9 views).If physical limitations make it impractical to segregate your
servers on a separate LAN, the next best solution it to use Split DNS.
Before you complain "It's too hard to set up split DNS!", check
here.But if you are the type of person who prefers quick and dirty
hacks to "doing it right", then proceed as described below.All traffic redirected through use of this hack will look to
the server as if it originated on the firewall rather than on the
original client! So the server's access logs will be useless for
determining which local hosts are accessing the server.Assuming that your external interface is eth0 and your internal
interface is eth1 and that eth1 has IP address 192.168.1.254 with subnet
192.168.1.0/24, then:In /etc/shorewall/interfaces:#ZONE INTERFACE BROADCAST OPTIONS
loc eth1 detect routebackIn /etc/shorewall/masq:#INTERFACE SOURCE ADDRESS PROTO PORT(S)
eth1:192.168.1.5 eth1 192.168.1.254 tcp wwwIn /etc/shorewall/rules:#ACTION SOURCE DEST PROTO DEST PORT SOURCE ORIGINAL
# PORT DEST.
DNAT loc loc:192.168.1.5 tcp www - 130.151.100.69That rule only works of course if you have a static external
IP address. If you have a dynamic IP address then include this in
/etc/shorewall/params (or your
<export directory>/init file if you are
using Shorewall Lite on the firewall system):ETH0_IP=`find_first_interface_address eth0`and make your DNAT rule:#ACTION SOURCE DEST PROTO DEST PORT SOURCE ORIGINAL
# PORT DEST.
DNAT loc loc:192.168.1.5 tcp www - $ETH0_IPUsing this technique, you will want to configure your
DHCP/PPPoE/PPTP/… client to automatically restart Shorewall each
time that you get a new IP address.(FAQ 2a) I have a zone Z with an RFC1918 subnet
and I use one-to-one NAT to assign non-RFC1918 addresses to hosts in
Z. Hosts in Z cannot communicate with each other using their external
(non-RFC1918 addresses) so they can't access each other using their
DNS names.If the ALL INTERFACES column in /etc/shorewall/nat is empty or
contains Yes, you will also see log messages like the
following when trying to access a host in Z from another host in Z
using the destination host's public address:Oct 4 10:26:40 netgw kernel:
Shorewall:FORWARD:REJECT:IN=eth1 OUT=eth1 SRC=192.168.118.200
DST=192.168.118.210 LEN=48 TOS=0x00 PREC=0x00 TTL=127 ID=1342 DF
PROTO=TCP SPT=1494 DPT=1491 WINDOW=17472 RES=0x00 ACK SYN URGP=0Answer: This is another problem
that is best solved using split DNS. It allows both external and
internal clients to access a NATed host using the host's DNS
name.Another good way to approach this problem is to switch from
one-to-one NAT to Proxy ARP. That way, the hosts in Z have non-RFC1918
addresses and can be accessed externally and internally using the same
address.If you don't like those solutions and prefer, incredibly, to
route all Z->Z traffic through your firewall then:Set the routeback option on the interface to Z.Set the ALL INTERFACES column in the nat file to
Yes.Example:Zone: dmz, Interface: eth2, Subnet: 192.168.2.0/24, Address: 192.168.2.254In /etc/shorewall/interfaces:#ZONE INTERFACE BROADCAST OPTIONS
dmz eth2 192.168.2.255 routebackIn /etc/shorewall/nat, be sure that you
have Yes in the ALL INTERFACES column.In /etc/shorewall/masq:#INTERFACE SOURCE ADDRESS
eth2 eth2 192.168.2.254Like the silly hack in FAQ 2 above, this will make all
dmz->dmz traffic appear to originate on the firewall.(FAQ 2b) I have a web server in my DMZ and I use port
forwarding to make that server accessible from the Internet as
www.mydomain.com. That works fine but when my local users try to
connect to www.mydomain.com, it doesn't work.Answer: Let's assume the
following:External IP address is 206.124.146.176 on eth0 (www.mydomain.com).Server's IP address is 192.168.2.4You can enable access to the server from your local network
using the firewall's external IP address by adding this rule:#ACTION SOURCE DEST PROTO DEST PORT(S) SOURCE ORIGINAL
# PORT DEST
DNAT loc dmz:192.168.2.4 tcp 80 - 206.124.146.176If your external IP address is dynamic, then you must do the
following:In /etc/shorewall/params (or in your
<export directory>/init file if you are
using Shorewall Lite on the firewall system):ETH0_IP=`find_first_interface_address eth0`and make your DNAT rule:#ACTION SOURCE DEST PROTO DEST PORT SOURCE ORIGINAL
# PORT DEST.
DNAT loc dmz:192.168.2.4 tcp 80 - $ETH0_IPWith dynamic IP addresses, you probably don't want to use
shorewall[-lite]
save and shorewall[-lite]
restore.(FAQ 2c) I tried to apply the answer to FAQ 2 to my external
interface and the net zone and it didn't work. Why?Answer: Did you set IP_FORWARDING=On in
shorewall.conf?Blacklisting(FAQ 63) I just blacklisted IP address 206.124.146.176 and I can
still ping it. What did I do wrong?Answer: Nothing.Blacklisting an IP address blocks incoming traffic from that IP
address. And if you set BLACKLISTNEWONLY=Yes in
shorewall.conf, then only new connections from that address are disallowed; traffic from
that address that is part of an established connection (such as ping
replies) is allowed.(FAQ 84) I put some IPs in the blacklist file in /etc/shorewall
to block the ips but i'm still getting reports from PSAD from those ips
saying they're port scanning. Shouldn't being on the blacklist drop all
packets from those ips?Answer: You probably forgot to
specify the blacklist option for your
external interface(s) in
/etc/shorewall/interfaces.Netmeeting/MSN(FAQ 3) I want to use Netmeeting or MSN Instant Messenger with
Shorewall. What do I do?Answer: There is an H.323
connection tracking/NAT module that helps with Netmeeting. Note
however that one of the Netfilter developers recently posted the
following:
> I know PoM -ng is going to address this issue, but till it is ready, and
> all the extras are ported to it, is there any way to use the h.323
> conntrack module kernel patch with a 2.6 kernel?
> Running 2.6.1 - no 2.4 kernel stuff on the system, so downgrade is not
> an option... The module is not ported yet to 2.6, sorry.
> Do I have any options besides a gatekeeper app (does not work in my
> network) or a proxy (would prefer to avoid them)?
I suggest everyone to setup a proxy (gatekeeper) instead: the module is
really dumb and does not deserve to exist at all. It was an excellent tool
to debug/develop the newnat interface.
Look here for a solution for MSN IM
but be aware that there are significant security risks involved with
this solution. Also check the Netfilter mailing list archives at http://www.netfilter.org.Open Ports(FAQ 51) How do I Open Ports in Shorewall?Answer: No one who has installed
Shorewall using one of the Quick Start Guides should
have to ask this question.Regardless of which guide you used, all outbound communication is
open by default. So you do not need to 'open ports' for output.For input:If you installed using the Standalone Guide, then please
re-read this
section.If you installed using the Two-interface Guide, then please
re-read these sections: Port
Forwarding (DNAT), and Other ConnectionsIf you installed using the Three-interface Guide, then please
re-read these sections: Port
Forwarding (DNAT) and Other ConnectionsIf you installed using the Shorewall Setup Guide then
you had better read the guide again -- you clearly missed a
lot.Also please see the Port Forwarding
section of this FAQ.(FAQ 4) I just used an online port scanner to check my firewall
and it shows some ports as closed rather than
blocked. Why?Answer: The default Shorewall
setup invokes the Drop action prior to
enforcing a DROP policy and the default policy to all zones from the
Internet is DROP. The Drop action is defined in
/usr/share/shorewall/action.Drop which in turn
invokes the Auth macro (defined in
/usr/share/shorewall/macro.Auth) specifying the
REJECT action (i.e., Auth(REJECT)). This is necessary to prevent
outgoing connection problems to services that use the
Auth mechanism for identifying requesting users. That is
the only service which the default setup rejects.If you are seeing closed TCP ports other than 113 (auth) then
either you have added rules to REJECT those ports or a router outside of
your firewall is responding to connection requests on those
ports.(FAQ 4a) I just ran an nmap UDP scan of my firewall and it
showed 100s of ports as open!!!!Answer: Take a deep breath and
read the nmap man page section about UDP scans. If nmap gets nothing back from your firewall then it reports
the port as open. If you want to see which UDP ports are really open,
temporarily change your net->all policy to REJECT, restart
Shorewall and do the nmap UDP scan again.(FAQ 4b) I have a port that I can't close no matter how I
change my rules.I had a rule that allowed telnet from my local network to my
firewall; I removed that rule and restarted Shorewall but my telnet
session still works!!!Answer: Rules only govern the
establishment of new connections. Once a connection is established
through the firewall it will be usable until disconnected (tcp) or
until it times out (other protocols). If you stop telnet and try to
establish a new session your firewall will block that attempt.(FAQ 4c) How do I use Shorewall with PortSentry?Answer: Here's a writeup describing a
nice integration of Shorewall and PortSentry.Connection ProblemsWhy are these packets being Dropped/Rejected? How do I decode
Shorewall log messages?Please see FAQ 17.(FAQ 5) I've installed Shorewall and now I can't ping through the
firewallAnswer: For a complete
description of Shorewall ping management, see this page.(FAQ 15) My local systems can't see out to the netAnswer: Every time I read
systems can't see out to the net, I wonder where the
poster bought computers with eyes and what those computers will
see when things are working properly. That aside, the
most common causes of this problem are:The default gateway on each local system isn't set to the IP
address of the local firewall interface.The entry for the local network in the
/etc/shorewall/masq file is wrong or
missing.The DNS settings on the local systems are wrong or the user is
running a DNS server on the firewall and hasn't enabled UDP and TCP
port 53 from the local net to the firewall or from the firewall to
the Internet.Forwarding is not enabled (This is often the problem for
Debian users). Enter this command:cat /proc/sys/net/ipv4/ip_forwardIf the value displayed is 0 (zero) then set IP_FORWARDING=On in
/etc/shorewall/shorewall.conf and restart
Shorewall.(FAQ 29) FTP Doesn't WorkAnswer: See the Shorewall and FTP page.(FAQ 33) From clients behind the firewall, connections to some
sites fail. Connections to the same sites from the firewall itself work
fine. What's wrong.Answer: Most likely, you need to
set CLAMPMSS=Yes in /etc/shorewall/shorewall.conf.(FAQ 35) I have two Ethernet interfaces to my local network which
I have bridged. When Shorewall is started, I'm unable to pass traffic
through the bridge. I have defined the bridge interface (br0) as the
local interface in /etc/shorewall/interfaces; the
bridged Ethernet interfaces are not defined to Shorewall. How do I tell
Shorewall to allow traffic through the bridge?Answer: Add the
routeback option to br0 in /etc/shorewall/interfaces.For more information on this type of configuration, see the Shorewall Simple Bridge
documentation.(FAQ 64) I just upgraded my kernel to 2.6.20 and my
bridge/firewall stopped working. What is wrong?Answer: In kernel 2.6.20, the
Netfilter physdev match feature was changed such
that it is no longer capable of matching the output device of
non-bridged traffic. You will see messages such as the following in your
log:Apr 20 15:03:50 wookie kernel: [14736.560947] physdev match: using --physdev-out in the OUTPUT, FORWARD and POSTROUTING chains for
non-bridged traffic is not supported anymore.This kernel change, while necessary, means that Shorewall zones
may no longer be defined in terms of bridge ports. See the Shorewall-perl bridging
documentation for information about how to configure
bridge/firewalls.Following the instructions in the new bridging documentation
will not prevent the above message from being issued.Logging(FAQ 6) Where are the log messages written and how do I change
the destination?Answer: NetFilter uses the
kernel's equivalent of syslog (see man syslog) to log
messages. It always uses the LOG_KERN (kern) facility (see man
openlog) and you get to choose the log level (again, see
man syslog) in your policies and
rules. The
destination for messages logged by syslog is controlled by
/etc/syslog.conf (see man
syslog.conf). When you have changed
/etc/syslog.conf, be sure to restart syslogd (on a
RedHat system, service syslog restart).By default, older versions of Shorewall rate-limited log messages
through settings in
/etc/shorewall/shorewall.conf -- If you want to log
all messages, set:LOGLIMIT=""
LOGBURST=""It is also possible to set up
Shorewall to log all of its messages to a separate file.(FAQ 6a) Are there any log parsers that work with
Shorewall?Answer: Here are several links
that may be helpful:http://www.shorewall.net/pub/shorewall/parsefw/http://aaron.marasco.com/linux.htmlhttp://cert.uni-stuttgart.de/projects/fwlogwatchhttp://www.logwatch.orgI personally use Logwatch. It emails me a report
each day from my various systems with each report summarizing the
logged activity on the corresponding system. I use the brief report
format; here's a sample:
--------------------- iptables firewall Begin ------------------------
Dropped 111 packets on interface eth0
From 58.20.162.142 - 5 packets to tcp(1080)
From 62.163.19.50 - 1 packet to udp(6348)
From 66.111.45.60 - 9 packets to tcp(192)
From 69.31.82.50 - 18 packets to tcp(3128)
From 72.232.183.102 - 2 packets to tcp(3128)
From 82.96.96.3 - 6 packets to tcp(808,1080,1978,7600,65506)
From 128.48.51.209 - 5 packets to tcp(143)
From 164.77.223.150 - 12 packets to tcp(873)
From 165.233.109.23 - 8 packets to tcp(22)
From 202.99.172.175 - 4 packets to udp(2,4081)
From 206.59.41.101 - 2 packets to tcp(5900)
From 217.91.30.224 - 24 packets to tcp(873)
From 218.87.47.114 - 6 packets to tcp(3128)
From 220.110.219.234 - 4 packets to tcp(22)
From 220.133.116.173 - 5 packets to tcp(3128)
---------------------- iptables firewall End -------------------------
(FAQ 6b) DROP messages on port 10619 are flooding the logs with
their connect requests. Can I exclude these error messages for this
port temporarily from logging in Shorewall?Answer: Temporarily add the
following rule:#ACTION SOURCE DEST PROTO DEST PORT(S)
DROP net fw udp 10619Alternatively, if you do not set BLACKLIST_LOGLEVEL and you have
specifed the 'blacklist' option on your external interface in
/etc/shorewall/interfaces, then you can blacklist
the port. In /etc/shorewall/blacklist:#ADDRESS/SUBNET PROTOCOL PORT
- udp 10619(FAQ 6d) Why is the MAC address in Shorewall log messages so
long? I thought MAC addresses were only 6 bytes in length.Answer: What is labeled as the
MAC address in a Netfilter (Shorewall) log message is actually the
Ethernet frame header. It contains:the destination MAC address (6 bytes)the source MAC address (6 bytes)the Ethernet frame type (2 bytes)ExampleMAC=00:04:4c:dc:e2:28:00:b0:8e:cf:3c:4c:08:00Destination MAC address = 00:04:4c:dc:e2:28Source MAC address = 00:b0:8e:cf:3c:4cEthernet Frame Type = 08:00 (IP Version 4)(FAQ 16) Shorewall is writing log messages all over my console
making it unusable!Answer:Just to be clear, it is not Shorewall that is writing all over
your console. Shorewall issues a single log message during each
start, restart,
stop, etc. It is rather the klogd daemon that is
writing messages to your console. Shorewall itself has no control over
where a particular class of messages are written. See the Shorewall logging
documentation.The max log level to be sent to the console is available in
/proc/sys/kernel/printk:teastep@ursa:~$ cat /proc/sys/kernel/printk
6 6 1 7
teastep@ursa:~$ The first number determines the maximum log
level (syslog priority) sent to the console. Messages with priority
less than this number are sent to the
console. On the system shown in the example above, priorities 0-5 are
sent to the console. Since Shorewall defaults to using 'info' (6), the
Shorewall-generated Netfilter rule set will generate log messages that
will not appear on the console.The second number is the default log level for kernel printk()
calls that do not specify a log level.The third number specifies the minimum console log level while the
fourth gives the default console log level.If, on your system, the first number is 7 or greater, then the
default Shorewall configurations will cause messages to be written to
your console. The simplest solution is to add this to your
/etc/sysctl.conf file:kernel.printk = 4 4 1 7thensysctl -p /etc/sysctl.conf(FAQ 16a) Why can't I see any Shorewall messages in
/var/log/messages?Some people who ask this question report that the only Shorewall
messages that they see in /var/log/messages are
'started', 'restarted' and 'stopped' messages.Answer: First of all, it is
important to understand that Shorewall itself does not control where
Netfilter log messages are written. The LOGFILE setting in
shorewall.conf simply tells the
/sbin/shorewall[-lite] program where to look for
the log. Also, it is important to understand that a log level of
"debug" will generally cause Netfilter messages to be written to fewer
files in /var/log than a log
level of "info". The log level does not control the number of log
messages or the content of the messages.The actual log file where Netfilter messages are written is not
standardized and will vary by distribution and distribution version.
But anytime you see no logging, it's time to look outside the
Shorewall configuration for the cause. As an example, recent
SUSE releases use syslog-ng by default and
write Shorewall messages to
/var/log/firewall.Please see the Shorewall
logging documentation for further information.(FAQ 17) Why are these packets being Dropped/Rejected? How do I
decode Shorewall log messages?Answer: Logging of
dropped/rejected packets occurs out of a number of chains (as indicated
in the log message) in Shorewall:man1918 or logdropThe destination address is listed in
/usr/share/shorewall/rfc1918 with a logdrop target -- see /usr/share/shorewall/rfc1918.rfc1918 or logdropThe source or destination address is listed in
/usr/share/shorewall/rfc1918 with a logdrop target -- see /usr/share/shorewall/rfc1918.If you see packets being dropped in the rfc1918 chain and
neither the source nor the destination IP address is reserved by
RFC 1918, that usually means that you have a old
rfc1918 file in /etc/shorewall (this problem most
frequently occurs if you are running Debian or one if its
derivatives). The rfc1918 file used to
include bogons as well as the three ranges reserved by RFC 1918
and it resided in /etc/shorewall. The file now only
includes the three RFC 1918 ranges and it resides in /usr/share/shorewall. Remove the
stale rfc1918 file in /etc/shorewall.all2zone, zone2all
or all2allYou have a policy
that specifies a log level and this packet is being logged under
that policy. If you intend to ACCEPT this traffic then you need a
rule to that
effect.Packets logged out of these chains may have a source and/or
destination that is not in any defined zone (see the output of
shorewall[-lite] show zones). Remember that
zone membership involves both a firewall interface and an ip
address.zone12zone2Either you have a policy for
zone1 to zone2 that
specifies a log level and this packet is being logged under that
policy or this packet matches a rule that includes a
log level.@source2destYou have a policy for traffic from
source to dest that
specifies TCP connection rate limiting (value in the LIMIT:BURST
column). The logged packet exceeds that limit and was dropped.
Note that these log messages themselves are severely rate-limited
so that a syn-flood won't generate a secondary DOS because of
excessive log message. These log messages were added in Shorewall
2.2.0 Beta 7.interface_mac or
interface_recThe packet is being logged under the maclistinterface
option.blacklistThe packet is being logged because the source IP is
blacklisted in the /etc/shorewall/blacklist file.INPUT or FORWARDThe packet has a source IP address that isn't in any of your
defined zones (shorewall[-lite] show
zones and look at the printed zone definitions)
or the chain is FORWARD and the destination IP isn't in any of
your defined zones. If the chain is FORWARD and the IN and OUT
interfaces are the same, then you probably need the routeback option on that interface in
/etc/shorewall/interfaces, you need the routeback option in the relevant entry in
/etc/shorewall/hosts
or you've done something silly like define a default route out of
an internal interface.With OPTIMIZE=1 in shorewall.conf, such
packets may also be logged out of a <zone>2all chain or the
all2all chain.OUTPUTThe packet has a destination IP address that isn't in any of
your defined zones(shorewall[-lite] show zones
and look at the printed zone definitions).With OPTIMIZE=1 in shorewall.conf, such
packets may also be logged out of the fw2all chain or the all2all
chain.logflagsThe packet is being logged because it failed the checks
implemented by the tcpflagsinterface
option.Here is an example:Jun 27 15:37:56 gateway kernel:
Shorewall:all2all:REJECT:IN=eth2OUT=eth1SRC=192.168.2.2DST=192.168.1.3 LEN=67 TOS=0x00 PREC=0x00 TTL=63 ID=5805 DF PROTO=UDP
SPT=1803 DPT=53 LEN=47Let's look at the important parts of this message:all2all:REJECTThis packet was REJECTed out of the all2all chain -- the packet was rejected
under the all->all REJECT
policy (all2all above).IN=eth2the packet entered the firewall via eth2. If you see
IN= with no interface name, the packet originated
on the firewall itself.OUT=eth1if accepted, the packet would be sent on eth1. If you see
OUT= with no interface name, the packet would be
processed by the firewall itself.When a DNAT rule is logged, there will never be an OUT=
shown because the packet is being logged before it is routed.
Also, DNAT logging will show the original
destination IP address and destination port number. When a
REDIRECT rule is logged, the message will also show the
original destination IP address and port number.SRC=192.168.2.2the packet was sent by 192.168.2.2DST=192.168.1.3the packet is destined for 192.168.1.3PROTO=UDPUDP ProtocolDPT=53The destination port is 53 (DNS)In this case, 192.168.2.2 was in the dmz zone and
192.168.1.3 is in the loc zone. I was missing the
rule:ACCEPT dmz loc udp 53(FAQ 21) I see these strange log entries occasionally; what are
they?Nov 25 18:58:52 linux kernel:
Shorewall:net2all:DROP:IN=eth1 OUT=
MAC=00:60:1d:f0:a6:f9:00:60:1d:f6:35:50:08:00 SRC=206.124.146.179
DST=192.0.2.3 LEN=56 TOS=0x00 PREC=0x00 TTL=110 ID=18558 PROTO=ICMPTYPE=3 CODE=3 [SRC=192.0.2.3 DST=172.16.1.10 LEN=128 TOS=0x00 PREC=0x00
TTL=47 ID=0 DF PROTO=UDP SPT=53 DPT=2857 LEN=108 ]192.0.2.3 is external on my firewall... 172.16.0.0/24 is my
internal LANAnswer: First of all, please note
that the above is a very specific type of log message dealing with ICMP
port unreachable packets (PROTO=ICMP TYPE=3 CODE=3). Do not read this
answer and assume that all Shorewall log messages have something to do
with ICMP (hint -- see FAQ 17).While most people associate the Internet Control Message Protocol
(ICMP) with ping, ICMP is a key piece of IP. ICMP is used
to report problems back to the sender of a packet; this is what is
happening here. Unfortunately, where NAT is involved (including SNAT,
DNAT and Masquerade), there are many broken implementations. That is
what you are seeing with these messages. When Netfilter displays these
messages, the part before the "[" describes the ICMP packet and the part
between the "[" and "]" describes the packet for which the ICMP is a
response.Here is my interpretation of what is happening -- to confirm this
analysis, one would have to have packet sniffers placed a both ends of
the connection.Host 172.16.1.10 behind NAT gateway 206.124.146.179 sent a UDP DNS
query to 192.0.2.3 and your DNS server tried to send a response (the
response information is in the brackets -- note source port 53 which
marks this as a DNS reply). When the response was returned to to
206.124.146.179, it rewrote the destination IP TO 172.16.1.10 and
forwarded the packet to 172.16.1.10 who no longer had a connection on
UDP port 2857. This causes a port unreachable (type 3, code 3) to be
generated back to 192.0.2.3. As this packet is sent back through
206.124.146.179, that box correctly changes the source address in the
packet to 206.124.146.179 but doesn't reset the DST IP in the original
DNS response similarly. When the ICMP reaches your firewall (192.0.2.3),
your firewall has no record of having sent a DNS reply to 172.16.1.10 so
this ICMP doesn't appear to be related to anything that was sent. The
final result is that the packet gets logged and dropped in the all2all
chain. I have also seen cases where the source IP in the ICMP itself
isn't set back to the external IP of the remote NAT gateway; that causes
your firewall to log and drop the packet out of the rfc1918 chain
because the source IP is reserved by RFC 1918.(FAQ 52) When I blacklist an IP address with "shorewall[-lite]
drop www.xxx.yyy.zzz", why does my log still show REDIRECT and DNAT
entries from that address?I blacklisted the address 130.252.100.59 using shorewall
drop 130.252.100.59 but I am still seeing these log
messages:Jan 30 15:38:34 server Shorewall:net_dnat:REDIRECT:IN=eth1 OUT= MAC=00:4f:4e:14:97:8e:00:01:5c:23:24:cc:08:00
SRC=130.252.100.59 DST=206.124.146.176 LEN=64 TOS=0x00 PREC=0x00 TTL=43 ID=42444 DF
PROTO=TCP SPT=2215 DPT=139 WINDOW=53760 RES=0x00 SYN URGP=0Answer: Please refer to the
Shorewall Netfilter
Documentation. Logging of REDIRECT and DNAT rules occurs in the
nat table's PREROUTING chain where the original destination IP address
is still available. Blacklisting occurs out of the filter table's INPUT
and FORWARD chains which aren't traversed until later.(FAQ 81) logdrop and logreject don't log.I love the ability to type 'shorewall logdrop ww.xx.yy.zz' and
>> completely block a particular IP address. However, the log part
doesn't happen. When I look in the logdrop chain, there is no LOG
prefix.Answer: You haven't set a value
for BLACKLIST_LOGLEVEL in shorewall.conf (5).(FAQ 36) My log is filling up with these BANDWIDTH
messages!Dec 15 16:47:30 heath-desktop kernel: [17182740.184000] BANDWIDTH_IN:IN=eth1 OUT= MAC=ff:ff:ff:ff:ff:ff:00:01:5c:23:79:02:08:00 SRC=10.119.248.1 DST=255.255.255.255 LEN=328 TOS=0x00 PREC=0x00 TTL=64 ID=62081 PROTO=UDP SPT=67 DPT=68 LEN=308
Dec 15 16:47:30 heath-desktop last message repeated 2 times
Dec 15 16:47:30 heath-desktop kernel: [17182740.188000] BANDWIDTH_IN:IN=eth1 OUT= MAC=ff:ff:ff:ff:ff:ff:00:01:5c:23:79:02:08:00 SRC=10.112.70.1 DST=255.255.255.255 LEN=328 TOS=0x00 PREC=0x00 TTL=64 ID=62082 PROTO=UDP SPT=67 DPT=68 LEN=308
Dec 15 16:47:30 heath-desktop last message repeated 2 timesAnswer: The Webmin 'bandwidth'
module adds commands to /etc/shorewall/start that
creates rules to log every packet to/from/through the firewall. DON'T
START THE BANDWIDTH SERVICE IN WEBMIN!!!!!To correct this situation once it occurs, edit
/etc/shorewall/start and insert 'return 0' prior to
the BANDWIDTH rules.Routing(FAQ 32) My firewall has two connections to the Internet from two
different ISPs. How do I set this up in Shorewall?Answer: See this article about Shorewall and Multiple
ISPs.(FAQ 49) When I start Shorewall, my routing table gets blown
away. Why does Shorewall do that?Answer: This is usually the
consequence of a one-to-one nat configuration blunder:Specifying the primary IP address for an interface in the
EXTERNAL column of /etc/shorewall/nat even
though the documentation (and the comments in the file) warn you not
to do that.Specifying ADD_IP_ALIASES=Yes and RETAIN_ALIASES=No in
/etc/shorewall/shorewall.conf.This combination causes Shorewall to delete the primary IP address
from the network interface specified in the INTERFACE column which
usually causes all routes out of that interface to be deleted. The
solution is to not specify the primary IP address
of an interface in the EXTERNAL column.(FAQ 82) When I enable USE_DEFAULT_RT, Shorewall won't
startI get the following errors:RTNETLINK answers: Numerical result out of range
ERROR: Command "ip -4 rule add from all table 254 pref 999" FailedAnswer: This is a known kernel
issue -- see http://lkml.org/lkml/2007/3/30/253.Starting and Stopping(FAQ 7) When I stop Shorewall using shorewall[-lite]
stop, I can't connect to anything. Why doesn't that command
work?Answer: The stop command is intended to place your
firewall into a safe state whereby only those hosts listed in
/etc/shorewall/routestopped are activated. If you
want to totally open up your firewall, you must use the shorewall[-lite] clear command.(FAQ 9) Why can't Shorewall detect my interfaces properly at
startup?I just installed Shorewall and when I issue the
start command, I see the following:Processing /etc/shorewall/params ...
Processing /etc/shorewall/shorewall.conf ...
Starting Shorewall...
Loading Modules...
Initializing...
Determining Zones...
Zones: net loc
Validating interfaces file...
Validating hosts file...
Determining Hosts in Zones...
Net Zone: eth0:0.0.0.0/0
Local Zone: eth1:0.0.0.0/0
Deleting user chains...
Creating input Chains...
...Why can't Shorewall detect my interfaces properly?Answer: The above output is
perfectly normal. The Net zone is defined as all hosts that are
connected through eth0 and the
local zone is defined as all hosts connected through eth1. You can set the routefilter option on an internal interface if
you wish to guard against 'Martians' (a Martian
is a packet with a source IP address that is not routed out of the
interface on which the packet was received). If you do that, it is a
good idea to also set the logmartians
option.(FAQ 22) I have some iptables commands that I want to run when
Shorewall starts. Which file do I put them in?Answer:You can place these
commands in one of the Shorewall Extension
Scripts. Be sure that you look at the contents of the chain(s)
that you will be modifying with your commands so that the commands will
do what is intended. Many iptables commands published in HOWTOs and
other instructional material use the -A command which adds the rules to
the end of the chain. Most chains that Shorewall constructs end with an
unconditional DROP, ACCEPT or REJECT rule and any rules that you add
after that will be ignored. Check man iptables and look
at the -I (--insert) command.(FAQ 43) I just installed the Shorewall RPM and Shorewall doesn't
start at boot time.Answer: When you install using
the "rpm -U" command, Shorewall doesn't run your distribution's tool for
configuring Shorewall startup. You will need to run that tool (insserv,
chkconfig, run-level editor, …) to configure Shorewall to start in the
the default run-levels of your firewall system.(FAQ 45) Why does "shorewall[-lite] start" fail when trying to
set up SNAT/Masquerading?shorewall start produces the following
output:…
Processing /etc/shorewall/policy...
Policy ACCEPT for fw to net using chain fw2net
Policy ACCEPT for loc0 to net using chain loc02net
Policy ACCEPT for loc1 to net using chain loc12net
Policy ACCEPT for wlan to net using chain wlan2net
Masqueraded Networks and Hosts:
iptables: Invalid argument
ERROR: Command "/sbin/iptables -t nat -A …" FailedAnswer: 99.999% of the time, this
error is caused by a mismatch between your iptables and kernel.Your iptables must be compiled against a kernel source tree
that is Netfilter-compatible with the kernel that you are
running.If you rebuild iptables using the defaults and install it, it
will be installed in /usr/local/sbin/iptables. As shown above, you
have the IPTABLES variable in shorewall.conf set to
"/sbin/iptables".(FAQ 59) After I start Shorewall, there are lots of unused
Netfilter modules loaded. How do I avoid that?Answer: Copy
/usr/share/shorewall[-lite]/modules to
/etc/shorewall/modules and modify the copy to
include only the modules that you need.(FAQ 61) I just installed the latest Debian kernel and now
"shorewall start" fails with the message "ipt_policy: matchsize 116 !=
308". What's wrong?Answer: Your iptables is
incompatible with your kernel. Eitherrebuild iptables using the kernel headers that match your new
kernel; orif you don't need policy match support (you are not using the
IPSEC implementation builtinto the 2.6 kernel) then you can rename
/lib/iptables/libipt_policy.so.Shorewall does not attempt to use policy match if you have no
IPSEC zones and you have not specified the
option on any entry in /etc/shorewall/hosts. The
subject message will still appear in your kernel log each time that
Shorewall determines the capabilities of your kernel/iptables.(FAQ 68) I have a VM under an OpenVZ system. I can't get rid of
the following message:ERROR: Command "/sbin/iptables -A FORWARD -m state --state
ESTABLISHED,RELATED -j ACCEPT" failed.Answer: At a root shell prompt,
type the iptables command shown in the error message. If the command
fails, your OpenVZ Netfilter/iptables configuration is incorrect. Until
that command can run without error, no stateful iptables firewall will
be able to run in your VM.(FAQ 73) When I stop Shorewall, the firewall is wide open. Isn't
that a security risk?It is important to understand that the scripts in /etc/init.d are generally provided by your
distribution and not by the Shorewall developers. These scripts must
meet the requirements of the distribution's packaging system which may
conflict with the requirements of a tight firewall. So when you say
"…when I stop Shorewall…" it is necessary to distinguish between the
commands /sbin/shorewall stop and
/etc/init.d/shorewall stop./sbin/shorewall stop places the firewall in a
safe state, the details of which depend on your
/etc/shorewall/routestopped file (shorewall-routestopped(8))
and on the setting of ADMINISABSENTMINDED in
/etc/shorewall/shorewall.conf (shorewall.conf(8))./etc/init.d/shorewall stop may or may not do
the same thing. In the case of Debian systems for
example, that command actually executes /sbin/shorewall
clear which opens the firewall completely. In other words, in
the init script's stop reverses the effect of
start.One way to avoid these differences is to install Shorewall from
the tarballs available from shorewall.net. This places Shorewall outside
of the control of the packaging system and provides consistent behavior
between the init scripts and /sbin/shorewall (and
/sbin/shorewall-lite). For more information on the
factors involved when deciding whether to use the Debian package, see
this
article.(FAQ 74) When I "shorewall start" or
"shorewall check" on my SuSE 10.0 system, I get FATAL
ERROR messages and/or the system crashes"Answer: These failures result
from trying to load a particular combination of kernel modules. To work
around the problem:Copy /usr/share/shorewall/modules to
/etc/shorewall/modulesEdit /etc/shorewall/modules and remove all entries except for
those for the helper modules that you need.(FAQ 78) After restart and bootup of my Debian firewall, all
traffic is blocked for hosts behind the firewall trying to connect out
onto the net or through the vpn (although i can reach the internal
firewall interface and obtain dumps etc). Once I issue 'shorewall clear'
followed by 'shorewall start' it then works, despite the config not
changingAnswer: Set IP_FORWARDING=On in
/etc/shorewall/shorewall.conf.Multiple ISPs(FAQ 57) I configured two ISPs in Shorewall but when I try to use
the second one, it doesn't work.Answer: The Multi-ISP
Documentation strongly recommends that you use the balance option on all providers even if you want
to manually specify which ISP to use. If you don't do that so that your
main routing table only has one default route, then you must disable
route filtering. Do not specify the routefilter option on the other interface(s) in
/etc/shorewall/interfaces and disable any
IP Address Spoofing protection that your
distribution supplies.(FAQ 58) But if I specify 'balance' then won't Shorewall balance
the traffic between the interfaces? I don't want that!Answer: Suppose that you want all
traffic to go out through ISP1 (mark 1) unless you specify otherwise.
Then simply add these two rules as the first marking rules in your
/etc/shorewall/tcrules file:#MARK SOURCE DEST
1:P 0.0.0.0/0
1 $FW
other MARK rulesNow any traffic that isn't marked by one of your other MARK rules
will have mark = 1 and will be sent via ISP1. That will work whether
balance is specified or not!Using DNS Names(FAQ 79) Can I use DNS names in Shorewall configuration file
entries in place of IP addresses?Answer: Yes, but we advise
strongly against it.Traffic Shaping(FAQ 67) I just configured Shorewall's builtin traffic shaping
and now Shorewall fails to Start.The error I receive is as follows:RTNETLINK answers: No such file or directory
We have an error talking to the kernel
ERROR: Command "tc filter add dev eth2 parent ffff: protocol ip prio
50 u32 match ip src 0.0.0.0/0 police rate 500kbit burst 10k drop flowid
:1" FailedAnswer: This message indicates that your kernel
doesn't have 'traffic policing' support. If your kernel is modularized,
you may be able to resolve the problem by loading the act_police kernel module. Other kernel modules
that you will need include:cls_fwcls_u32sch_htbsch_ingresssch_sfqAbout Shorewall(FAQ 10) What Distributions does Shorewall work with?Answer: Shorewall works with any
GNU/Linux distribution that includes the proper prerequisites.(FAQ 11) What Features does Shorewall have?Answer: See the Shorewall Feature List.(FAQ 12) Is there a GUI?Answer: Yes! Shorewall support is
available in Webmin. See http://www.webmin.com(FAQ 13) Why do you call it Shorewall?Answer: Shorewall is a
concatenation of Shoreline (the city where I live) and
Firewall. The full name of the
product is actually Shoreline Firewall but
Shorewall is much more commonly used.(FAQ 23) Why do you use such ugly fonts on your web site?Answer: The Shorewall web site is
almost font neutral (it doesn't explicitly specify fonts except on a few
pages) so the fonts you see are largely the default fonts configured in
your browser. If you don't like them then reconfigure your
browser.(FAQ 25) How do I tell which version of Shorewall or Shorewall
Lite I am running?Answer: At the shell prompt,
type:/sbin/shorewall[-lite] version(FAQ 31) Does Shorewall provide protection against....IP Spoofing: Sending packets over the WAN interface using an
internal LAP IP address as the source address?Answer: Yes.Tear Drop: Sending packets that contain overlapping
fragments?Answer: This is the
responsibility of the IP stack, not the Netfilter-based firewall
since fragment reassembly occurs before the stateful packet filter
ever touches each packet.Smurf and Fraggle: Sending packets that use the WAN or LAN
broadcast address as the source address?Answer: Shorwall filters
these packets under the nosmurfs interface
option in /etc/shorewall/interfaces.Land Attack: Sending packets that use the same address as the
source and destination address?Answer: Yes, if the routefilter interface
option is selected.DOS: - SYN Dos - ICMP Dos - Per-host Dos protectionAnswer: Yes.(FAQ 65) How do I accomplish failover with Shorewall?Answer:This article
by Paul Gear should help you get started.(FAQ 80) Does Shorewall support IPV6?Answer: Shorewall IPv6
support is currently available in Shorewall 4.2.4 and
later.(FAQ 80a) Why does Shorewall lPv6 Support Require Kernel 2.6.24
or later?Answer: Shorewall implements a
stateful firewall which requires connection tracking be present in
ip6tables and in the kernel. Linux kernel's before 2.6.20 didn't have
connection tracking for IPv6. So we could not even start to develop
IPv6 support until 2.6.20. We understand that there were significant
problems with the facility until at least kernel 2.6.23. When
distributions began offering IPv6 connection tracking support, it was
with kernel 2.6.25. So that is what we developed IPv6 support on and
that's all that we initially tested on. Subsequently, we have tested
Shorewall6 on Ubuntu Hardy with kernel 2.6.24. If you are running
2.6.20 or later, you can try to run
Shorewall6 by hacking
/usr/share/shorewall/prog.footer6 and changing the kernel
version test to check for your kernel version rather than 2.6.24
(20624). But after that, you are on your own.kernel=$(printf "%2d%02d%02d\n" $(echo $(uname -r) 2> /dev/null | sed 's/-.*//' | tr '.' ' ' ) | head -n1)
if [ $kernel -lt 20624 ]; then
error_message "ERROR: $PRODUCT requires Linux kernel 2.6.24 or later"
status=2
else
RFC 1918(FAQ 14) I'm connected via a cable modem and it has an internal
web server that allows me to configure/monitor it but as expected if I
enable rfc1918 blocking for my eth0 interface (the Internet one), it
also blocks the cable modems web server.Is there any way it can add a rule before the rfc1918 blocking
that will let all traffic to and from the 192.168.100.1 address of the
modem in/out but still block all other rfc1918 addresses?Answer: Use of the norfc1918
interface is currently deprecated and support for the option will be
removed entirely in a future version. So deleting the option from shorewall-interfaces
(5) is the preferred solution.Otherwise, add the following to /etc/shorewall/rfc1918
(Note: If you are running Shorewall 2.0.0 or later, you may need to
first copy /usr/share/shorewall/rfc1918 to
/etc/shorewall/rfc1918):Be sure that you add the entry ABOVE the entry for
192.168.0.0/16.#SUBNET TARGET
192.168.100.1 RETURNIf you add a second IP address to your external firewall
interface to correspond to the modem address, you must also make an
entry in /etc/shorewall/rfc1918 for that address.
For example, if you configure the address 192.168.100.2 on your
firewall, then you would add two entries to
/etc/shorewall/rfc1918:#SUBNET TARGET
192.168.100.1 RETURN
192.168.100.2 RETURN(FAQ 14a) Even though it assigns public IP addresses, my ISP's
DHCP server has an RFC 1918 address. If I enable RFC 1918 filtering on
my external interface, my DHCP client cannot renew its lease.Answer: The solution is the
same as above.(FAQ 14b) I connect to the Internet with PPPoE. When I try to
access the built-in web server in my DSL Modem, I get connection
Refused.I see the following in my log:Mar 1 18:20:07 Mail kernel: Shorewall:OUTPUT:REJECT:IN= OUT=eth0 SRC=192.168.1.2 DST=192.168.1.1 LEN=60
TOS=0x00 PREC=0x00 TTL=64 ID=26774 DF PROTO=TCP SPT=32797 DPT=80 WINDOW=5840 RES=0x00 SYN URGP=0 Answer: The fact that the
message is being logged from the OUTPUT chain means that the
destination IP address is not in any defined zone (see FAQ 17). You need to:Add a zone for the modem in
/etc/shorewall/zones:#ZONE TYPE OPTIONS
modem ipv4Define the zone to be associated with eth0 (or whatever interface connects
to your modem) in
/etc/shorewall/interfaces:#ZONE INTERFACE BROADCAST OPTIONS
modem eth0 detectAllow web traffic to the modem in
/etc/shorewall/rules:#ACTION SOURCE DEST PROTO DEST PORT(S)
ACCEPT fw modem tcp 80
ACCEPT loc modem tcp 80Note that many of these ADSL/Cable Modems have no default
gateway or their default gateway is at a fixed IP address that is
different from the IP address you have assigned to your external
interface. In either case, you may have problems browsing the modem
from your local network even if you have the correct routes
established on your firewall. This is usually solved by masquerading
traffic from your local network to the modem./etc/shorewall/masq:#INTERFACE SOURCE ADDRESS
eth0 eth1 # eth1 = interface to local networkFor an example of this when the ADSL/Cable modem is bridged, see
my configuration. In that
case, I masquerade using the IP address of my local interface!Alias IP Addresses/Virtual Interfaces(FAQ 18) Is there any way to use aliased ip addresses with
Shorewall, and maintain separate rule sets for different IPs?Answer: Yes. See Shorewall and Aliased
Interfaces.(FAQ 83) Is there no way to nest the firewall zone or create
subzones? I've got a system with Linux-VServers, it's one interface
(eth0) with multiple IPsAnswer: There is no way to create
sub-zones of the firewall zone. But you can use shell variables to make
vservers easier to deal with./etc/shorewall/params:VS1=fw:192.168.2.12
VS2=fw:192.168.2.13
VS3=fw:192.168.2.14/etc/shorewall/rules:#ACTION SOURCE DEST PROTO DEST PORT(S)
ACCEPT $VS1 net tcp 25
DNAT net $VS1 tcp 25
etc...Shorewall Lite(FAQ 53) What is Shorewall Lite?Answer: Shorewall Lite is a
companion product to Shorewall and is designed to allow you to maintain
all Shorewall configuration information on a single system within your
network. See the Compiled
Firewall script documentation for details.(FAQ 54) If I want to use Shorewall Lite, do I also need to
install Shorewall on the same system?Answer: No. In fact, we recommend
that you do NOT install Shorewall on
systems where you wish to use Shorewall Lite. You must have Shorewall
installed on at least one system within your network in order to use
Shorewall Lite.(FAQ 55) How do I decide which product to use - Shorewall or
Shorewall Lite?Answer: If you plan to have only
a single firewall system, then Shorewall is the logical choice. I also
think that Shorewall is the appropriate choice for laptop systems that
may need to have their firewall configuration changed while on the road.
In the remaining cases, Shorewall Lite will work very well. At
shorewall.net, the two laptop systems have the full Shorewall product
installed as does my personal Linux desktop system. All other Linux
systems that run a firewall use Shorewall Lite and have their
configuration directories on my desktop system.(FAQ 60) What are the compatibility restrictions between
Shorewall and Shorewall LiteAnswer: There are no
compatibility constraints between Shorewall and Shorewall-lite.VOIP(FAQ 77) Shorewall is eating my Asterisk egress traffic!Somehow, my firewall config is causing a one-way audio problem in
Asterisk. If a person calls into the PBX, they cannot hear me speaking,
but I can hear them. If I plug the Asterisk server directly into the
router, bypassing the firewall, the problem goes away.Answer (requires Shorewall 4.0.6 or
later): If your kernel version is 2.6.20 or
earlier:rmmod ip_nat_sip
rmmod ip_conntrack_sipThen change the DONT_LOAD specification
in your shorewall.conf to:DONT_LOAD=ip_nat_sip,ip_conntrack_sipIf
your kernel version is 2.6.21 or later:rmmod nf_nat_sip
rmmod nf_conntrack_sipThen change the DONT_LOAD specification
in your shorewall.conf to:DONT_LOAD=nf_nat_sip,nf_conntrack_sipIf
you are running a version of Shorewall earlier than 4.0.6, you can avoid
loading the sip helper modules by following the suggestions in FAQ 59.Miscellaneous(FAQ 20) I have just set up a server. Do I have to change
Shorewall to allow access to my server from the Internet?Answer: Yes. Consult the QuickStart guide that you
used during your initial setup for information about how to set up rules
for your server.(FAQ 24) How can I allow connections to, let's say, the ssh port
only from specific IP Addresses on the Internet?Answer: In the SOURCE column of
the rule, follow net by a colon and a list of the
host/subnet addresses as a comma-separated list.net:<ip1>,<ip2>,...Example:ACCEPT net:192.0.2.16/28,192.0.2.44 fw tcp 22(FAQ 26) When I try to use any of the SYN options in nmap on or
behind the firewall, I get operation not permitted. How
can I use nmap with Shorewall?"Answer: Temporarily remove and
rejNotSyn, dropNotSyn and dropInvalid rules from
/etc/shorewall/rules and restart Shorewall.(FAQ 27) I'm compiling a new kernel for my firewall. What should
I look out for?Answer: First take a look at the
Shorewall kernel configuration page. You
probably also want to be sure that you have selected the NAT of local connections (READ HELP) on the Netfilter Configuration menu. Otherwise, DNAT rules with
your firewall as the source zone won't work with your new kernel.(FAQ 27a) I just built (or downloaded or otherwise acquired)
and installed a new kernel and now Shorewall won't start. I know that
my kernel options are correct.The last few lines of a startup
trace are these:+ run_iptables2 -t nat -A eth0_masq -s 192.168.2.0/24 -d 0.0.0.0/0 -j
MASQUERADE
+ '[' 'x-t nat -A eth0_masq -s 192.168.2.0/24 -d 0.0.0.0/0 -j
MASQUERADE' = 'x-t nat -A eth0_masq -s 192.168.2.0/24 -d 0.0.0.
0/0 -j MASQUERADE' ']'
+ run_iptables -t nat -A eth0_masq -s 192.168.2.0/24 -d 0.0.0.0/0 -j
MASQUERADE
+ iptables -t nat -A eth0_masq -s 192.168.2.0/24 -d 0.0.0.0/0 -j
MASQUERADE
iptables: Invalid argument
+ '[' -z '' ']'
+ stop_firewall
+ set +xAnswer: Your new kernel
contains headers that are incompatible with the ones used to compile
your iptables utility. You need to rebuild
iptables using your new kernel source.(FAQ 28) How do I use Shorewall as a Bridging Firewall?Answer: Shorewall Bridging
Firewall support is available — check here for details.(FAQ 39) How do I block connections to a particular domain
name?I tried this rule to block Google's Adsense that you'll find on
everyone's site. Adsense is a Javascript that people add to their Web
pages. So I entered the rule:#ACTION SOURCE DEST PROTO
REJECT fw net:pagead2.googlesyndication.com allHowever, this also sometimes restricts access to "google.com". Why
is that? Using dig, I found these IPs for domain
googlesyndication.com:216.239.37.99
216.239.39.99And this for google.com:216.239.37.99
216.239.39.99
216.239.57.99So my guess is that you are not actually
blocking the domain, but rather the IP being called. So how in the world
do you block an actual domain name?Answer: Packet filters like
Netfilter base their decisions on the contents of the various protocol
headers at the front of each packet. Stateful packet filters (of which
Netfilter is an example) use a combination of header contents and state
created when the packet filter processed earlier packets. Netfilter (and
Shorewall's use of Netfilter) also consider the network interface(s)
where each packet entered and/or where the packet will leave the
firewall/router.When you specify a domain name in a
Shorewall rule, the iptables program resolves that name to one
or more IP addresses and the actual Netfilter rules that are created are
expressed in terms of those IP addresses. So the rule that you entered
was equivalent to:#ACTION SOURCE DEST PROTO
REJECT fw net:216.239.37.99 all
REJECT fw net:216.239.39.99 allGiven that
name-based multiple hosting is a common practice (another example:
lists.shorewall.net and www1.shorewall.net are both hosted on the same
system with a single IP address), it is not possible to filter
connections to a particular name by examination of protocol headers
alone. While some protocols such as FTP
require the firewall to examine and possibly modify packet payload,
parsing the payload of individual packets doesn't always work because
the application-level data stream can be split across packets in
arbitrary ways. This is one of the weaknesses of the 'string match'
Netfilter extension available in later Linux kernel releases. The only
sure way to filter on packet content is to proxy the connections in
question -- in the case of HTTP, this means running something like
Squid. Proxying allows
the proxy process to assemble complete application-level messages which
can then be accurately parsed and decisions can be made based on the
result.(FAQ 42) How can I tell which features my kernel and iptables
support?Answer: Use the
shorewall[-lite] show capabilities command at a root
prompt.gateway:~# shorewall show capabilities
Loading /usr/share/shorewall/functions...
Processing /etc/shorewall/params ...
Processing /etc/shorewall/shorewall.conf...
Loading Modules...
Shorewall has detected the following iptables/netfilter capabilities:
NAT: Available
Packet Mangling: Available
Multi-port Match: Available
Extended Multi-port Match: Available
Connection Tracking Match: Available
Packet Type Match: Available
Policy Match: Available
Physdev Match: Available
IP range Match: Available
Recent Match: Available
Owner Match: Available
Ipset Match: Available
ROUTE Target: Available
Extended MARK Target: Available
CONNMARK Target: Available
Connmark Match: Available
Raw Table: Available
gateway:~#(FAQ 19) How do I open the firewall for all traffic to/from the
LAN?Answer: Add these two
policies:#SOURCE DESTINATION POLICY LOG LIMIT:BURST
# LEVEL
$FW loc ACCEPT
loc $FW ACCEPT You should also delete any ACCEPT rules from $FW->loc and
loc->$FW since those rules are redundant with the above
policies.