Shorewall FAQsShorewall CommunityTomEastep2005-07-192001-2005Thomas 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.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 empty!!!Once you have installed the .deb package and before you attempt
to configure Shorewall, please heed the advice of Lorenzo Martignoni,
the Shorewall Debian Maintainer:For more information about Shorewall usage on Debian
system please look at /usr/share/doc/shorewall/README.Debian provided
by [the] shorewall Debian package.If you install using the .deb, you will find that your /etc/shorewall directory is empty. This is
intentional. The released configuration file skeletons may be found on
your system in the directory /usr/share/doc/shorewall/default-config.
Simply copy the files you need from that directory to /etc/shorewall and modify the
copies.Note that you must copy /usr/share/doc/shorewall/default-config/shorewall.conf
and /usr/share/doc/shorewall/default-config/modules
to /etc/shorewall even if you do
not modify those files.(FAQ 44) I can't install/upgrade the RPM — I keep getting the
message "error: failed dependencies:iproute is needed..."Answer: Read the Installation Instructions!!!!!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 first example in the
rules file documentation
shows how to do port forwarding under Shorewall. 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>] <protocol> <port #>So 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>] <protocol> <port #> - <external IP>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) Ok -- 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 should be set to the IP address of your
firewall's internal interface).Your ISP is blocking that particular port inbound.You are running Mandrake Linux 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 iptables -t nat -Z. This clears the NetFilter counters in the nat
table.Try to connect to the redirected port from an external
host.As root type shorewall show natLocate 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.(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?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: Let's assume the
following:External IP address is 206.124.146.176 on eth0.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/init:ETH0_IP=`find_interface_address eth0`For users of Shorewall 2.1.0 and later: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_IP(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 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 30) I'm confused about when to use DNAT rules and when to
use ACCEPT rules.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.
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 38) Where can I find more information about DNAT?Ian Allen has written a Paper about DNAT and
Linux.(FAQ 48) How do I Set up Transparent 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 Bind Version 9
views (or using a separate DNS server for
local clients) 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.If you insist on a stupid IP solution to the accessibility problem
rather than a more efficient DNS solution, then if you are running
Shorewall 2.0.0 or 2.0.1 then please see the Shorewall 1.4
FAQ.Otherwise, 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:All traffic redirected through use of this hack will look to
the server as if it came from the firewall (192.168.1.254) rather
than from the original client!In /etc/shorewall/interfaces:#ZONE INTERFACE BROADCAST OPTIONS
loc eth1 detect routebackIn /etc/shorewall/masq:#INTERFACE SUBNET 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 and are running
Shorewall 1.3.4 through Shorewall 2.0.* then include this in
/etc/shorewall/init:ETH0_IP=`find_interface_address eth0`For users of Shorewall 2.1.0 and later: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 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 hosts'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 Bind Version 9 views. 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 to stupidly 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 SUBNETS ADDRESS
eth2 eth2 192.168.2.254Like the idiotic 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/init:ETH0_IP=`find_interface_address eth0`For users of Shorewall 2.1.0 and later: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_IPNetmeeting/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
> contrack 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 4) I just used an online port scanner to check my firewall
and it shows some ports as closed rather than
blocked. Why?Answer: (Shorewall versions prior
to 2.0.0 only). The common.def included with version 1.3.x always
rejects connection requests on TCP port 113 rather than dropping them.
This is necessary to prevent outgoing connection problems to services
that use the Auth mechanism for identifying requesting
users. Shorewall also rejects TCP ports 135, 137, 139 and 445 as well as
UDP ports 137-139. These are ports that are used by Windows (Windows
can be configured to use the DCE cell locator on
port 135). Rejecting these connection requests rather than dropping them
cuts down slightly on the amount of Windows chatter on LAN segments
connected to the Firewall.If you are seeing port 80 being closed, that's
probably your ISP preventing you from running a web server in violation
of your Service Agreement.You can change the default behavior of Shorewall through use of
an /etc/shorewall/common file. See the Extension Script
Section.Beginning with Shorewall 1.4.9, Shorewall no longer rejects the
Windows SMB ports (135-139 and 445) by default and silently drops them
instead.Answer: (Shorewall versions 2.0.0
and later). The default Shorewall setup invokes the Drop action prior to enforcing a DROP policy and
the default policy to all zone from the internet is DROP. The Drop
action is defined in
/usr/share/shorewall/action.Drop which in turn
invokes the RejectAuth action (defined
in /usr/share/shorewall/action.RejectAuth). 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 firerwall will block that attempt.(FAQ 4c) How do I use Shorewall with PortSentry?Here's
a writeup on a nice integration of Shorewall and
PortSentry.Connection Problems(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 firewall to the internet.(FAQ 29) FTP Doesn't WorkSee 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 40) Shorewall is Blocking my OpenVPN TunnelI have this entry in /etc/shorewall/tunnels:# TYPE ZONE GATEWAY GATEWAY
# ZONE
openvpn:5000 net 69.145.71.133Yet I am seeing this log message:Oct 12 13:41:03 localhost kernel: Shorewall:net2all:DROP:IN=eth0 OUT=
MAC=00:04:5a:7f:92:9f:00:b0:c2:89:68:e4:08:00 SRC=69.145.71.133
DST=216.187.138.18 LEN=42 TOS=0x00 PREC=0x00 TTL=46 ID=11 DF PROTO=UDP
SPT=33120 DPT=5000 LEN=22Answer: Shorewall's openvpn tunnel type assumes that OpenVPN will be
using the same port (default 5000) for both the source and destination
port. From the above message, it is clear that the remote client is
using source port 33120. The solution is to replace your /etc/shorewall/tunnels entry
with this one:# TYPE ZONE GATEWAY GATEWAY
# ZONE
generic:udp:5000 net 69.145.71.133(FAQ 47) This Rule Doesn't Work as DocumentedI want to allow access from the local zone to the net except for
two systems (192.168.100.101 and 192.168.100.115). I use the following
rule but find that 192.168.100.115 can still access the net. Is this a
bug?#ACTION SOURCE DEST PROTO
ACCEPT loc:!192.168.100.101,192.168.100.115 netAnswer: Shorewall is currently
inconsistent as to where it correctly supports the "!" before a list of
addresses. In some places, it works as you would expect and in other
cases such as this one it does not. You will need to take a different
approach to accomplish what you want. I recommend that you change your
loc->net policy to ACCEPT and then use this rule:#ACTION SOURCE DEST PROTO
REJECT loc:192.168.100.101,192.168.100.115 netAuthor's Note: I have looked
several times at correcting this problem but it really isn't feasible
until I muster the energy to rewrite the Shorewall rules parser.
Sorry.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 ratelimited log messages
through settings in
/etc/shorewall/shorewall.conf -- If you want to log
all messages, set:LOGLIMIT=""
LOGBURST=""Beginning with Shorewall version 1.3.12, you can 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://www.fireparse.comhttp://cert.uni-stuttgart.de/projects/fwlogwatchhttp://www.logwatch.orghttp://gege.org/iptableshttp://home.regit.org/ulogd-php.htmlI 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.(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?Temporarily add the following rule:DROP net fw 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.What is labeled as the MAC address in a 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: If you are running
Shorewall version 1.4.4 or 1.4.4a then check the errata. Otherwise:Find where klogd is being started (it will be from one of the
files in /etc/init.d -- sysklogd, klogd, ...). Modify that file or
the appropriate configuration file so that klogd is started with
-c <n> where
<n> is a log level of 5 or less;
orSee the dmesg man page (man
dmesg). You must add a suitable dmesg command
to your startup scripts or place it in /etc/shorewall/start.Under RedHat and Mandrake, the max log level that is sent to the
console is specified in /etc/sysconfig/init in the LOGLEVEL variable.
Set LOGLEVEL=5 to suppress info (log level 6) messages
on the console.Under Debian, you can set KLOGD=-c 5 in
/etc/init.d/klogd to suppress info (log level 6)
messages on the console.Under SuSE, add -c 5 to KLOGD_PARAMS in
/etc/sysconfig/syslog to suppress info (log level 6) messages on the
console.(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.all2<zone>, <zone>2all 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.<zone1>2<zone2>Either 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.@<source>2<dest>You 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>_macThe packet is being logged under the maclistinterface
option.logpktThe packet is being logged under the loguncleaninterface
option.badpktThe packet is being logged under the dropuncleaninterface option as
specified in the LOGUNCLEAN
setting in /etc/shorewall/shorewall.conf.blacklstThe packet is being logged because the source IP is
blacklisted in the /etc/shorewall/blacklist file.newnotsynThe packet is being logged because it is a TCP packet that
is not part of any current connection yet it is not a syn packet.
Options affecting the logging of such packets include NEWNOTSYN and LOGNEWNOTSYN in /etc/shorewall/shorewall.conf.INPUT or FORWARDThe packet has a source IP address that isn't in any of your
defined zones (shorewall check 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 or you need the routeback option in the relevant entry in
/etc/shorewall/hosts.OUTPUTThe packet has a destination IP address that isn't in any of
your defined zones("shorewall check" and look at the printed zone
definitions).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.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)For additional information about the log message, see http://logi.cc/linux/netfilter-log-format.php3.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=ICMP
TYPE=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: While most people
associate the Internet Control Message Protocol (ICMP) with
ping, ICMP is a key piece of the internet. 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 a lot of 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.Routing(FAQ 32) My firewall has two connections to the internet from two
different ISPs. How do I set this up in Shorewall?Anyone with two Internet connections MUST read and understand
this article on Shorewall and
Routing. If you don't, you will be completely lost trying to
make this work. And that article should be all
that you need if you are running Shorewall 2.3.2 or
later.Setting this up in Shorewall is easy; setting up the routing is a
bit harder.Assuming that eth0 and
eth1 are the interfaces to the
two ISPs then:/etc/shorewall/interfaces:#ZONE INTERFACE BROADCAST OPTIONS
net eth0 detect
net eth1 detect/etc/shorewall/policy:#SOURCE DESTINATION POLICY LIMIT:BURST
net net DROPIf you have masqueraded hosts, be sure to update
/etc/shorewall/masq to masquerade to both ISPs. For
example, if you masquerade all hosts connected to eth2 then:#INTERFACE SUBNET ADDRESS
eth0 eth2
eth1 eth2Again, if you are running Shorewall 2.3.2 or later, please see
this article for
instructions for setting up the routing. Otherwise, follow the
instructions that follow.There was an article in SysAdmin covering the topic of setting up
routing for this configuration. It may be found at http://www.samag.com/documents/s=1824/sam0201h/.Stephen Carville has put together a Shorewall-specific writeup
that covers this subject at http://www.heronforge.net/redhat/node17.html.The following information regarding setting up routing
for this configuration is reproduced from the LARTC HOWTO and has not been verified
by the author. If you have questions or problems with the instructions
given below, please post to the LARTC mailing
list.A common configuration is the following, in which there are two
providers that connect a local network (or even a single machine) to
the big Internet. ________
+------------+ /
| | |
+-------------+ Provider 1 +-------
__ | | | /
___/ \_ +------+-------+ +------------+ |
_/ \__ | if1 | /
/ \ | | |
| Local network -----+ Linux router | | Internet
\_ __/ | | |
\__ __/ | if2 | \
\___/ +------+-------+ +------------+ |
| | | \
+-------------+ Provider 2 +-------
| | |
+------------+ \________
There are usually two questions given this setup.Split accessThe first is how to route answers to packets coming in over a
particular provider, say Provider 1, back out again over that same
provider.Let us first set some symbolical names. Let $IF1 be the name of the first interface (if1 in
the picture above) and $IF2 the name
of the second interface. Then let $IP1 be the IP address associated with
$IF1 and $IP2 the IP address associated with $IF2. Next, let $P1 be the IP address of the gateway at
Provider 1, and $P2 the IP address of
the gateway at provider 2. Finally, let $P1_NET be the IP network $P1 is in, and $P2_NET the IP network $P2 is in.One creates two additional routing tables, say T1 and T2.
These are added in /etc/iproute2/rt_tables. Then you set up routing in
these tables as follows:ip route add $P1_NET dev $IF1 src $IP1 table T1
ip route add default via $P1 table T1
ip route add $P2_NET dev $IF2 src $IP2 table T2
ip route add default via $P2 table T2Nothing spectacular, just build a route to the gateway and build
a default route via that gateway, as you would do in the case of a
single upstream provider, but put the routes in a separate table per
provider. Note that the network route suffices, as it tells you how to
find any host in that network, which includes the gateway, as
specified above.Next you set up the main routing table. It is a good idea to
route things to the direct neighbour through the interface connected
to that neighbour. Note the `src' arguments, they make sure the right
outgoing IP address is chosen.ip route add $P1_NET dev $IF1 src $IP1
ip route add $P2_NET dev $IF2 src $IP2Then, your preference for default route:ip route add default via $P1Next, you set up the routing rules. These actually choose what
routing table to route with. You want to make sure that you route out
a given interface if you already have the corresponding source
address:ip rule add from $IP1 table T1
ip rule add from $IP2 table T2This set of commands makes sure all answers to traffic coming in
on a particular interface get answered from that interface.'If $P0_NET is the local network and $IF0 is its interface,
the following additional entries are desirable:ip route add $P0_NET dev $IF0 table T1
ip route add $P2_NET dev $IF2 table T1
ip route add 127.0.0.0/8 dev lo table T1
ip route add $P0_NET dev $IF0 table T2
ip route add $P1_NET dev $IF1 table T2
ip route add 127.0.0.0/8 dev lo table T2Now, this is just the very basic setup. It will work for all
processes running on the router itself, and for the local network, if
it is masqueraded. If it is not, then you either have IP space from
both providers or you are going to want to masquerade to one of the
two providers. In both cases you will want to add rules selecting
which provider to route out from based on the IP address of the
machine in the local network.Load balancingThe second question is how to balance traffic going out over the
two providers. This is actually not hard if you already have set up
split access as above.Instead of choosing one of the two providers as your default
route, you now set up the default route to be a multipath route. In
the default kernel this will balance routes over the two providers. It
is done as follows (once more building on the example in the section
on split-access):ip route add default scope global nexthop via $P1 dev $IF1 weight 1 \
nexthop via $P2 dev $IF2 weight 1This will balance the routes over both providers. The weight parameters can be tweaked to favor one
provider over the other.balancing will not be perfect, as it is route based, and
routes are cached. This means that routes to often-used sites will
always be over the same provider.Furthermore, if you really want to do this, you probably also
want to look at Julian Anastasov's patches at http://www.ssi.bg/~ja/#routes
, Julian's route patch page. They will make things nicer to work
with.The following was contributed by Martin Brown and is an excerpt
from http://www.docum.org/stef.coene/qos/faq/cache/44.html.There are two issues requiring different handling when dealing
with multiple Internet providers on a given network. The below assumes
that the host which has multiple Internet connections is a
masquerading (or NATting) host and is at the chokepoint between the
internal and external networks. For the use of multiple inbound
connections to the same internal server (public IP A from ISP A and
public IP B from ISP B both get redirected to the same internal
server), the ideal solution involves using two private IP addresses on
the internal server. This leads to an end-to-end uniqueness of public
IP to private IP and can be easily accomplished by following the
directions here:http://linux-ip.net/html/adv-multi-internet.html#adv-multi-internet-inboundFor the use of multiple outbound links to the Internet, there
are a number of different techniques. The simplest is identified
here:http://linux-ip.net/html/adv-multi-internet.html#adv-multi-internet-outboundBetter (and more robust) techniques are available after a kernel
routing patch by Julian Anastasov. See the famous nano-howto.http://www.ssi.bg/~ja/(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.Starting and Stopping(FAQ 7) When I stop Shorewall using shorewall
stop, I can't connect to anything. Why doesn't that command
work?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 clear command.(FAQ 8) When I try to start Shorewall on RedHat, I get messages
about insmod failing -- what's wrong?Answer: The output you will see
looks something like this:/lib/modules/2.4.17/kernel/net/ipv4/netfilter/ip_tables.o: init_module: Device or resource busy
Hint: insmod errors can be caused by incorrect module parameters, including invalid IO or IRQ parameters
/lib/modules/2.4.17/kernel/net/ipv4/netfilter/ip_tables.o: insmod
/lib/modules/2.4.17/kernel/net/ipv4/netfilter/ip_tables.o failed
/lib/modules/2.4.17/kernel/net/ipv4/netfilter/ip_tables.o: insmod ip_tables failed
iptables v1.2.3: can't initialize iptables table `nat': iptables who? (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.This problem is usually corrected through the following sequence
of commandsservice ipchains stop
chkconfig --delete ipchains
rmmod ipchainsAlso, be sure to check the errata
for problems concerning the version of iptables (v1.2.3) shipped with
RH7.2.(FAQ 8a) When I try to start Shorewall on RedHat I get a
message referring me to FAQ #8Answer: This is usually cured
by the sequence of commands shown above in .(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. If you
are running Shorewall 1.4.10 or later, you can consider setting the
detectnets interface option on your local
interface (eth1 in the above
example). That will cause Shorewall to restrict the local zone to only
those networks routed through that interface.(FAQ 22) I have some iptables commands that I want to run when
Shorewall starts. Which file do I put them in?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 to be sure that the
commands will do what they are 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 34) How can I speed up start (restart)?Using a light-weight shell such as ash can
dramatically decrease the time required to start or restart
Shorewall. See the SHOREWALL_SHELL variable in shorewall.conf.Use a fast terminal emulator -- in particular the KDE konsole
scrolls much faster than the Gnome terminal. Also use the '-q' option if
you are restarting remotely or from a slow terminal (or redirect the
output to a file as in shorewall restart >
/dev/null).Beginning with Shorewall version 2.0.2 Beta 1, Shorewall supports
a fast start capability. To use this capability:With Shorewall in the started state, run
shorewall save. This creates the script
/var/lib/shorewall/restore.Use the -f option to the
start command (e.g., shorewall -f start). This
causes Shorewall to look for the
/var/lib/shorewall/restore script and if that
script exists, it is run. Running
/var/lib/shorewall/restore takes much less time
than a full shorewall start.The /etc/init.d/shorewall script that is
run at boot time uses the -f
option.The /var/lib/shorewall/restore script can
be run any time to restore the firewall. The script may be run
directly or it may be run indirectly using the shorewall
restore command.If you change your Shorewall configuration, you must execute a
shorewall start (without -f) or shorewall restart prior
to doing another shorewall save. The
shorewall save command saves the currently running
configuration and not the one reflected in your updated configuration
files.Likewise, if you change your Shorewall configuration then once you
are satisfied that it is working properly, you must do another
shorewall save. Otherwise at the next reboot, you
will revert to the old configuration stored in
/var/lib/shorewall/restore.(FAQ 34a) I get errors about a host or network not found when I
run/var/lib/shorewall/restore. The
shorewall restore and shorewall -f
start commands gives the same result.Answer: iptables 1.2.9 is broken with respect to iptables-save
and the connection tracking match extension. You must patch your
iptables using the patch available from the Shorewall errata page.(FAQ 41) Why do I get modprobe failure messages when I start
Shorewall?When I start shorewall I got the following errors.Oct 30 11:13:12 fwr modprobe: modprobe: Can't locate module ipt_conntrack
Oct 30 11:13:17 fwr modprobe: modprobe: Can't locate module ipt_pkttype
Oct 30 11:13:18 fwr modprobe: modprobe: Can't locate module ipt_pkttype
Oct 30 11:13:57 fwr last message repeated 2 times
Oct 30 11:14:06 fwr root: Shorewall RestartedThe "shorewall status" output seems complying with my rules set.
Should I worry ? and is there any way to get rid of these errors
?Answer: You are seeing two
different things:The normal checking that Shorewall does when it starts.
Shorewall tries to determine the the capabilities of your 'iptables'
and kernel and then taylors the ruleset accordingly.A problem in Shorewall 2.0.3a through 2.0.5 whereby Shorewall
tried to use the pkttype match feature each
time that it wanted to generate a rule involving broadcast or
multicast packets.You can suppress the messages by aliasing the modules mentioned in
the error messages to off in /etc/modules.conf. Just be sure to review
these aliases each time that you do a kernel upgrade to be sure that you
are not disabling a feature in your new kernel that you want to
use.alias ipt_conntrack off
alias ipt_pkttype offFor users who don't have the pkttype match feature in their
kernel, I also recommend upgrading to Shorewall 2.0.6 or later and then
setting PKTTYPE=No in shorewall.conf.(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
run-levels that you run your firewall system at.(FAQ 45) Why does "shorewall 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".About Shorewall(FAQ 10) What Distributions does it work with?Shorewall works with any GNU/Linux distribution that includes the
proper
prerequisites.(FAQ 11) What Features does it have?Answer: See the Shorewall Feature List.(FAQ 12) Is there a GUI?Answer: Yes. Shorewall support is
included in Webmin 1.060 and later versions. 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?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 to I tell which version of Shorewall I am
running?At the shell prompt, type:/sbin/shorewall 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: Shorewall can be configured to do that using the
blacklisting
facility. Shorewall versions 2.0.0 and later filter 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: Shorewall has facilities for limiting SYN and ICMP
packets. Netfilter as included in standard Linux kernels doesn't
support per-remote-host limiting except by explicit rule that
specifies the host IP address; that form of limiting is supported
by Shorewall.(FAQ 46) Given that the Debian Stable Release includes Shorewall
1.2.12, how can you not support that version?The first release of Shorewall was in March of 2001. Shorewall
1.2.12 was released in May of 2002. It is now the year 2005 and
Shorewall 2.2 is available. Shorewall 1.2.12 is poorly documented and is
missing many of the features that Shorewall users find essential today
and it is silly to continue to run it simply because it is bundled with
an ancient Debian release.(FAQ 36) Does Shorewall Work with the 2.6 Linux Kernel?Shorewall works with the 2.6 Kernels with a couple of
caveats:Netfilter/iptables doesn't fully support IPSEC in the 2.6
Kernels -- kernel and iptables patches are available and the details
may be found at the Shorewall IPSEC-2.6
page.The 2.6 Kernels do not provide support for the logunclean and
dropunclean options in
/etc/shorewall/interfaces. Note that support
for those options was also removed from Shorewall in version
2.0.0.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: If you are running a
version of Shorewall earlier than 1.3.1, create /etc/shorewall/start and
in it, place the following:run_iptables -I rfc1918 -s 192.168.100.1 -j ACCEPTIf you are running version 1.3.1 or later, 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.The solution is the same as above.
Simply substitute the IP address of your ISPs DHCP server.(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 DISPLAY COMMENTS
modem ADSLModem Zone for modemDefine 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 SUBNET 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 rulesets for different IPs?Answer: Yes. See Shorewall and Aliased
Interfaces.Miscellaneous(FAQ 19) I have added entries to /etc/shorewall/tcrules but they
don't seem to do anything. Why?You probably haven't set TC_ENABLED=Yes in
/etc/shorewall/shorewall.conf so the contents of the tcrules file are
simply being ignored.(FAQ 20) I have just set up a server. Do I have to change
Shorewall to allow access to my server from the internet?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 conections to let's say the ssh port
only from specific IP Addresses on the internet?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?"Edit /etc/shorewall/shorewall.conf and change
NEWNOTSYN=No to NEWNOTSYN=Yes then restart
Shorewall.(FAQ 26a) When I try to use the -O option of
nmap from the firewall system, I get operation not
permitted. How do I allow this option?If you are running Shorewall 2.2.0 or later, set DROPINVALID=No
in /etc/shorewall/shorewall.conf.Otherwise, add this command to your /etc/shorewall/start
file:run_iptables -D OUTPUT -p ! icmp -m state --state INVALID -j DROP(FAQ 27) I'm compiling a new kernel for my firewall. What should
I look out for?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?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 examiniation 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 Patch-O-Matic. 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: Users running Shorewall 2.2.4 or later can simply use the
shorewall show capabilities command at a root
prompt.For those running older versions, at a root prompt, enter the
command shorewall check. There is a section near the
top of the resulting output that gives you a synopsis of your
kernel/iptables capabilities.gateway:/etc/shorewall # shorewall check
Loading /usr/share/shorewall/functions...
Processing /etc/shorewall/params ...
Processing /etc/shorewall/shorewall.conf...
Loading Modules...
Notice: The 'check' command is unsupported and problem
reports complaining about errors that it didn't catch
will not be accepted
Shorewall has detected the following iptables/netfilter capabilities:
NAT: Available
Packet Mangling: Available
Multi-port Match: Available
Connection Tracking Match: Available
Packet Type Match: Not available
Policy Match: Available
Physdev Match: Available
IP range Match: Available
Verifying Configuration...
...