.GNU Free Documentation License
diff --git a/Shorewall-docs2/Documentation.html b/Shorewall-docs2/Documentation.html deleted file mode 100644 index acd04c081..000000000 --- a/Shorewall-docs2/Documentation.html +++ /dev/null @@ -1,928 +0,0 @@ - - -
Copyright © 2001-2004 Thomas M. Eastep
Permission 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”.
2004-02-03
Abstract
This documentation is intended primarily for reference. - Step-by-step instructions for configuring Shorewall in common setups may - be found in the QuickStart - Guides.
Table of Contents
Shorewall consists of the following components:
a parameter file installed in /etc/shorewall - that can be used to establish the values of shell variables for use - in other files.
a parameter file installed in /etc/shorewall - that is used to set several firewall parameters.
a parameter file installed in /etc/shorewall - that defines a network partitioning into “zones”
a parameter file installed in /etc/shorewall - that establishes overall firewall policy.
a parameter file installed in /etc/shorewall - and used to express firewall rules that are exceptions to the - high-level policies established in /etc/shorewall/policy.
a parameter file installed in /etc/shorewall - and used to list blacklisted IP/subnet/MAC addresses.
a parameter file installed in /etc/shorewall - and used to selectively disable Explicit Congestion Notification - (ECN - RFC 3168).
a set of shell functions used by both the firewall and - shorewall shell programs. Installed in /usr/share/shorewall.
a parameter file installed in /etc/shorewall - and that specifies kernel modules and their parameters. Shorewall - will automatically load the modules specified in this file.
a parameter file installed in /etc/shorewall - that is used to specify how the Type of Service (TOS) field in - packets is to be set.
a shell script installed in /etc/init.d - to automatically start Shorewall during boot. The - particular script installed depends on which distribution you are - running.
a parameter file installed in /etc/shorewall - and used to describe the interfaces on the firewall system.
a parameter file installed in /etc/shorewall - and used to describe individual hosts or subnetworks in zones.
a parameter file installed in /etc/shorewall - and used to verify the MAC address (and possibly also the IP - address(es)) of devices.
This file also describes IP masquerading under Shorewall and - is installed in /etc/shorewall.
a shell program that reads the configuration files in - /etc/shorewall and configures - your firewall. This file is installed in /usr/share/shorewall.
a parameter file in /etc/shorewall - used to define one-to-one NAT.
a parameter file in /etc/shorewall - used to define Proxy Arp.
a parameter file in /etc/shorewall - used to define the treatment of packets under the norfc1918 interface option.
a parameter file in /etc/shorewall - used to define those hosts that can access the firewall when - Shorewall is stopped.
a parameter file in /etc/shorewall - used to define rules for classifying packets for Traffic Shaping/Control.
a parameter file in /etc/shorewall - used to define IPSec tunnels.
a shell program (requiring a Bourne shell or derivative) used - to control and monitor the firewall. This should be placed in - /sbin or in /usr/sbin (the install.sh script and - the rpm install this file in /sbin).
a parameter file in /etc/shorewall - used to define traffic accounting rules. This file was added in - version 1.4.7.
a file created in /usr/share/shorewall - that describes the version of Shorewall installed on your system.
files in /etc/shorewall that allow you to define your own - actions for rules in /etc/shorewall/rules.
files in /etc/shorewall - that define the actions included as a standard part of Shorewall.
You may use the file /etc/shorewall/params file - to set shell variables that you can then use in some of the other - configuration files.
It is suggested that variable names begin with an upper case letter - to distinguish them from variables used internally within the Shorewall - programs
The result will be the same as if the record had been written
net eth0 130.252.100.255 blacklist,norfc1918 |
Variables may be used anywhere in the other configuration files.
This file is used to define the network zones. There is one entry in - /etc/shorewall/zones for each zone; Columns in an - entry are:
short name for the zone. The name should be 5 characters or - less in length (4 characters or less if you are running Shorewall - 1.4.4 or later) and consist of lower-case letters or numbers. Short - names must begin with a letter and the name assigned to the firewall - is reserved for use by Shorewall itself. Note that the output - produced by iptables is much easier to read if you select short - names that are three characters or less in length. The name - “all” may not be used as a zone name nor may the zone - name assigned to the firewall itself via the FW variable in /etc/shorewall/shorewall.conf.
The name of the zone as displayed during Shorewall startup.
Any comments that you want to make about the zone. Shorewall - ignores these comments.
#ZONE DISPLAY COMMENTS -net Net Internet -loc Local Local networks -dmz DMZ Demilitarized zone |
You may add, delete and modify entries in the /etc/shorewall/zones - file as desired so long as you have at least one zone defined.
If you rename or delete a zone, you should perform “shorewall - stop; shorewall start” to install the change rather - than “shorewall restart”.
The order of entries in the /etc/shorewall/zones - file is significant in some cases.
This file is used to tell the firewall which of your firewall's - network interfaces are connected to which zone. There will be one entry in - /etc/shorewall/interfaces for each of your interfaces. Columns in an entry - are:
A zone defined in the /etc/shorewall/zones file or - “-”. If you specify “-”, you must use the - /etc/shorewall/hosts file to define the zones accessed via this - interface.
the name of the interface (examples: eth0, ppp0, ipsec+). Each - interface can be listed on only one record in this file.
You do not need to include the loopback interface (lo) in - this file.
the broadcast address(es) for the sub-network(s) attached to - the interface. This should be left empty for P-T-P interfaces (ppp*, - ippp*); if you need to specify options for such an interface, enter - “-” in this column. If you supply the special value - “detect” in this column, the firewall will - automatically determine the broadcast address. In order to use - “detect”:
the interface must be up before you start your firewall
the interface must only be attached to a single - sub-network (i.e., there must have a single broadcast address).
a comma-separated list of options. Possible options include:
(Added in version 1.4.7) - This option causes - /proc/sys/net/ipv4/conf/<interface>/arp_filter - to be set with the result that this interface will only answer - ARP “who-has” requests from hosts that are routed - out of that interface. Setting this option facilitates testing - of your firewall where multiple firewall interfaces are - connected to the same HUB/Switch (all interface connected to - the single HUB/Switch should have this option specified). Note - that using such a configuration in a production environment is - strongly recommended against.
(Added in version 1.4.6) - This option overrides NEWNOTSYN=No for packets arriving on - this interface. In other words, packets coming in on this - interface are processed as if NEWNOTSYN=Yes had been specified - in /etc/shorewall/shorewall.conf.
(Added in version 1.4.2) - This option causes Shorewall - to set up handling for routing packets that arrive on this - interface back out the same interface. If this option is - specified, the ZONE column may not contain “-”.
(added in version 1.3.11) - This option causes Shorewall - to make sanity checks on the header flags in TCP packets - arriving on this interface. Checks include Null flags, - SYN+FIN, SYN+RST and FIN+URG+PSH; these flag combinations are - typically used for “silent” port scans. Packets - failing these checks are logged according to the - TCP_FLAGS_LOG_LEVEL option in /etc/shorewall/shorewall.conf and are - disposed of according to the TCP_FLAGS_DISPOSITION option.
This option causes incoming packets on this interface to - be checked against the blacklist.
The interface is assigned an IP address via DHCP or is - used by a DHCP server running on the firewall. The firewall - will be configured to allow DHCP traffic to and from the - interface even when the firewall is stopped. You may also wish - to use this option if you have a static IP but you are on a - LAN segment that has a lot of Laptops that use DHCP and you - select the norfc1918 option - (see below).
Packets arriving on this interface and that have a - source address that is reserved in RFC 1918 or in other RFCs - will be dropped after being optionally logged. If packet mangling is enabled in - /etc/shorewall/shorewall.conf , - then packets arriving on this interface that have a - destination address that is reserved by one of these RFCs will - also be logged and dropped.
Addresses blocked by the standard rfc1918 file include those addresses - reserved by RFC1918 plus other ranges reserved by the IANA or - by other RFCs.
Beware that as IPv4 addresses become in increasingly - short supply, ISPs are beginning to use RFC 1918 addresses - within their own infrastructure. Also, many cable and DSL - “modems” have an RFC 1918 address that can be - used through a web browser for management and monitoring - functions. If you want to specify norfc1918 - on your external interface but need to allow access to certain - addresses from the above list, see FAQ - 14.
Invoke the Kernel's route filtering (anti-spoofing) - facility on this interface. The kernel will reject any packets - incoming on this interface that have a source address that - would be routed outbound through another interface on the - firewall.
If you specify this option for an interface then the - interface must be up prior to starting the firewall.
(Added in version 1.3.5) - This option causes Shorewall - to set /proc/sys/net/ipv4/conf/<interface>/proxy_arp - and is used when implementing Proxy ARP Sub-netting as - described at http://www.tldp.org/HOWTO/mini/Proxy-ARP-Subnet/. - Do not set this option if you - are implementing Proxy ARP through entries in /etc/shorewall/proxyarp.
(Added in version 1.3.10) - If this option is specified, - all connection requests from this interface are subject to - MAC Verification. May - only be specified for ethernet interfaces.
(Added in version 1.4.10) - If this option is specified, - the zone named in the ZONE column will contain only the hosts - routed through the interface named in the INTERFACE column. - Do not set this option on your external - (Internet) interface! The interface must be in the - UP state when Shorewall is [re]started.
(Added in version 2.0.0) - If this option is specified, - incoming connection requests will be checked to ensure that - they do not have a broadcast or multicast address as their - source. Any such packets will be dropped after being - optionally logged according to the setting of SMURF_LOG_LEVEL - in /etc/shorewall/shorewall.conf.
My recommendations concerning options:
External Interface -- tcpflags,blacklist,norfc1918,routefilter,nosmurfs
Wireless Interface -- maclist,routefilter,tcpflags,detectnets,nosmurfs
Use dhcp and proxyarp when needed.
Example 3. You have a conventional firewall setup in which eth0 connects to - a Cable or DSL modem and eth1 connects to your local network and eth0 - gets its IP address via DHCP. You want to check all packets entering - from the internet against the black list. - Your /etc/shorewall/interfaces file would be as follows:
#ZONE INTERFACE BROADCAST OPTIONS -net eth0 detect dhcp,norfc1918,blacklist |
For most applications, specifying zones entirely in terms of network - interfaces is sufficient. There may be times though where you need to - define a zone to be a more general collection of hosts. This is the - purpose of the /etc/shorewall/hosts file.
The only times that you need entries in /etc/shorewall/hosts - are:
You have more than one zone - connecting through a single interface; or
You have a zone - that has multiple subnetworks that connect through a single - interface and you want the Shorewall box to route traffic - between those subnetworks.
IF YOU DON'T HAVE EITHER OF THOSE - SITUATIONS THEN DON'T TOUCH THIS FILE!!
Columns in this file are:
A zone defined in the /etc/shorewall/zones file.
The name of a network interface followed by a colon (“:”) - followed by a comma-separated list either:
An IP address (example - eth1:192.168.1.3)
A subnet in CIDR notation (example - eth2:192.168.2.0/24)
The interface name much match an entry in - /etc/shorewall/interfaces.
If you are running a version of Shorewall earlier than - 1.4.6, only a single host/subnet address may be specified in an - entry in /etc/shorewall/hosts.
A comma-separated list of option
(Added in version 1.4.2) - This option causes Shorewall - to set up handling for routing packets sent by this host group - back back to the same group.
Added in version 1.3.10. If specified, connection - requests from the hosts specified in this entry are subject to - MAC Verification. - This option is only valid for ethernet interfaces.
If you don't define any hosts for a zone, the hosts in the zone - default to i0:0.0.0.0/0 , i1:0.0.0.0/0, ... where i0, i1, ... are the - interfaces to the zone.
You probably DON'T want to specify any hosts for your internet - zone since the hosts that you specify will be the only ones that you - will be able to access without adding additional rules.
Example 6. Your local interface is eth1 and you have two groups of local - hosts that you want to make into separate zones:
192.168.1.0/25 192.168.1.128/25 |
Your /etc/shorewall/interfaces file might look like:
#ZONE INTERFACE BROADCAST OPTIONS -net eth0 detect dhcp,norfc1918 -- eth1 192.168.1.127,192.168.1.255 |
The “-” in the ZONE column for eth1 tells Shorewall - that eth1 interfaces to multiple zones.
#ZONE HOST(S) OPTIONS -loc1 eth1:192.168.1.0/25 -loc2 eth1:192.168.1.128/25 |
Example 7. You have local interface eth1 with two IP addresses - - 192.168.1.1/24 and 192.168.12.1/24
Your /etc/shorewall/interfaces file might look like:
#ZONE INTERFACE BROADCAST OPTIONS -net eth0 detect dhcp,norfc1918 -- eth1 192.168.1.255,192.168.12.255 |
Your /etc/shorewall/hosts file might look like:
#ZONE HOST(S) OPTIONS -loc eth1:192.168.1.0/24 -loc eth1:192.168.12.0/24 |
If you are running Shorewall 1.4.6 or later, your hosts file may - look like:
#ZONE HOST(S) OPTIONS -loc eth1:192.168.1.0/24,192.168.12.0/24 |
The /etc/shorewall/interfaces and - /etc/shorewall/hosts file allow you to define - nested or overlapping zones. Such overlapping/nested zones are allowed - and Shorewall processes zones in the order that they appear in the - /etc/shorewall/zones file. So if you have nested - zones, you want the sub-zone to appear before the super-zone and in the - case of overlapping zones, the rules that will apply to hosts that - belong to both zones is determined by which zone appears first in - /etc/shorewall/zones.
Hosts that belong to more than one zone may be managed by the - rules of all of those zones. This is done through use of the special - CONTINUE policy described below.
This file is used to describe the firewall policy regarding - establishment of connections. Connection establishment is described in - terms of clients who initiate connections and - servers who receive those connection requests. - Policies defined in /etc/shorewall/policy describe - which zones are allowed to establish connections with other zones.
Policies established in /etc/shorewall/policy can - be viewed as default policies. If no rule in /etc/shorewall/rules applies - to a particular connection request then the policy from - /etc/shorewall/policy is applied.
Five policies are defined:
The connection is allowed.
The connection request is ignored.
The connection request is rejected with an RST (TCP) or an - ICMP destination-unreachable packet being returned to the client.
The connection is neither ACCEPTed, DROPped nor REJECTed. - CONTINUE may be used when one or both of the zones named in the - entry are sub-zones of or intersect with another zone. For more - information, see below.
(Added in version 1.4.1) - Shorewall should not set up any - infrastructure for handling traffic from the SOURCE zone to the DEST - zone. When this policy is specified, the LOG - LEVEL and BURST:LIMIT - columns must be left blank.
For each policy specified in /etc/shorewall/policy, you can indicate - that you want a message sent to your system log each time that the policy - is applied.
Entries in /etc/shorewall/policy have four columns as follows:
The name of a client zone (a zone defined in the /etc/shorewall/zones file , the name of the - firewall zone or “all”).
The name of a destination zone (a zone defined in the /etc/shorewall/zones file , the name of the - firewall zone or “all”). Shorewall automatically - allows all traffic from the firewall to itself so the name of the firewall zone cannot appear in - both the SOURCE and DEST columns.
The default policy for connection requests from the SOURCE - zone to the DESTINATION zone.
Optional. If left empty, no log message is generated when the - policy is applied. Otherwise, this column should contain an integer - or name indicating a syslog - level.
If left empty, TCP connection requests from the SOURCE zone to the DEST - zone will not be rate-limited. Otherwise, this column specifies the - maximum rate at which TCP connection requests will be accepted - followed by a colon (“:”) followed by the maximum burst - size that will be tolerated. Example: 10/sec:40 - specifies that the maximum rate of TCP connection requests allowed - will be 10 per second and a burst of 40 connections will be - tolerated. Connection requests in excess of these limits will be - dropped. See the rules file documentation - for an explaination of how rate limiting works.
In the SOURCE and DEST columns, you can enter “all” to - indicate all zones.
The default /etc/shorewall/policy file is as - follows.
#SOURCE DEST POLICY LOG LEVEL LIMIT:BURST -loc net ACCEPT -net all DROP info -all all REJECT info |
This table may be interpreted as follows:
All connection requests from the local network to hosts on the - internet are accepted.
All connection requests originating from the internet are - ignored and logged at level KERNEL.INFO.
All other connection requests are rejected and logged.
The firewall script processes the /etc/shorewall/policy - file from top to bottom and uses the first - applicable policy that it finds. For example, in the - following policy file, the policy for (loc, loc) connections would be - ACCEPT as specified in the first entry even though the third entry in - the file specifies REJECT.
#SOURCE DEST POLICY LOG LEVEL LIMIT:BURST -loc all ACCEPT -net all DROP info -loc loc REJECT info |
Shorewall allows a zone to be associated with more than one - interface or with multiple networks that interface through a single - interface. Beginning with Shorewall 1.4.1, Shorewall will ACCEPT all - traffic from a zone to itself provided that there is no explicit policy - governing traffic from that zone to itself (an explicit policy does not - specify “all” in either the SOURCE or DEST column) and that - there are no rules concerning connections from that zone to itself. If - there is an explicit policy or if there are one or more rules, then - traffic within the zone is handled just like traffic between zones is.
Any time that you have multiple interfaces associated with a - single zone, you should ask yourself if you really want traffic routed - between those interfaces. Cases where you might not want that behavior - are:
Multiple “net” interfaces to different ISPs. You - don't want to route traffic from one ISP to the other through - your firewall.
Multiple VPN clients. You don't necessarily want them to - all be able to communicate between themselves using your - gateway/router.
Beginning with Shorewall 2.0.0, you can control the traffic from - the firewall to itself. As with any zone, fw->fw traffic is enabled - by default. It is not necessary to define the loopback interface (lo) in - /etc/shorewall/interfaces in order to - define fw->fw rules or a fw->fw policy.
So long as there are no intra-zone rules for a zone, all - intra-zone traffic for that zone is accepted. As soon as you add a - single rule from the zone to itself, then ALL traffic from that zone - to itself is controlled by the rules and the first policy in - /etc/shorewall/policy that matches the zone to - itself.
Where zones are nested or overlapping, - the CONTINUE policy allows hosts that are within multiple zones to be - managed under the rules of all of these zones. Let's look at an - example:
/etc/shorewall/zones:
#ZONE DISPLAY COMMENTS -sam Sam Sam's system at home -net Internet The Internet -loc Local Local Network |
/etc/shorewall/interfaces:
#ZONE INTERFACE BROADCAST OPTIONS -- eth0 detect dhcp,norfc1918 -loc eth1 detect |
/etc/shorewall/hosts:
#ZONE HOST(S) OPTIONS -net eth0:0.0.0.0/0 -sam eth0:206.191.149.197 |
Sam's home system is a member of both the sam zone and the net - zone and as described above , that means - that sam must be listed before - net in /etc/shorewall/zones.
/etc/shorewall/policy:
#SOURCE DEST POLICY LOG LEVEL -loc net ACCEPT -sam all CONTINUE -net all DROP info -all all REJECT info |
The second entry above says that when Sam is the client, - connection requests should first be process under rules where the source - zone is sam and if there is no match - then the connection request should be treated under rules where the - source zone is net. It is important - that this policy be listed BEFORE the next policy (net - to all).
Partial /etc/shorewall/rules:
#ACTION SOURCE DEST PROTO DEST PORT(S) -... -DNAT sam loc:192.168.1.3 tcp ssh -DNAT net loc:192.168.1.5 tcp www -... |
Given these two rules, Sam can connect to the firewall's - internet interface with ssh and the connection request will be forwarded - to 192.168.1.3. Like all hosts in the net - zone, Sam can connect to the firewall's internet interface on TCP - port 80 and the connection request will be forwarded to 192.168.1.5. The - order of the rules is not significant.
Sometimes it is necessary to suppress port forwarding - for a sub-zone. For example, suppose that all hosts can SSH to the - firewall and be forwarded to 192.168.1.5 EXCEPT Sam. When Sam connects - to the firewall's external IP, he should be connected to the - firewall itself. Because of the way that Netfilter is constructed, this - requires two rules as follows:
#ACTION SOURCE DEST PROTO DEST PORT(S) -... -DNAT sam fw tcp ssh -DNAT net loc:192.168.1.3 tcp ssh -... |
The first rule allows Sam SSH access to the firewall. The second - rule says that any clients from the net zone with the exception of those - in the “sam” zone should have their connection port - forwarded to 192.168.1.3. If you need to exclude more than one zone in - this way, you can list the zones separated by commas (e.g., - net!sam,joe,fred). This technique also may be used when the ACTION is - REDIRECT.
The /etc/shorewall/rules file defines - exceptions to the policies established in the /etc/shorewall/policy - file. There is one entry in /etc/shorewall/rules for each of these rules. - Entries in this file only govern the establishment of new connections — - packets that are part of an existing connection or that establish a - connection that is related to an existing connection are automatically - accepted.
Rules for each pair of zones (source zone, destination zone) are - evaluated in the order that they appear in the file — the first match - determines the disposition of the connection request with a couple of - caveats:
LOG rules cause the connection request to be logged then - processing continues with the next rule in the file.
QUEUE rules cause the connection request to be passed to - user-space -- the user-space application can later insert them back - into the stream for further processing by following rules.
CONTINUE rules may cause the connection request to be - reprocessed using a different (source zone, destination zone) pair.
Entries in the file have the following columns:
These have the same meaning here as in the policy file - above.
Causes the connection request to be forwarded to the - system specified in the DEST column (port forwarding). - “DNAT” stands for “Destination - Network Address - Translation”
The above ACTION (DNAT) generates two iptables rules:
a header-rewriting rule in the Netfilter - “nat” table
an ACCEPT rule in the Netfilter “filter” - table.
DNAT- works like DNAT but only generates the - header-rewriting rule.
Causes the connection request to be redirected to a port - on the local (firewall) system.
The above ACTION (REDIRECT) generates two iptables - rules:
a header-rewriting rule in the Netfilter - “nat” table
an ACCEPT rule in the Netfilter “filter” - table.
REDIRECT- works like REDIRECT but only generates the - header-rewriting rule.
Log the packet -- requires a syslog level (see below).
Forward the packet to a user-space application. This - facility is provided to allow interfacing to ftwall for Kazaa filtering.
When the protocol specified in the PROTO column is TCP - (“tcp”, “TCP” or “6”), - Shorewall will only pass connection requests (SYN packets) - to user space. This is for compatibility with ftwall.
(Shorewall 1.4.9 and later) - An action defined in the - /etc/shorewall/actions - file.
The ACTION may optionally be followed by “:” and - a syslog level (example: - REJECT:info or ACCEPT:debug). This causes the packet to be logged at - the specified level prior to being processed according to the - specified ACTION. Note: if the ACTION is LOG then you MUST specify a - syslog level.
The use of DNAT or REDIRECT requires that you have NAT enabled - in your kernel configuration.
Describes the source hosts to which the rule applies.. The - contents of this field must begin with the name of a zone defined in - /etc/shorewall/zones, $FW or “all”. If the ACTION is - DNAT or REDIRECT, sub-zones may be excluded from the rule by - following the initial zone name with “!” and a - comma-separated list of those sub-zones to be excluded. There is an - example above.
If the source is not “all” then the source may be - further restricted by adding a colon (“:”) followed by - a comma-separated list of qualifiers. Qualifiers are may include:
refers to any connection requests arriving on the - specified interface (example loc:eth4). Beginning with - Shorwall 1.3.9, the interface name may optionally be followed - by a colon (“:”) and an IP address or subnet - (examples: loc:eth4:192.168.4.22, net:eth0:192.0.2.0/24).
refers to a connection request from the host with the - specified address (example net:155.186.235.151). If the ACTION - is DNAT, this must not be a DNS name.
refers to a connection request from any host in the - specified subnet (example net:155.186.235.0/24).
Describes the destination host(s) to which the rule applies. - May take most of the forms described above for SOURCE plus the - following two additional forms:
An IP address followed by a colon and the port number that the server is listening on - (service names from /etc/services are not allowed - example - loc:192.168.1.3:80).
A single port number (again, service names are not - allowed) -- this form is only allowed if the ACTION is REDIRECT - and refers to a server running on the firewall itself and - listening on the specified port.
Restrictions:
MAC addresses may not be specified.
In DNAT rules, only IP addresses may be given -- DNS names - are not permitted.
You may not specify both an IP address and an interface - name in the DEST column.
Unlike in the SOURCE column, a range of IP addresses may be - specified in the DEST column as <first address>-<last - address>. When the ACTION is DNAT or DNAT-, - connections will be assigned to the addresses in the range in a - round-robin fashion (load-balancing). This - feature is available with DNAT rules only with Shorewall 1.4.6 and - later versions; it is available with DNAT- rules in all versions - that support DNAT-.
Protocol. Must be a protocol name from /etc/protocols, a - number or “all”. Specifies the protocol of the - connection request.
Port or port range (<low port>:<high port>) - being connected to. May only be specified if the protocol is tcp, - udp or icmp. For icmp, this column's contents are interpreted as - an icmp type. If you don't want to specify DEST PORT(S) but need - to include information in one of the columns to the right, enter - “-” in this column. You may give a list of ports and/or - port ranges separated by commas. Port numbers may be either integers - or service names from /etc/services.
May be used to restrict the rule to a particular client port - or port range (a port range is specified as <low port - number>:<high port number>). If you don't want to - restrict client ports but want to specify something in the next - column, enter “-” in this column. If you wish to - specify a list of port number or ranges, separate the list elements - with commas (with no embedded white space). Port numbers may be - either integers or service names from /etc/services.
This column may only be non-empty if the ACTION is DNAT or - REDIRECT.
If DNAT or REDIRECT is the ACTION and the ORIGINAL DEST column - is left empty, any connection request arriving at the firewall from - the SOURCE that matches the rule will be forwarded or redirected. - This works fine for connection requests arriving from the internet - where the firewall has only a single external IP address. When the - firewall has multiple external IP addresses or when the SOURCE is - other than the internet, there will usually be a desire for the rule - to only apply to those connection requests directed to particular IP - addresses (see Example 2 below for another usage). Those IP - addresses are specified in the ORIGINAL DEST column as a - comma-separated list.
The IP address(es) may be optionally followed by - “:” and a second IP address. This latter address, if - present, is used as the source address for packets forwarded to the - server (This is called “Source NAT” or SNAT.
If this list begins with “!” then the rule will - only apply if the original destination address matches none of the - addresses listed.
When using SNAT, it is a good idea to qualify the source - with an IP address or subnet. Otherwise, it is likely that SNAT - will occur on connections other than those described in the rule. - The reason for this is that SNAT occurs in the Netfilter - POSTROUTING hook where it is not possible to restrict the scope of - a rule by incoming interface.
If SNAT is not used (no “:” and second IP - address), the original source address is used. If you want any - destination address to match the rule but want to specify SNAT, - simply use a colon followed by the SNAT address.
Beginning with Shorewall version 1.4.7, you may rate-limit - ACCEPT, DNAT[-], REDIRECT[-] or LOG rules with an entry in this - column. Entries have the form
<rate>/<interval>[:<burst>] |
where <rate> is the number of connections per - <interval> (“sec” or “min”) and - <burst> is the largest burst permitted. If no burst value is - given, a value of 5 is assumed.
There may be no whitespace embedded in the specification.
Example 9. Let's take
ACCEPT<2/sec:4> net dmz tcp 80 |
The first time this rule is reached, the packet will be - accepted; in fact, since the burst is 4, the first four packets - will be accepted. After this, it will be 500ms (1 second divided - by the rate of 2) before a packet will be accepted from this rule, - regardless of how many packets reach it. Also, every 500ms which - passes without matching a packet, one of the bursts will be - regained; if no packets hit the rule for 2 second, the burst will - be fully recharged; back where we started.
When rate limiting is specified on a rule with - “all” in the SOURCE or DEST fields below, the limit - will apply to each pair of zones individually rather than as a - single limit for all pairs of zones covered by the rule.
If you want to specify any following columns but no rate - limit, place “-” in this column.
Beginning with Shorewall release 1.4.7, output rules from the - firewall itself may be restricted to a particular set of users - and/or user groups. See the User Set - Documentation for details.
Example 10. You wish to forward all ssh connection requests from the internet - to local system 192.168.1.3. You wish to limit the number of connections - to 4/minute with a burst of 8 (Shorewall 1.4.7 and later only):
#ACTION SOURCE DEST PROTO DEST PORT(S) -DNAT<4/min:8> net loc:192.168.1.3 tcp ssh |
Example 11. You want to redirect all local www connection requests EXCEPT - those to your own http server (206.124.146.177) to a Squid transparent - proxy running on the firewall and listening on port 3128. Squid will of - course require access to remote web servers. This example shows yet - another use for the ORIGINAL DEST column; here, connection requests that - were NOT (notice the “!”) originally destined to - 206.124.146.177 are redirected to local port 3128.
#ACTION SOURCE DEST PROTO DEST PORT(S) SOURCE ORIGINAL -# PORT(S) DEST -REDIRECT loc 3128 tcp www - !206.124.146.177 -ACCEPT fw net tcp www |
Example 12. You want to run a web server at 155.186.235.222 in your DMZ and - have it accessible remotely and locally. the DMZ is managed by Proxy ARP - or by classical sub-netting.
#ACTION SOURCE DEST PROTO DEST PORT(S) -ACCEPT net dmz:155.186.235.222 tcp www -ACCEPT loc dmz:155.186.235.222 tcp www |
Example 13. You want to run wu-ftpd on 192.168.2.2 in your masqueraded DMZ. - Your internet interface address is 155.186.235.151 and you want the FTP - server to be accessible from the internet in addition to the local - 192.168.1.0/24 and dmz 192.168.2.0/24 subnetworks.
since the server is in the 192.168.2.0/24 subnetwork, - we can assume that access to the server from that subnet will not - involve the firewall (but see FAQ 2)
unless - you have more than one external IP address, you can leave the ORIGINAL - DEST column blank in the first rule. You cannot leave it blank in the - second rule though because then all ftp connections originating in the - local subnet 192.168.1.0/24 would be sent to 192.168.2.2 regardless of - the site that the user was trying to connect to. That is clearly not - what you want.
#ACTION SOURCE DEST PROTO DEST PORT(S) SOURCE ORIGINAL -# PORT(S) DEST -DNAT net dmz:192.168.2.2 tcp ftp -DNAT loc:192.168.1.0/24 dmz:192.168.2.2 tcp ftp - 155.186.235.151 |
If you are running wu-ftpd, you should restrict the range of - passive in your /etc/ftpaccess file. I only need a few simultaneous FTP - sessions so I use port range 65500-65535. In /etc/ftpaccess, this entry - is appropriate:
passive ports 0.0.0.0/0 65500 65534 |
If you are running pure-ftpd, you would include “-p - 65500:65534” on the pure-ftpd runline.
The important point here is to ensure that the port range used for - FTP passive connections is unique and will not overlap with any usage on - the firewall system.
Example 14. You wish to allow unlimited DMZ access to the host with MAC - address 02:00:08:E3:FA:55.
#ACTION SOURCE DEST PROTO DEST PORT(S) -ACCEPT loc:~02-00-08-E3-FA-55 dmz all |
Example 15. You wish to allow access to the SMTP server in your DMZ from all - zones.
#ACTION SOURCE DEST PROTO DEST PORT(S) -ACCEPT all dmz tcp 25 |
When “all” is used as a source or - destination, intra-zone traffic is not affected. In this example, if - there were two DMZ interfaces then the above rule would NOT enable SMTP - traffic between hosts on these interfaces.
Example 16. Your firewall's external interface has several IP addresses - but you only want to accept SSH connections on address 206.124.146.176.
#ACTION SOURCE DEST PROTO DEST PORT(S) -ACCEPT net fw:206.124.146.176 tcp 22 |
Example 17. (For advanced users running Shorewall version 1.3.13 or later). - From the internet, you with to forward tcp port 25 directed to - 192.0.2.178 and 192.0.2.179 to host 192.0.2.177 in your DMZ. You also - want to allow access from the internet directly to tcp port 25 on - 192.0.2.177.
#ACTION SOURCE DEST PROTO DEST PORT(S) SOURCE ORIGINAL -# PORT(S) DEST -DNAT- net dmz:192.0.2.177 tcp 25 - 192.0.2.178 -DNAT- net dmz:192.0.2.177 tcp 25 - 192.0.2.179 -ACCEPT net dmz:192.0.2.177 tcp 25 |
Using “DNAT-” rather than “DNAT” avoids - two extra copies of the third rule from being generated.
Example 18. (Shorewall version 1.4.6 or later). You have 9 http servers - behind a Shorewall firewall and you want connection requests to be - distributed among your servers. The servers are - 192.168.1.101-192.168.1.109.
#ACTION SOURCE DEST PROTO DEST PORT(S) -DNAT net loc:192.168.1.101-192.168.1.109 tcp 80 |
The /etc/shorewall/masq file is used to define classical IP - Masquerading and Source Network Address Translation (SNAT). There is one - entry in the file for each subnet that you want to masquerade. In order to - make use of this feature, you must have NAT enabled.
Columns are:
The interface that will masquerade the subnet; this is - normally your internet interface. This interface name can be - optionally qualified by adding “:” and a subnet or host - IP. When this qualification is added, only packets addressed to that - host or subnet will be masqueraded. Beginning with Shorewall version - 1.4.10, the interface name can be qualified with ":" - followed by a comma separated list of hosts and/or subnets. If this - list begins with “!” (e.g., “eth0:!192.0.2.8/29,192.0.2.32/29”) - then only packets addressed to destinations not - listed will be masqueraded; otherwise (e.g., “eth0:192.0.2.8/29,192.0.2.32/29”), - traffic will be masqueraded if it does - match one of the listed addresses.
Beginning with Shorewall version 1.3.14, if you have set - ADD_SNAT_ALIASES=Yes in /etc/shorewall/shorewall.conf, you can cause - Shorewall to create an alias label of the form - interfacename:digit (e.g., eth0:0) by placing - that label in this column. See example 5 below. Alias labels created - in this way allow the alias to be visible to the ipconfig utility. - THAT IS THE ONLY THING THAT THIS LABEL IS GOOD - FOR AND IT MAY NOT APPEAR ANYWHERE ELSE IN YOUR SHOREWALL - CONFIGURATION.
The subnet that you want to have masqueraded through the - INTERFACE. This may be expressed as a single IP address, a subnet or - an interface name. In the latter instance, the interface must be - configured and started before Shorewall is started as Shorewall will - determine the subnet based on information obtained from the - “ip” utility.
When using Shorewall 1.3.13 or earlier, when an interface - name is specified, Shorewall will only masquerade traffic from the - first subnetwork on the named interface; if the interface - interfaces to more that one subnetwork, you will need to add - additional entries to this file for each of those other - subnetworks. Beginning with Shorewall 1.3.14, shorewall will - masquerade/SNAT traffic from any host that is routed through the - named interface.
The subnet may be optionally followed by “!” and - a comma-separated list of addresses and/or subnets that are to be - excluded from masquerading.
The source address to be used for outgoing packets. This - column is optional and if left blank, the current primary IP address - of the interface in the first column is used. If you have a static - IP on that interface, listing it here makes processing of output - packets a little less expensive for the firewall. If you specify an - address in this column, it must be an IP address configured on the - INTERFACE or you must have ADD_SNAT_ALIASES enabled in /etc/shorewall/shorewall.conf. Beginning with Shorewall version 1.4.6, you may - include a range of IP addresses in this column to indicate that - Netfilter should use the addresses in the range in round-robin - fashion. Beginning with Shorewall version 1.4.7, you may include a - list of ranges and/or addresses in this column; again, Netfilter - will use all listed ranges/addresses in rounde-robin fashion.
Example 19. You have eth0 connected to a cable modem and eth1 connected to - your local subnetwork 192.168.9.0/24. Your /etc/shorewall/masq file - would look like:
#INTERFACE SUBNET ADDRESS -eth0 192.168.9.0/24 |
Example 20. You have a number of IPSEC tunnels through ipsec0 and you want to - masquerade traffic from your 192.168.9.0/24 subnet to the remote subnet - 10.1.0.0/16 only.
#INTERFACE SUBNET ADDRESS -ipsec0:10.1.0.0/16 192.168.9.0/24 |
Example 21. You have a DSL line connected on eth0 and a local network - (192.168.10.0/24) connected to eth1. You want all local->net - connections to use source address 206.124.146.176.
#INTERFACE SUBNET ADDRESS -eth0 192.168.10.0/24 206.124.146.176 |
Example 22. Same as example 3 except that you wish to exclude 192.168.10.44 - and 192.168.10.45 from the SNAT rule.
#INTERFACE SUBNET ADDRESS -eth0 192.168.10.0/24!192.168.10.44,192.168.10.45 206.124.146.176 |
Example 23. (Shorewall version >= 1.3.14): - You have a second IP address (206.124.146.177) assigned to you and wish - to use it for SNAT of the subnet 192.168.12.0/24. You want to give that - address the name eth0:0. You must have ADD_SNAT_ALIASES=Yes in /etc/shorewall/shorewall.conf.
#INTERFACE SUBNET ADDRESS -eth0:0 192.168.12.0/24 206.124.146.177 |
If you want to use proxy ARP on an entire sub-network, I suggest - that you look at the Proxy ARP Subnet - Mini HOWTO. If you decide to use the technique described in that - HOWTO, you can set the proxy_arp flag for an interface (/proc/sys/net/ipv4/conf/<interface>/proxy_arp) - by including the proxyarp option in the - interface's record in /etc/shorewall/interfaces. When using Proxy - ARP sub-netting, you do NOT include any - entries in /etc/shorewall/proxyarp.
The /etc/shorewall/proxyarp file is used to - define Proxy ARP. The file is typically - used for enabling Proxy ARP on a small set of systems since you need one - entry in this file for each system using proxy ARP. Columns are:
address of the system.
the interface that connects to the system. If the interface is - obvious from the subnetting, you may enter “-” in this - column.
the external interface that you want to honor ARP requests for - the ADDRESS specified in the first column.
If you already have a route through INTERFACE to ADDRESS, this - column should contain “Yes” or “yes”. If - you want Shorewall to add the route, the column should contain - “No” or “no”.
If you specify "No" or "no" in the HAVEROUTE - column, Shorewall will automatically add a route to the host in the - ADDRESS column through the interface in the INTERFACE column. If you - enter “No” or “no” in the PERSISTENT - column or if you leave the column empty, that route will be deleted - if you issue a shorewall stop or - shorewall clear command. If you place - “Yes” or “yes” in the PERSISTENT column, - then those commands will not cause the route to be deleted.
After you have made a change to the /etc/shorewall/proxyarp - file, you may need to flush the ARP cache of all routers on - the LAN segment connected to the interface specified in the EXTERNAL - column of the change/added entry(s). If you are having problems - communicating between an individual host (A) on that segment and a - system whose entry has changed, you may need to flush the ARP cache on - host A as well.
ISPs typically have ARP configured with long TTL (hours!) so if - your ISPs router has a stale cache entry (as seen using “tcpdump - -nei <external interface> host <IP addr>”), it - may take a long while to time out. I personally have had to contact my - ISP and ask them to delete a stale entry in order to restore a system to - working order after changing my proxy ARP settings.
Example 25. You have public IP addresses 155.182.235.0/28. You configure your - firewall as follows:
eth0 - 155.186.235.1 (internet connection) eth1 - - 192.168.9.0/24 (masqueraded local systems) eth2 - 192.168.10.1 - (interface to your DMZ) |
In your DMZ, you want to install a Web/FTP server with public - address 155.186.235.4. On the Web server, you subnet just like the - firewall's eth0 and you configure 155.186.235.1 as the default - gateway. In your /etc/shorewall/proxyarp file, you - will have:
#ADDRESS INTERFACE EXTERNAL HAVEROUTE -155.186.235.4 eth2 eth0 NO |
You may want to configure the servers in your DMZ with - a subnet that is smaller than the subnet of your internet interface. See - the Proxy - ARP Subnet Mini HOWTO for details. In this case you will want to - place “Yes” in the HAVEROUTE column.
Do not use Proxy ARP and FreeS/Wan on the same system unless you - are prepared to suffer the consequences. If you start or restart - Shorewall with an IPSEC tunnel active, the proxied IP addresses are - mistakenly assigned to the IPSEC tunnel device (ipsecX) rather than to - the interface that you specify in the INTERFACE column of - /etc/shorewall/proxyarp. I haven't had the time - to debug this problem so I can't say if it is a bug in the Kernel or - in FreeS/Wan.
You might be able to work around - this problem using the following (I haven't tried it):
In /etc/shorewall/init, include:
qt /etc/init.d/ipsec stop |
In /etc/shorewall/start, include:
qt /etc/init.d/ipsec start |
The /etc/shorewall/nat file is used to define - one-to-one NAT. There is one entry in the file for each one-to-one NAT - relationship that you wish to define. In order to make use of this - feature, you must have NAT enabled.
If all you want to do is forward ports to servers behind your - firewall, you do NOT want to use one-to-one NAT. Port forwarding can be - accomplished with simple entries in the rules file. - Also, in most cases Proxy ARP provides a - superior solution to one-to-one NAT because the internal systems are - accessed using the same IP address internally and externally.
Columns in an entry are:
External IP address
This should NOT be the primary IP address of the interface - named in the next column.
Interface that you want the EXTERNAL IP address to appear on. - Beginning with Shorewall version 1.3.14, if you have set - ADD_IP_ALIASES=Yes in /etc/shorewall/shorewall.conf, you can specify an - alias label of the form interfacename:digit - (e.g., eth0:0) and Shorewall will create the alias with that label. - Alias labels created in this way allow the alias to be visible to - the ipconfig utility. THAT IS THE ONLY THING - THAT THIS LABEL IS GOOD FOR AND IT MAY NOT APPEAR ANYWHERE ELSE IN - YOUR SHOREWALL CONFIGURATION.
Internal IP address.
If “Yes” or “yes”, NAT will be - effective from all hosts. If “No” or “no” - (or if left empty) then NAT will be effective only through the - interface named in the INTERFACE column.
If Yes or yes and the ALL INTERFACES column contains Yes or - yes, NAT will be effective from the firewall system.
For this to work, you must be running kernel 2.4.19 or later - and iptables 1.2.6a or later and you must have enabled CONFIG_IP_NF_NAT_LOCAL in your kernel.
The /etc/shorewall/tunnels file allows you to define IPSec, GRE, - IPIP, OpenVPN, PPTP - and 6to4.tunnels with end-points on your firewall. To use ipsec, you must - install version 1.9, 1.91 or the current FreeS/WAN development - snapshot.
For kernels 2.4.4 and above, you will need to use version 1.91 or - a development snapshot as patching with version 1.9 results in kernel - compilation errors.
Instructions for setting up IPSEC tunnels - may be found here, instructions for IPIP and GRE - tunnels are here, instructions for OpenVPN - tunnels are here, instructions for PPTP - tunnels are here, instructions for 6to4 - tunnels are here, and instructions for integrating Shorewall with other types of - tunnels are here.
This file is used to set the following firewall parameters:
(Added at version 2.0.0) - Specifies the logging level for - smurf packets (see the nosmurfs - option in /etc/shorewall/interfaces). - If set to the empty value ( SMURF_LOG_LEVEL="" ) then smurfs - are not logged.
(Added at version 1.4.9) - The value of this variable - determines the possible file extensions of kernel modules. The - default value is "o gz ko and o.gz". See /etc/shorewall/modules for more details.
(Added at version 1.4.7) - The value of this variable affects - Shorewall's stopped - state. When ADMINISABSENTMINDES=No, only traffic to/from - those addresses listed in /etc/shorewall/routestopped is accepted - when Shorewall is stopped.When ADMINISABSENTMINDED=Yes, in addition - to traffic to/from addresses in /etc/shorewall/routestopped, - connections that were active when Shorewall stopped continue to work - and all new connections from the firewall system itself are allowed. - If this variable is not set or is given the empty value then - ADMINISABSENTMINDED=No is assumed.
(Added at version 1.4.6) - This parameter is used to specify - the shell program to be used to interpret the firewall script - (/usr/share/shorewall/firewall). If not specified or specified as a - null value, /bin/sh is assumed.
(Added at version 1.4.4) - The value of this variable generate - the --log-prefix setting for Shorewall logging rules. It contains a - “printf” formatting template which accepts three - arguments (the chain name, logging rule number (optional) and the - disposition). To use LOGFORMAT with fireparse, set it as:
LOGFORMAT="fp=%s:%d a=%s " |
If the LOGFORMAT value contains the substring “%d” - then the logging rule number is calculated and formatted in that - position; if that substring is not included then the rule number is - not included. If not supplied or supplied as empty - (LOGFORMAT="") then “Shorewall:%s:%s:” is - assumed.
/sbin/shorewall uses the leading part of - the LOGFORMAT string (up to but not including the first - “%”) to find log messages in the “show log”, - “status” and “hits” commands. This part - should not be omitted (the LOGFORMAT should not begin with - “%”) and the leading part should be sufficiently - unique for /sbin/shorewall to identify - Shorewall messages.
(Added at version 1.3.13) - If this option is set to - “No” then Shorewall won't clear the current traffic - control rules during [re]start. This setting is intended for use by - people that prefer to configure traffic shaping when the network - interfaces come up rather than when the firewall is started. If that - is what you want to do, set TC_ENABLED=Yes and CLEAR_TC=No and do - not supply an /etc/shorewall/tcstart file. That - way, your traffic shaping rules can still use the “fwmark” - classifier based on packet marking defined in - /etc/shorewall/tcrules. If not specified, CLEAR_TC=Yes is assumed.
(Added at version 1.3.12) - If your kernel has a FORWARD chain - in the mangle table, you may set MARK_IN_FORWARD_CHAIN=Yes to cause - the marking specified in the tcrules file to occur in - that chain rather than in the PREROUTING chain. This permits you to - mark inbound traffic based on its destination address when SNAT or - Masquerading are in use. To determine if your kernel has a FORWARD - chain in the mangle table, use the “/sbin/shorewall - show mangle” command; if a FORWARD chain is - displayed then your kernel will support this option. If this option - is not specified or if it is given the empty value (e.g., - MARK_IN_FORWARD_CHAIN="") then MARK_IN_FORWARD_CHAIN=No is - assumed.
(Added at version 1.3.12) - This parameter determines the - level at which packets logged under the “norfc1918” - mechanism are logged. The value must be a valid syslog level and if no level is - given, then info is assumed. Prior to Shorewall version 1.3.12, - these packets are always logged at the info level.
(Added in Version 1.3.11) - Determines the disposition of TCP - packets that fail the checks enabled by the tcpflags interface option and must have - a value of ACCEPT (accept the packet), REJECT (send an RST response) - or DROP (ignore the packet). If not set or if set to the empty value - (e.g., TCP_FLAGS_DISPOSITION="") then - TCP_FLAGS_DISPOSITION=DROP is assumed.
(Added in Version 1.3.11) - Determines the syslog level for logging - packets that fail the checks enabled by the tcpflags interface option.The value must - be a valid syslogd log level. If you don't want to log these - packets, set to the empty value (e.g., - TCP_FLAGS_LOG_LEVEL="").
(Added in Version 1.3.10) - Determines the disposition of - connections requests that fail MAC - Verification and must have the value ACCEPT (accept the - connection request anyway), REJECT (reject the connection request) - or DROP (ignore the connection request). If not set or if set to the - empty value (e.g., MACLIST_DISPOSITION="") then - MACLIST_DISPOSITION=REJECT is assumed.
(Added in Version 1.3.10) - Determines the syslog level for logging - connection requests that fail MAC - Verification. The value must be a valid syslogd log level. - If you don't want to log these connection requests, set to the - empty value (e.g., MACLIST_LOG_LEVEL="").
(Added in Version 1.3.8) - When set to “Yes” or - “yes”, Shorewall will filter TCP packets that are not - part of an established connention and that are not SYN packets (SYN - flag on - ACK flag off). If set to “No”, Shorewall will - silently drop such packets. If not set or set to the empty value - (e.g., “NEWNOTSYN=”), NEWNOTSYN=No is assumed.
If you have a HA setup with failover to another firewall, you - should have NEWNOTSYN=Yes on both firewalls. You should also select - NEWNOTSYN=Yes if you have asymmetric routing.
(Added in Version 1.3.6) - Beginning with version 1.3.6, - Shorewall drops non-SYN TCP packets that are not part of an existing - connection. If you would like to log these packets, set LOGNEWNOTSYN - to the syslog level at - which you want the packets logged. Example: LOGNEWNOTSYN=ULOG|
Packets logged under this option are usually the result of - broken remote IP stacks rather than the result of any sort of - attempt to breach your firewall.
(Added in Version 1.3.4) - If set to “Yes” or - “yes”, Shorewall will detect the first IP address of - the interface to the source zone and will include this address in - DNAT rules as the original destination IP address. If set to - “No” or “no”, Shorewall will not detect - this address and any destination IP address will match the DNAT - rule. If not specified or empty, “DETECT_DNAT_ADDRS=Yes” - is assumed.
If set to “No” or “no”, port - forwarding rules can override the contents of the /etc/shorewall/nat file. If set to “Yes” or - “yes”, port forwarding rules cannot override one-to-one - NAT. If not set or set to an empty value, “Yes” is - assumed.
This parameter specifies the name of the firewall zone. If not - set or if set to an empty string, the value “fw” is - assumed.
This parameter should be set to the name of a file that the - firewall should create if it starts successfully and remove when it - stops. Creating and removing this file allows Shorewall to work with - your distribution's initscripts. For RedHat, this should be set - to /var/lock/subsys/shorewall. For Debian, the value is - /var/state/shorewall and in LEAF it is /var/run/shorwall. Example: - SUBSYSLOCK=/var/lock/subsys/shorewall.
This parameter specifies the name of a directory where - Shorewall stores state information. If the directory doesn't - exist when Shorewall starts, it will create the directory. Example: - STATEDIR=/tmp/shorewall.
If you change the STATEDIR variable while the firewall is - running, create the new directory if necessary then copy the - contents of the old directory to the new directory.
This parameter specifies the directory where your kernel - netfilter modules may be found. If you leave the variable empty, - Shorewall will supply the value "/lib/modules/`uname - -r`/kernel/net/ipv4/netfilter.
These parameters set the match rate and initial burst size for - logged packets. Please see the iptables man page for a description - of the behavior of these parameters (the iptables option --limit is - set by LOGRATE and --limit-burst is set by LOGBURST). If both - parameters are set empty, no rate-limiting will occur.
This parameter tells the /sbin/shorewall program where to look - for Shorewall messages when processing the “show log”, - “monitor”, “status” and “hits” - commands. If not assigned or if assigned an empty value, - /var/log/messages is assumed.
This parameter determines whether Shorewall enables or - disables IPV4 Packet Forwarding (/proc/sys/net/ipv4/ip_forward). - Possible values are:
packet forwarding will be enabled.
packet forwarding will be disabled.
Shorewall will neither enable nor disable packet - forwarding.
If this variable is not set or is given an empty value - (IP_FORWARD="") then IP_FORWARD=On is assumed.
This parameter determines whether Shorewall automatically adds - the external address(es) in /etc/shorewall/nat. - If the variable is set to “Yes” or “yes” - then Shorewall automatically adds these aliases. If it is set to - “No” or “no”, you must add these aliases - yourself using your distribution's network configuration tools.
If this variable is not set or is given an empty value - (ADD_IP_ALIASES="") then ADD_IP_ALIASES=Yes is assumed.
This parameter determines whether Shorewall automatically adds - the SNAT ADDRESS in /etc/shorewall/masq. If - the variable is set to “Yes” or “yes” then - Shorewall automatically adds these addresses. If it is set to - “No” or “no”, you must add these addresses - yourself using your distribution's network configuration tools.
If this variable is not set or is given an empty value - (ADD_SNAT_ALIASES="") then ADD_SNAT_ALIASES=No is assumed.
This parameter determines the logging level of mangled/invalid - packets controlled by the “dropunclean and logunclean” - interface options. If LOGUNCLEAN is empty (LOGUNCLEAN=) then packets - selected by “dropclean” are dropped silently (“logunclean” - packets are logged under the “info” log level). - Otherwise, these packets are logged at the specified level (Example: - LOGUNCLEAN=debug).
This parameter determines the disposition of packets from - blacklisted hosts. It may have the value DROP if the packets are to - be dropped or REJECT if the packets are to be replied with an ICMP - port unreachable reply or a TCP RST (tcp only). If you do not assign - a value or if you assign an empty value then DROP is assumed.
This paremter determines if packets from blacklisted hosts are - logged and it determines the syslog level that they are to be logged - at. Its value is a syslog level - (Example: BLACKLIST_LOGLEVEL=debug). If you do not assign a value or - if you assign an empty value then packets from blacklisted hosts are - not logged.
This parameter enables the TCP Clamp MSS to PMTU feature of - Netfilter and is usually required when your internet connection is - through PPPoE or PPTP. If set to “Yes” or - “yes”, the feature is enabled. If left blank or set to - “No” or “no”, the feature is not enabled.
This option requires CONFIG_IP_NF_TARGET_TCPMSS in your kernel.
If this parameter is given the value “Yes” or - “yes” then route filtering (anti-spoofing) is enabled - on all network interfaces which are brought up while Shorewall is in - the started state. The default value is “no”.
The file /etc/shorewall/modules contains - commands for loading the kernel modules required by Shorewall-defined - firewall rules. Shorewall will source this file during start/restart - provided that it exists and that the directory specified by the MODULESDIR - parameter exists (see /etc/shorewall/shorewall.conf above).
The file that is released with Shorewall calls the Shorewall - function “loadmodule” for the set of modules that I load.
The loadmodule function is called as follows:
loadmodule <modulename> [ <module parameters> ] |
where
is the name of the modules without the trailing - “.o” (example ip_conntrack).
Optional parameters to the insmod utility.
The function determines if the module named by <modulename> - is already loaded and if not then the function determines if the - “.o” file corresponding to the module exists in the - <moduledirectory>; if so, then the following - command is executed:
insmod <moduledirectory>/<modulename>.o <module parameters> |
If the file doesn't exist, the function determines of the - “.o.gz” file corresponding to the module exists in the - moduledirectory. If it does, the function assumes - that the running configuration supports compressed modules and execute the - following command:
insmod <moduledirectory>/<modulename>.o.gz <module parameters> |
Beginning with the 1.4.9 Shorewall release, the value of the - MODULE_SUFFIX option in determines which files the loadmodule function - looks for if the named module doesn't exist. For each file - <extension> listed in MODULE_SUFFIX (default - "o gz ko o.gz"), the function will append a period (".") - and the extension and if the resulting file exists then the following - command will be executed:
insmod moduledirectory/<modulename>.<extension> <module parameters> |
The /etc/shorewall/tos file allows you to set - the Type of Service field in packet headers based on packet source, packet - destination, protocol, source port and destination port. In order for this - file to be processed by Shorewall, you must have mangle support enabled.
Entries in the file have the following columns:
The source zone. May be qualified by following the zone name - with a colon (“:”) and either an IP address, an IP - subnet, a MAC address in - Shorewall Format or the name of an interface. This column - may also contain the name of the firewall zone to indicate packets - originating on the firewall itself or “all” to indicate - any source.
The destination zone. May be qualified by following the zone - name with a colon (“:”) and either an IP address or an - IP subnet. Because packets are marked prior to routing, you may not - specify the name of an interface. This column may also contain - “all” to indicate any destination.
The name of a protocol in /etc/protocols or - the protocol's number.
The source port or a port range. For all ports, place a hyphen - (“-”) in this column.
The destination port or a port range. To indicate all ports, - place a hyphen (“-”) in this column.
The type of service. Must be one of the following:
Minimize-Delay (16) |
Maximize-Throughput (8) |
Maximize-Reliability (4) |
Minimize-Cost (2) |
Normal-Service (0) |
/etc/shorewall/tos file that is included with - Shorewall
#SOURCE DEST PROTOCOL SOURCE PORTS(S) DEST PORTS(S) TOS -all all tcp - ssh 16 -all all tcp ssh - 16 -all all tcp - ftp 16 -all all tcp ftp - 16 -all all tcp - ftp-data 8 -all all tcp ftp-data - 8 |
Users have reported that odd routing problems result from adding - the ESP and AH protocols to the /etc/shorewall/tos - file.
Each line in /etc/shorewall/blacklist contains - an IP address, a MAC address in Shorewall Format or subnet address.
Packets from hosts listed in the - blacklist file will be disposed of according to the value assigned to the - BLACKLIST_DISPOSITION and BLACKLIST_LOGLEVEL - variables in /etc/shorewall/shorewall.conf. Only packets arriving on - interfaces that have the “blacklist” - option in /etc/shorewall/interfaces are checked - against the blacklist. The black list is designed to prevent listed - hosts/subnets from accessing services on your - network.
Beginning with Shorewall 1.3.8, the blacklist file has three - columns:
As described above.
Optional. If specified, only packets specifying this protocol - will be blocked.
Optional; may only be given if PROTOCOL is tcp, udp or icmp. - Expressed as a comma-separated list of port numbers or service names - (from /etc/services). If present, only packets destined for the - specified protocol and one of the listed ports are blocked. When the - PROTOCOL is icmp, the PORTS column contains a comma-separated list - of ICMP type numbers or names (see “iptables -h icmp”).
Shorewall also has a dynamic - blacklist capability.
The Shorewall blacklist file is NOT - designed to police your users' web browsing -- to do that, I suggest - that you install and configure Squid - with SquidGuard.
This file lists the subnets affected by the norfc1918 interface option. Columns in the - file are:
The subnet using VLSM notation (e.g., 192.168.0.0/16).
What to do with packets to/from the SUBNET:
Process the packet normally thru the rules and policies.
Silently drop the packet.
Log then drop the packet -- see the RFC1918_LOG_LEVEL - parameter above.
This file defines the hosts that are accessible from the firewall - when the firewall is stopped. Columns in the file are:
The firewall interface through which the host(s) comminicate - with the firewall.
A comma-separated list of IP/Subnet addresses. If not supplied - or supplied as “-” then 0.0.0.0/0 is assumed.
This file is described in the MAC - Validation Documentation.
This file is described in the ECN Control - Documentation.
This file is described in the Traffic - Accounting Documentation.
Revision History | ||
---|---|---|
Revision 1.14 | 2004-02-13 | TE |
Add - a note about the order of rules. | ||
Revision 1.13 | 2004-02-03 | TE |
Update - for Shorewall 2.0. | ||
Revision 1.12 | 2004-01-21 | TE |
Add - masquerade destination list. | ||
Revision 1.12 | 2004-01-18 | TE |
Correct - typo. | ||
Revision 1.11 | 2004-01-05 | TE |
Standards - Compliance | ||
Revision 1.10 | 2004-01-05 | TE |
Improved - formatting of DNAT- and REDIRECT- for clarity | ||
Revision 1.9 | 2003-12-25 | MN |
Initial - Docbook Conversion Complete |
Copyright © 2001-2004 Thomas M. Eastep
Permission 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”.
2004-02-03
Table of Contents
Answer: Check out the QuickStart Guides.
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 7777 |
If 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 PORT - column specify the range as <low-port>:<high-port>.
Answer: 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 the section called “(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.”).
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.
Answer: 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 nat”
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); or
you 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); or
your 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.
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.
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 an IP solution to the accessibility problem - rather than a DNS solution, then 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.
If you are running Shorewall 1.4.0 or earlier see the 1.3 FAQ for instructions suitable for - those releases.
If you are running Shorewall 1.4.1 or Shorewall 1.4.1a, please - upgrade to Shorewall 1.4.2 or later.
Otherwise:
In this configuration, all loc->loc - traffic will look to the server as if it came from the firewall rather - than from the original client!
In /etc/shorewall/interfaces:
#ZONE INTERFACE BROADCAST OPTIONS
-loc eth1 detect routeback |
In /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.69:192.168.1.254 |
That 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 or later then include this in /etc/shorewall/init:
ETH0_IP=`find_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_IP:192.168.1.254 |
Using this technique, you will want to configure your - DHCP/PPPoE client to automatically restart Shorewall each time that - you get a new IP address.
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=0 |
Answer: 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 routing all - Z->Z traffic through your firewall then:
Set the Z->Z policy to ACCEPT.
Masquerade Z to itself.
Set the routeback option on the interface to Z.
Set the ALL INTERFACES column in the nat file to - “Yes”.
In this configuration, all Z->Z traffic will look to - the server as if it came from the firewall rather than from the - original client! I DO NOT RECOMMEND THIS SETUP.
Example 1. Example:
Zone: dmz Interface: eth2 Subnet: 192.168.2.0/24
In /etc/shorewall/interfaces:
#ZONE INTERFACE BROADCAST OPTIONS
-loc eth2 192.168.2.255 routeback |
In /etc/shorewall/policy:
#SOURCE DESTINATION POLICY LIMIT:BURST -dmz dmz ACCEPT |
In /etc/shorewall/masq:
#INTERFACE SUBNET ADDRESS -eth2 192.168.2.0/24 |
In /etc/shorewall/nat, be sure that you - have “Yes” in the ALL INTERFACES column.
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.
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 /etc/shorewall/action.Drop - which in turn invokes the RejectAuth - action (defined in /etc/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.
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.
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.
Here's - a writeup on a nice integration of Shorewall and PortSentry.
Answer: If you want your firewall - to be totally open for “ping”,
Create /etc/shorewall/common if it - doesn't already exist.
Be sure that the first command in the file is “. - /etc/shorewall/common.def”
Add the following to /etc/shorewall/common
run_iptables -A icmpdef -p ICMP --icmp-type echo-request -j ACCEPT |
For a complete description of Shorewall “ping” - management, see this page.
Answer: 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.
See the Shorewall and FTP page.
Answer: Most likely, you need to - set CLAMPMSS=Yes in /etc/shorewall/shorewall.conf.
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 - messaged 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.
Answer: Here are several links - that may be helpful:
http://www.shorewall.net/pub/shorewall/parsefw/
-http://www.fireparse.com
-http://cert.uni-stuttgart.de/projects/fwlogwatch
-http://www.logwatch.org
-http://gege.org/iptables
-http://home.regit.org/ulogd-php.html
I personnaly use Logwatch. It emails me a report each day from - my various systems with each report summarizing the logged activity on - the corresponding system.
Temporarily add the following rule:
DROP net fw udp 10619 |
Jan 8 15:50:48 norcomix kernel: - Shorewall:net2all:DROP:IN=eth0 OUT= - MAC=00:40:c7:2e:09:c0:00:01:64:4a:70:00:08:00 SRC=208.138.130.16 - DST=24.237.22.45 LEN=53 TOS=0x00 PREC=0x00 TTL=251 ID=8288 DF - PROTO=UDP SPT=53 DPT=40275 LEN=33 |
Answer: There are two - possibilities:
They are late-arriving replies to DNS queries.
They are corrupted reply packets.
You can distinguish the difference by setting the logunclean option (/etc/shorewall/interfaces) - on your external interface (eth0 in the above example). If they get - logged twice, they are corrupted. I solve this problem by using an - /etc/shorewall/common file like this:
# -# Include the standard common.def file -# -. /etc/shorewall/common.def -# -# The following rule is non-standard and compensates for tardy -# DNS replies -# -run_iptables -A common -p udp --sport 53 -mstate --state NEW -j DROP |
The above file is also include in all of my sample - configurations available in the Quick Start Guides and in - the common.def file in Shorewall 1.4.0 and later.
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)
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; or
See 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.
Answer: Logging occurs out of a - number of chains (as indicated in the log message) in Shorewall:
The destination address is listed in /etc/shorewall/rfc1918 - with a logdrop target -- see - /etc/shorewall/rfc1918.
The source address is listed in /etc/shorewall/rfc1918 - with a logdrop target -- see - /etc/shorewall/rfc1918.
You 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.
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.
The packet is being logged under the maclist - interface option.
The packet is being logged under the logunclean - interface option.
The packet is being logged under the dropunclean - interface option - as specified in the LOGUNCLEAN - setting in /etc/shorewall/shorewall.conf.
The packet is being logged because the source IP is - blacklisted in the /etc/shorewall/blacklist - file.
The 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.
The 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. Also see - the section called “(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.” for another cause of packets being logged - in the FORWARD chain.
The packet is being logged because it failed the checks - implemented by the tcpflags - interface option.
Example 3. Here is an example:
Jun 27 15:37:56 gateway kernel: - Shorewall:all2all:REJECT:IN=eth2 OUT=eth1 SRC=192.168.2.2 - DST=192.168.1.3 LEN=67 TOS=0x00 PREC=0x00 TTL=63 ID=5805 DF PROTO=UDP - SPT=1803 DPT=53 LEN=47 |
Let's look at the important parts of this message:
This packet was REJECTed out of the all2all - chain -- the packet was rejected under the “all”->“all” - REJECT policy (all2<zone>, <zone>2all or all2all above).
the packet entered the firewall via eth2. If you see - “IN=” with no interface name, the packet originated - on the firewall itself.
if 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.
the packet was sent by 192.168.2.2
the packet is destined for 192.168.1.3
UDP Protocol
The 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 |
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 LAN
Answer: 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.
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.
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 DROP |
If 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 eth2 |
There was an article in SysAdmin covering this topic. - It may be found at http://www.samag.com/documents/s=1824/sam0201h/
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.
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.
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 commands
service ipchains stop -chkconfig --delete ipchains -rmmod ipchains |
Also, be sure to check the errata - for problems concerning the version of iptables (v1.2.3) shipped with - RH7.2.
Answer: This is usually cured - by the sequence of commands shown above in the section called “(FAQ 8) When I try to start Shorewall on RedHat, I get messages - about insmod failing -- what's wrong?”.
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.
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.
Shorewall works with any GNU/Linux distribution that includes the - proper prerequisites.
Answer: See the Shorewall Feature List.
Answer: Yes. Shorewall support is - included in Webmin 1.060 and later versions. See http://www.webmin.com
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 must more commonly used.
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.
At the shell prompt, type:
/sbin/shorewall version |
Answer: Yes.
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.
Answer: Shorewall can be configured to do that using the - blacklisting - facility.
Answer: Yes, if the routefilter interface option - is selected.
Answer: 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.
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 2004 and soon - Shorewall 2.0 will be available. Shorewall 1.2.12 is poorly documented - and is missing many of the features that Shorewall users find essential - today.
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 ACCEPT |
If you are running version 1.3.1 or later, simply add the - following 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 RETURN |
If 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 |
The solution is the same as the section called “(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.” above. - Simply substitute the IP address of your ISPs DHCP server.
Answer: Yes. See Shorewall and Aliased - Interfaces.
You probably haven't set TC_ENABLED=Yes in - /etc/shorewall/shorewall.conf so the contents of the tcrules file are - simply being ignored.
Yes. Consult the QuickStart - guide that you used during your initial setup for information - about how to set up rules for your server.
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>,... |
Edit /etc/shorewall/shorewall.conf and change “NEWNOTSYN=No” - to “NEWNOTSYN=Yes” then restart Shorewall.
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.
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 +x |
Answer: 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.
Basically, you don't. While there are kernel patches that - allow you to route bridge traffic through Netfilter, the environment is - so different from the Layer 3 firewalling environment that very little - of Shorewall works. In fact, so much of Shorewall doesn't work that - my official position is that “Shorewall doesn't work with - Layer 2 Bridging”.
Revision History | ||
---|---|---|
Revision 1.17 | 2004-02-03 | TE |
Added - FAQ 33. | ||
Revision 1.16 | 2004-02-03 | TE |
Updated - for Shorewall 2.0. | ||
Revision 1.15 | 2004-01-25 | TE |
Updated - FAQ 32 to mention masquerading. Remove tables. | ||
Revision 1.14 | 2004-01-24 | TE |
Added - FAQ 27a regarding kernel/iptables incompatibility. | ||
Revision 1.13 | 2004-01-24 | TE |
Add - a note about the detectnets interface - option in FAQ 9. | ||
Revision 1.12 | 2004-01-20 | TE |
Improve - FAQ 16 answer. | ||
Revision 1.11 | 2004-01-14 | TE |
Corrected - broken link | ||
Revision 1.10 | 2004-01-09 | TE |
Added - a couple of more legacy FAQ numbers. | ||
Revision 1.9 | 2004-01-08 | TE |
Corrected - typo in FAQ 26a. Added warning to FAQ 2 regarding source address of - redirected requests. | ||
Revision 1.8 | 2003-12-31 | TE |
Additions - to FAQ 4. | ||
Revision 1.7 | 2003-12-30 | TE |
Remove - dead link from FAQ 1. | ||
Revision 1.6 | 2003.12-18 | TE |
Add - external link reference to FAQ 17. | ||
Revision 1.5 | 2003-12-16 | TE |
Added - a link to a Sys Admin article about multiple internet interfaces. Added - Legal Notice. Moved "abstract" to the body of the document. Moved - Revision History to this Appendix. | ||
Revision 1.4 | 2003-12-13 | TE |
Corrected - formatting problems | ||
Revision 1.3 | 2003-12-10 | TE |
Changed - the title of FAQ 17 | ||
Revision 1.2 | 2003-12-09 | TE |
Added - Copyright and legacy FAQ numbers | ||
Revision 1.1 | 2003-12-04 | MN |
Converted - to Simplified DocBook XML | ||
Revision 1.0 | 2002-08-13 | TE |
Initial - revision |
man iptablesand look at the -I (--insert) command.
Shorewall doesn't work with - Layer 2 Bridging.
shorwall.lrpfile on the image with the file that you downloaded. See the
--oldpackage- option to rpm.
loczone are configured with their default gateway set to - the Shorewall router's RFC1918 address.
Local Processmeans a process running on the Shorewall system itself.
Copyright © 2003-2004 Thomas M. Eastep
Permission 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”.
2004-02-04
Table of Contents
This page covers Shorewall configuration to use with Squid running as a Transparent - Proxy or as a Manual Proxy.
If you are running Shorewall 1.3, please see this documentation.
Please observe the following general requirements:
In all cases, Squid should be configured to run as a transrent - proxy as described at - http://tldp.org/HOWTO/mini/TransparentProxy.html.
The following instructions mention the files - /etc/shorewall/start and /etc/shorewall/init -- if you don't - have those files, siimply create them.
When the Squid server is in the DMZ zone or in the local zone, - that zone must be defined ONLY by its interface -- no - /etc/shorewall/hosts file entries. That is because the packets being - routed to the Squid server still have their original destination IP - addresses.
You must have iptables installed on your Squid server.
If you run a Shorewall version earlier than 1.4.6, you must - have NAT and MANGLE enabled in your /etc/shorewall/conf file
NAT_ENABLED=Yes -MANGLE_ENABLED=Yes |
Three different configurations are covered:
Squid (transparent) Running on the Firewall |
Squid (transparent) Running in the local Network |
Squid (transparent) Running in a DMZ |
You want to redirect all local www connection requests EXCEPT - those to your own http server (206.124.146.177) to a Squid transparent - proxy running on the firewall and listening on port 3128. Squid will of - course require access to remote web servers.
In /etc/shorewall/rules:
#ACTION SOURCE DEST PROTO DEST PORT(S) SOURCE ORIGINAL -# PORT(S) DEST -REDIRECT loc 3228 tcp www - !206.124.146.177 -ACCEPT fw net tcp www |
There may be a requirement to exclude additional destination hosts - or networks from being redirected. For example, you might also want - requests destined for 130.252.100.0/24 to not be routed to Squid.
If you are running Shorewall version 1.4.5 or later, you may just - add the additional hosts/networks to the ORIGINAL DEST column in your - REDIRECT rule.
/etc/shorewall/rules:
#ACTION SOURCE DEST PROTO DEST PORT(S) SOURCE ORIGINAL -# PORT(S) DEST -REDIRECT loc 3228 tcp www - !206.124.146.177,130.252.100.0/24 |
If you are running a Shorewall version earlier than 1.4.5, you - must add a manual rule in /etc/shorewall/start:
run_iptables -t nat -I loc_dnat -p tcp --dport www -d 130.252.100.0/24 -j RETURN |
To exclude additional hosts or networks, just add additional - similar rules.
You want to redirect all local www connection requests to a Squid - transparent proxy running in your local zone at 192.168.1.3 and - listening on port 3128. Your local interface is eth1. There may also be - a web server running on 192.168.1.3. It is assumed that web access is - already enabled from the local zone to the internet..
* On your firewall system, issue the following command
echo 202 www.out >> /etc/iproute2/rt_tables |
In /etc/shorewall/init, put:
if [ -z "`ip rule list | grep www.out`" ] ; then
- ip rule add fwmark 202 table www.out
- ip route add default via 192.168.1.3 dev eth1 table www.out
- ip route flush cache
- echo 0 > /proc/sys/net/ipv4/conf/eth1/send_redirects
-fi |
If you are running Shorewall 1.4.1 or Shorewall 1.4.1a, - please upgrade to Shorewall 1.4.2 or later.
If you are running Shorewall 1.4.2 or later, then in - /etc/shorewall/interfaces:
#ZONE INTERFACE BROADCAST OPTIONS
-loc eth1 detect routeback |
In /etc/shorewall/rules:
#ACTION SOURCE DEST PROTO DEST PORT(S) -ACCEPT loc loc tcp www |
Alternativfely, if you are running Shorewall 1.4.0 you can - have the following policy in place of the above rule.
/etc/shorewall/policy
#SOURCE DESTINATION POLICY -loc loc ACCEPT |
In /etc/shorewall/start add:
iptables -t mangle -A PREROUTING -i eth1 -s ! 192.168.1.3 -p tcp --dport 80 -j MARK --set-mark 202 |
On 192.168.1.3, arrange for the following command to be - executed after networking has come up
iptables -t nat -A PREROUTING -i eth0 -d ! 192.168.1.3 -p tcp --dport 80 -j REDIRECT --to-ports 3128 |
If you are running RedHat on the server, you can simply - execute the following commands after you have typed the iptables - command above:
iptables-save > /etc/sysconfig/iptables
-chkconfig --level 35 iptables on |
You have a single Linux system in your DMZ with IP address - 192.0.2.177. You want to run both a web server and Squid on that system. - Your DMZ interface is eth1 and your local interface is eth2.
On your firewall system, issue the following command
echo 202 www.out >> /etc/iproute2/rt_tables |
In /etc/shorewall/init, put:
if [ -z "`ip rule list | grep www.out`" ] ; then
- ip rule add fwmark 202 table www.out
- ip route add default via 192.0.2.177 dev eth1 table www.out
- ip route flush cache
-fi |
Do one of the following:
In /etc/shorewall/start add
iptables -t mangle -A PREROUTING -i eth2 -p tcp --dport 80 -j MARK --set-mark 202 |
Set MARK_IN_FORWARD_CHAIN=No in /etc/shorewall/shorewall.conf - and add the following entry in /etc/shorewall/tcrules:
#MARK SOURCE DESTINATION PROTOCOL PORT -202 eth2 0.0.0.0 tcp 80 |
Run Shorewall 1.3.14 or later and add the following entry - in /etc/shorewall/tcrules:
#MARK SOURCE DESTINATION PROTOCOL PORT -202:P eth2 0.0.0.0 tcp 80 |
In /etc/shorewall/rules, you will need:
#ACTION SOURCE DEST PROTO DEST PORT(S) -ACCEPT loc dmz tcp 80 -ACCEPT dmz net tcp 80 |
On 192.0.2.177 (your Web/Squid server), arrange for the - following command to be executed after networking has come up
iptables -t nat -A PREROUTING -i eth0 -d ! 192.0.2.177 -p tcp --dport 80 -j REDIRECT --to-ports 3128 |
If you are running RedHat on the server, you can simply - execute the following commands after you have typed the iptables - command above:
iptables-save > /etc/sysconfig/iptables
-chkconfig --level 35 iptables on |
Assume that Squid is running in zone SZ and listening on port SP; - all web sites that are to be accessed through Squid are in the - “net” zone. Then for each zone Z that needs access to the - Squid server.
/etc/shorewall/rules:
#ACTION SOURCE DEST PROTO DEST PORT(S) -ACCEPT Z SZ tcp SP -ACCEPT SZ net tcp 80 |
:) and ACCEPT, DROP or - REJECT. When this is done, the named action will become the -
:) and ACCEPT, DROP + or REJECT. When this is done, the named action will become the +
Foothen copy -
Foothen copy +
:) and a syslog - log level (e.g, REJECT:info or ACCEPT:debugging). This causes the packet - to be logged at the specified level. You may also specify ULOG (must be - in upper case) as a log level.This will log to the ULOG target for - routing to a separate log through use of ulogd (
~and must use -
-as a separator.
:) and a syslog log level (e.g, REJECT:info or + ACCEPT:debugging). This causes the packet to be logged at the + specified level. You may also specify ULOG (must be in upper case) as + a log level.This will log to the ULOG target for routing to a separate + log through use of ulogd (
:) - and an IP/MAC/subnet address as described above (e.g., - eth1:192.168.1.5).
~+ and must use
-as a separator.
:) and an IP/MAC/subnet address as described above + (e.g., eth1:192.168.1.5).
tcp,
udp, -
icmp, a number, or
all.
icmp, this column is - interpreted as the destination icmp-type(s).
tcp,
udp, +
icmp, a number, or
all.
icmp, this column is + interpreted as the destination icmp-type(s).
-.
-.
secor -
min) and <
secor +
min) and <
Dropfor DROP policies and -
Rejectfor REJECT policies.
Dropor -
Reject, simply copy
Dropfor DROP policies and +
Rejectfor REJECT policies.
Drop+ or
Reject, simply copy
.GNU Free Documentation License
~) and consist of 6 hex numbers separated by hyphens. In Shorewall, the MAC address in - the example above would be written
~02-00-08-E3-FA-55. + the example above would be written
Copyright © 2001-2004 Thomas M. Eastep
Permission 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”.
2004-02-13
Table of Contents
I use a combination of One-to-one NAT and Proxy ARP, neither of - which are relevant to a simple configuration with a single public IP - address. If you have just a single public IP address, most of what you - see here won't apply to your setup so beware of copying parts of - this configuration and expecting them to work for you. What you copy may - or may not work in your configuration.
The configuration shown here corresponds to Shorewall version - 2.0.0-Beta1. It may use features not available in earlier Shorewall - releases.
I have DSL service and have 5 static IP addresses - (206.124.146.176-180). My DSL “modem” (Fujitsu Speedport) is - connected to eth0. I have a local network connected to eth2 (subnet - 192.168.1.0/24), a DMZ connected to eth1 (206.124.146.176/32) and a - Wireless network connected to eth3 (192.168.3.0/24). Note that the IP - address of eth1 is a duplicate of one on eth0.
I use:
One-to-one NAT for Ursa (my personal system that dual-boots - Mandrake 9.2 and Windows XP) - Internal address 192.168.1.5 and - external address 206.124.146.178.
One-to-one NAT for EastepLaptop (My work system -- Windows XP - SP2). Internal address 192.168.1.7 and external address - 206.124.146.180.
SNAT through 206.124.146.179 for my SuSE 9.0 Linux - system (Wookie), my Wife's Windows XP system (Tarry), and - our Windows XP laptop (Tipper) which connects through the - Wireless Access Point (wap) via a Wireless Bridge (bridge).
While - the distance between the WAP and where I usually use the laptop - isn't very far (25 feet or so), using a WAC11 (CardBus wireless - card) has proved very unsatisfactory (lots of lost connections). By - replacing the WAC11 with the WET11 wireless bridge, I have virtually - eliminated these problems (Being an old radio tinkerer (K7JPV), I was - also able to eliminate the disconnects by hanging a piece of aluminum - foil on the family room wall. Needless to say, my wife Tarry rejected - that as a permanent solution :-).
The firewall runs on a 256MB PII/233 with Debian Sarge (Testing).
Wookie, Ursa and the Firewall all run Samba and the Firewall acts as - a WINS server.
The wireless network connects to eth3 via a LinkSys WAP11. - In additional to using the rather weak WEP 40-bit encryption (64-bit with - the 24-bit preamble), I use MAC - verification. This is still a weak combination and if I lived near - a wireless “hot spot”, I would probably add IPSEC or - something similar to my WiFi->local connections.
The single system in the DMZ (address 206.124.146.177) runs postfix, - Courier IMAP (imaps and pop3), DNS, a Web server (Apache) and an FTP - server (Pure-ftpd) under RedHat 9.0. The system also runs fetchmail to - fetch our email from our old and current ISPs. That server is managed - through Proxy ARP.
The firewall system itself runs a DHCP server that serves the local - network.
All administration and publishing is done using ssh/scp. I have a - desktop environment installed on the firewall but I am not usually logged - in to it. X applications tunnel through SSH to Ursa. The server also has a - desktop environment installed and that desktop environment is available - via XDMCP from the local zone. For the most part though, X tunneled - through SSH is used for server administration and the server runs at run - level 3 (multi-user console mode on RedHat).
I run an SNMP server on my firewall to serve MRTG running - in the DMZ.
The - ethernet interface in the Server is configured with IP address - 206.124.146.177, netmask 255.255.255.0. The server's default gateway - is 206.124.146.254 (Router at my ISP. This is the same default gateway - used by the firewall itself). On the firewall, an entry in my - /etc/network/interfaces file (see below) adds a host route to - 206.124.146.177 through eth1 when that interface is brought up.
Ursa (192.168.1.5 A.K.A. 206.124.146.178) runs a PPTP server for - Road Warrior access.
LOGFILE=/var/log/messages -LOGRATE= -LOGBURST= -LOGUNCLEAN=$LOG -BLACKLIST_LOGLEVEL= -LOGNEWNOTSYN=$LOG -MACLIST_LOG_LEVEL=$LOG -TCP_FLAGS_LOG_LEVEL=$LOG -RFC1918_LOG_LEVEL=$LOG -SMURF_LOG_LEVEL= -PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin -SHOREWALL_SHELL=/bin/ash -SUBSYSLOCK= #I run Debian which doesn't use service locks -STATEDIR=/var/state/shorewall -MODULESDIR= -FW=fw -IP_FORWARDING=On -ADD_IP_ALIASES=Yes -ADD_SNAT_ALIASES=Yes -TC_ENABLED=Yes -CLEAR_TC=No -MARK_IN_FORWARD_CHAIN=No -CLAMPMSS=Yes -ROUTE_FILTER=No -DETECT_DNAT_IPADDRS=Yes -MUTEX_TIMEOUT=60 -NEWNOTSYN=Yes -BLACKLISTNEWONLY=Yes -BLACKLIST_DISPOSITION=DROP -MACLIST_DISPOSITION=REJECT -TCP_FLAGS_DISPOSITION=DROP -
MIRRORS=<list of shorewall mirror ip addresses> -NTPSERVERS=<list of the NTP servers I sync with> -TEXAS=<ip address of gateway in Dallas> -LOG=info
#ZONE DISPLAY COMMENTS -net Internet Internet -WiFi Wireless Wireless Network on eth3 -dmz DMZ Demilitarized zone -loc Local Local networks -tx Texas Peer Network in Dallas -#LAST LINE -- ADD YOUR ENTRIES ABOVE THIS ONE - DO NOT REMOVE
This is set up so that I can start the firewall before bringing - up my Ethernet interfaces.
#ZONE INERFACE BROADCAST OPTIONS -net eth0 206.124.146.255 dhcp,norfc1918,routefilter,blacklist,tcpflags,nosmurfs -loc eth2 192.168.1.255 dhcp,detectnets -dmz eth1 - -WiFi eth3 192.168.3.255 dhcp,maclist,detectnets -- texas 192.168.9.255 -#LAST LINE -- ADD YOUR ENTRIES ABOVE THIS ONE - DO NOT REMOVE
#ZONE HOST(S) OPTIONS -tx texas:192.168.8.0/22 -#LAST LINE -- ADD YOUR ENTRIES ABOVE THIS ONE - DO NOT REMOVE
#INTERFACE HOST(S) -eth1 206.124.146.177 -eth2 - -eth3 192.168.3.0/24 -#LAST LINE -- ADD YOUR ENTRIES ABOVE THIS ONE - DO NOT REMOVE
I use a stripped-down file which doesn't have to be updated - when the IANA allocates a block of IP addresses.
#SUBNET TARGET -169.254.0.0/16 DROP # DHCP autoconfig -172.16.0.0/12 logdrop # RFC 1918 -192.0.2.0/24 logdrop # Example addresses -192.168.0.0/16 logdrop # RFC 1918 -10.24.60.56 DROP # Some idiot in my broadcast domain - # has a box configured with this - # address. -10.0.0.0/8 logdrop # Reserved (RFC 1918)
#ADDRESS/SUBNET PROTOCOL PORT -0.0.0.0/0 udp 1434 -0.0.0.0/0 tcp 1433 -0.0.0.0/0 tcp 8081 -0.0.0.0/0 tcp 57 -#LAST LINE -- ADD YOUR ENTRIES ABOVE THIS ONE - DO NOT REMOVE
#SOURCE DESTINATION POLICY LOG LEVEL BURST:LIMIT -fw fw ACCEPT # For testing fw->fw rules -loc net ACCEPT # Allow all net traffic from local net -$FW loc ACCEPT # Allow local access from the firewall -$FW tx ACCEPT # Allow firewall access to texas -loc tx ACCEPT # Allow local net access to texas -loc fw REJECT $LOG # Reject loc->fw and log -WiFi net ACCEPT # Allow internet access from wirless -net all DROP $LOG 10/sec:40 # Rate limit and - # DROP net->all -all all REJECT $LOG # Reject and log the rest -#LAST LINE -- ADD YOUR ENTRIES ABOVE THIS ONE - DO NOT REMOVE
Although most of our internal systems use one-to-one NAT, my - wife's system (192.168.1.4) uses IP Masquerading (actually SNAT) - as does my SuSE system (192.168.1.3), our laptop (192.168.3.8) and - visitors with laptops.
#INTERFACE SUBNET ADDRESS -eth0:2 eth2 206.124.146.179 -eth0 eth3 206.124.146.179 -#LAST LINE -- ADD YOUR ENTRIES ABOVE THIS LINE -- DO NOT REMOVE -
#EXTERNAL INTERFACE INTERNAL ALL INTERFACES LOCAL -206.124.146.178 eth0:0 192.168.1.5 No No -206.124.146.180 eth0:1 192.168.1.7 No No -# -# The following entry allows the server to be accessed through an address in -# the local network. This is convenient when I'm on the road and connected -# to the PPTP server. By doing this, I don't need to set my client's default -# gateway to route through the tunnel. -# -192.168.1.193 eth2:0 206.124.146.177 No No -#LAST LINE -- ADD YOUR ENTRIES ABOVE THIS LINE -- DO NOT REMOVE
#ADDRESS INTERFACE EXTERNAL HAVEROUTE PERSISTENT -206.124.146.177 eth1 eth0 Yes -#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE
#TYPE ZONE GATEWAY GATEWAY ZONE PORT -gre net $TEXAS -#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE
#ACTION -DropSMB #Silently Drops Microsoft SMB Traffic -RejectSMB #Silently Reject Microsoft SMB Traffic -DropUPnP #Silently Drop UPnP Probes -RejectAuth #Silently Reject Auth -DropPing #Silently Drop Ping -DropDNSrep #Silently Drop DNS Replies -AllowPing #Accept Ping - -Mirrors #Accept traffic from the Shorewall Mirror sites - -MyDrop:DROP #My DROP common action -MyReject:REJECT #My REJECT common action -#LAST LINE - ADD YOUR ENTRIES ABOVE THIS ONE - DO NOT REMOVE
The $MIRRORS variable expands to a list of approximately 10 IP - addresses. So moving these checks into a separate chain reduces the - number of rules that most net->dmz traffic needs to traverse.
#TARGET SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE -# PORT PORT(S) DEST LIMIT -ACCEPT $MIRRORS -#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE
This is my common action for the DROP policy. It is like the - standard Reject action except that it - allows “Ping”.
#TARGET SOURCE DEST PROTO DEST SOURCE RATE USER/ -# PORT(S) PORT(S) LIMIT GROUP -RejectAuth -AllowPing -dropBcast -DropSMB -DropUPnP -dropNonSyn -DropDNSrep
This is my common action for the REJECT policy. It is like the - standard Drop action except that it - allows “Ping”.
#TARGET SOURCE DEST PROTO DEST SOURCE RATE USER/ -# PORT(S) PORT(S) LIMIT GROUP -RejectAuth -AllowPing -dropBcast -RejectSMB -DropUPnP -dropNonSyn -DropDNSrep -DROP loc:eth2:!192.168.1.0/24 #So that my braindead Windows[tm] XP system doesn't flood my log - #with NTP requests with a source address in 16.0.0.0/8 (address of - #its PPTP tunnel to HP).
############################################################################################################################################################################### -#RESULT CLIENT(S) SERVER(S) PROTO PORT(S) CLIENT ORIGINAL RATE USER -# PORT(S) DEST:SNAT SET -############################################################################################################################################################################### -# Local Network to Internet - Reject attempts by Trojans to call home -# -REJECT:$LOG loc net tcp 6667 -# -# Stop NETBIOS crap since our policy is ACCEPT -# -REJECT loc net tcp 137,445 -REJECT loc net udp 137:139 -# -DROP loc:!192.168.1.0/24 net - -QUEUE loc net udp -QUEUE loc fw udp -QUEUE loc net tcp -############################################################################################################################################################################### -# Local Network to Firewall -# -DROP loc:!192.168.1.0/24 fw -ACCEPT loc fw tcp ssh,time,10000,swat,137,139,445 -ACCEPT loc fw udp snmp,ntp,445 -ACCEPT loc fw udp 137:139 -ACCEPT loc fw udp 1024: 137 -############################################################################################################################################################################### -# Local Network to DMZ -# -DROP loc:!192.168.1.0/24 dmz -REJECT loc dmz tcp 465 -ACCEPT loc dmz udp domain,xdmcp -ACCEPT loc dmz tcp www,smtp,domain,ssh,imap,https,imaps,cvspserver,ftp,10000,8080,10027,pop3 - -############################################################################################################################################################################### -# Internet to DMZ -# -DNAT- net dmz:206.124.146.177 tcp smtp - 206.124.146.179,206.124.146.178 -ACCEPT net dmz tcp smtp,www,ftp,imaps,domain,cvspserver,https - -ACCEPT net dmz udp domain -ACCEPT net dmz udp 33434:33436 -Mirrors net dmz tcp rsync -#ACCEPT:$LOG net dmz tcp 32768:61000 20 -############################################################################################################################################################################### -# -# Net to Local -# -# When I'm "on the road", the following two rules allow me VPN access back home. -# -ACCEPT net loc:192.168.1.5 tcp 1723 -ACCEPT net loc:192.168.1.5 gre -# -# ICQ -# -ACCEPT net loc:192.168.1.5 tcp 4000:4100 -# -# Real Audio -# -ACCEPT net loc:192.168.1.5 udp 6970:7170 -# -# Overnet -# -#ACCEPT net loc:192.168.1.5 tcp 4662 -#ACCEPT net loc:192.168.1.5 udp 12112 -############################################################################################################################################################################### -# DMZ to Internet -# -ACCEPT dmz net tcp smtp,domain,www,https,whois,echo,2702,21,2703,ssh,8080 -ACCEPT dmz net udp domain -ACCEPT dmz net:$POPSERVERS tcp pop3 -#ACCEPT dmz net:206.191.151.2 tcp pop3 -#ACCEPT dmz net:66.216.26.115 tcp pop3 -# -# Something is wrong with the FTP connection tracking code or there is some client out there -# that is sending a PORT command which that code doesn't understand. Either way, -# the following works around the problem. -# -ACCEPT:$LOG dmz net tcp 1024: 20 -############################################################################################################################################################################### -# DMZ to Firewall -- ntp & snmp, Silently reject Auth -# -ACCEPT dmz fw udp ntp ntp -ACCEPT dmz fw tcp snmp,ssh -ACCEPT dmz fw udp snmp -REJECT dmz fw tcp auth -############################################################################################################################################################################### -# DMZ to Internet -# -ACCEPT dmz net tcp smtp,domain,www,https,whois,echo,2702,21,2703,ssh,8080 -ACCEPT dmz net udp domain -ACCEPT dmz net:$POPSERVERS tcp pop3 -#ACCEPT dmz net:206.191.151.2 tcp pop3 -#ACCEPT dmz net:66.216.26.115 tcp pop3 -# -# Something is wrong with the FTP connection tracking code or there is some client out there -# that is sending a PORT command which that code doesn't understand. Either way, -# the following works around the problem. -# -ACCEPT:$LOG dmz net tcp 1024: 20 -############################################################################################################################################################################### -# DMZ to Firewall -- ntp & snmp, Silently reject Auth -# -ACCEPT dmz fw udp ntp ntp -ACCEPT dmz fw tcp snmp,ssh -ACCEPT dmz fw udp snmp -REJECT dmz fw tcp auth -############################################################################################################################################################################### -# -# DMZ to Local Network -# -ACCEPT dmz loc tcp smtp,6001:6010 -ACCEPT dmz loc tcp 111 -ACCEPT dmz loc udp -############################################################################################################################################################################### -# Internet to Firewall -# -REJECT net fw tcp www -ACCEPT net dmz udp 33434:33435 -############################################################################################################################################################################### -# WIFI to Firewall -# -ACCEPT WiFi fw tcp ssh,137,139,445 -ACCEPT WiFi fw udp 137:139,445 -ACCEPT WiFi fw udp 1024: 137 -ACCEPT WiFi fw udp ntp ntp -############################################################################################################################################################################### -# Firewall to WIFI -# -ACCEPT fw WiFi tcp 137,139,445 -ACCEPT fw WiFi udp 137:139,445 -ACCEPT fw WiFi udp 1024: 137 -ACCEPT fw WiFi udp ntp ntp -############################################################################################################################################################################## -# WIFI to DMZ -# -DNAT- WiFi dmz:206.124.146.177 all - - 192.168.1.193 -ACCEPT WiFi dmz tcp smtp,www,ftp,imaps,domain,https,ssh,8080 - -ACCEPT WiFi dmz udp domain -############################################################################################################################################################################## -# WIFI to loc -# -ACCEPT WiFi loc udp 137:139 -ACCEPT WiFi loc tcp 22,80,137,139,445,901,3389 -ACCEPT WiFi loc udp 1024: 137 -ACCEPT WiFi loc udp 177 -############################################################################################################################################################################## -# loc to WiFi -# -ACCEPT loc WiFi udp 137:139 -ACCEPT loc WiFi tcp 137,139,445 -ACCEPT loc WiFi udp 1024: 137 -ACCEPT loc WiFi tcp 6000:6010 -############################################################################################################################################################################### -# Firewall to Internet -# -ACCEPT fw net:$NTPSERVERS udp ntp ntp -#ACCEPT fw net:$POPSERVERS tcp pop3 -ACCEPT fw net udp domain -ACCEPT fw net tcp domain,www,https,ssh,1723,whois,1863,ftp,2702,2703,7 -ACCEPT fw net udp 33435:33535 -ACCEPT fw net icmp -############################################################################################################################################################################### -# Firewall to DMZ -# -ACCEPT fw dmz tcp www,ftp,ssh,smtp -ACCEPT fw dmz udp domain -REJECT fw dmz udp 137:139 -############################################################################################################################################################################### -# Ping -# -ACCEPT all all icmp 8 -#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE
This file is Debian specific. My additional entry (which is - displayed in bold type) adds a route - to my DMZ server when eth1 is brought up. It allows me to enter - “Yes” in the HAVEROUTE column of my - Proxy ARP file.
... -auto eth1 -iface eth1 inet static - address 206.124.146.176 - netmask 255.255.255.255 - broadcast 0.0.0.0 - up ip route add 206.124.146.177 dev eth1 -...
While this is a little off-topic, I've included it to show - how to set up DHCP on two interfaces.
default-lease-time 67200; max-lease-time 67200; -get-lease-hostnames on; - -group { - option subnet-mask 255.255.255.0; - option broadcast-address 192.168.1.255; - option routers 192.168.1.254; - option ntp-servers 192.168.1.254; - option domain-name-servers 192.168.1.193; - option netbios-name-servers 192.168.1.254; - option domain-name "shorewall.net"; - option netbios-dd-server 192.168.1.254; - option netbios-node-type 8; - option netbios-scope ""; - - subnet 192.168.1.0 netmask 255.255.255.0 { - range 192.168.1.11 192.168.1.20; - } - - host ursa.shorewall.net { - hardware ethernet …; - fixed-address 192.168.1.5; - } - - host eastept1 { - hardware ethernet …; - fixed-address 192.168.1.7; - } - - host tarry { - hardware ethernet …; - fixed-address 192.168.1.4; - } - - host wookie.shorewall.net { - hardware ethernet …; - fixed-address 192.168.1.3; - } - - host testws.shorewall.net { - hardware ethernet …; - fixed-address 192.168.1.6; - } - - host printer.shorewall.net { - hardware ethernet …; - fixed-address 192.168.1.10; - } - -} - -group { - option subnet-mask 255.255.255.0; - option broadcast-address 192.168.3.255; - option routers 192.168.3.254; - option ntp-servers 192.168.3.254; - option domain-name-servers 206.124.146.177; - option netbios-name-servers 192.168.3.254; - option domain-name "shorewall.net"; - option netbios-dd-server 192.168.3.254; - option netbios-node-type 8; - option netbios-scope ""; - - subnet 192.168.3.0 netmask 255.255.255.0 { - range 192.168.3.11 192.168.3.20; - } - - host easteplaptop { - hardware ethernet …; - fixed-address 192.168.3.7; - } - - host tipper.shorewall.net { - hardware ethernet …; - fixed-address 192.168.3.8; - }
modem(Fujitsu Speedport) is connected to eth0. I have a local network connected to eth2 (subnet - 192.168.1.0/24), a DMZ connected to eth1 (206.124.146.176/32) and a - Wireless network connected to eth3 (192.168.3.0/24). Note that the IP - address of eth1 is a duplicate of one on eth0.
hot spot, I would probably add IPSEC or - something similar to my WiFi->local connections.
hot spot, I + would probably add IPSEC or something similar to my WiFi->local + connections.
@@ -229,7 +238,6 @@ tx#ZONE DISPLAY COMMENTS net Internet Internet -WiFi Wireless Wireless Network on eth3 dmz DMZ Demilitarized zone loc Local Local networks tx Texas Peer Network in Dallas @@ -206,7 +216,6 @@ tx Texas Peer Network in Dallas net eth0 206.124.146.255 dhcp,norfc1918,routefilter,blacklist,tcpflags,nosmurfs loc eth2 192.168.1.255 dhcp,detectnets dmz eth1 - -WiFi eth3 192.168.3.255 dhcp,maclist,detectnets - texas 192.168.9.255 #LAST LINE -- ADD YOUR ENTRIES ABOVE THIS ONE - DO NOT REMOVE
@@ -428,23 +435,17 @@ REJECT:$LOG loc net tcp REJECT loc net tcp 137,445 REJECT loc net udp 137:139 # -DROP loc:!192.168.1.0/24 net - QUEUE loc net udp QUEUE loc fw udp QUEUE loc net tcp ############################################################################################################################################################################### # Local Network to Firewall # -DROP loc:!192.168.1.0/24 fw -ACCEPT loc fw tcp ssh,time,10000,swat,137,139,445 -ACCEPT loc fw udp snmp,ntp,445 -ACCEPT loc fw udp 137:139 -ACCEPT loc fw udp 1024: 137 +ACCEPT loc fw tcp ssh,time +ACCEPT loc fw udp snmp,ntp ############################################################################################################################################################################### # Local Network to DMZ # -DROP loc:!192.168.1.0/24 dmz REJECT loc dmz tcp 465 ACCEPT loc dmz udp domain,xdmcp ACCEPT loc dmz tcp www,smtp,domain,ssh,imap,https,imaps,cvspserver,ftp,10000,8080,10027,pop3 - @@ -500,72 +501,17 @@ ACCEPT dmz fw tcp ACCEPT dmz fw udp snmp REJECT dmz fw tcp auth ############################################################################################################################################################################### -# DMZ to Internet -# -ACCEPT dmz net tcp smtp,domain,www,https,whois,echo,2702,21,2703,ssh,8080 -ACCEPT dmz net udp domain -ACCEPT dmz net:$POPSERVERS tcp pop3 -#ACCEPT dmz net:206.191.151.2 tcp pop3 -#ACCEPT dmz net:66.216.26.115 tcp pop3 -# -# Something is wrong with the FTP connection tracking code or there is some client out there -# that is sending a PORT command which that code doesn't understand. Either way, -# the following works around the problem. -# -ACCEPT:$LOG dmz net tcp 1024: 20 -############################################################################################################################################################################### -# DMZ to Firewall -- ntp & snmp, Silently reject Auth -# -ACCEPT dmz fw udp ntp ntp -ACCEPT dmz fw tcp snmp,ssh -ACCEPT dmz fw udp snmp -REJECT dmz fw tcp auth -############################################################################################################################################################################### -# # DMZ to Local Network # ACCEPT dmz loc tcp smtp,6001:6010 -ACCEPT dmz loc tcp 111 -ACCEPT dmz loc udp +ACCEPT dmz:206.124.146.177 loc:192.168.1.3 tcp 111 +ACCEPT dmz:206.124.146.177 loc:192.168.1.3 udp ############################################################################################################################################################################### # Internet to Firewall # REJECT net fw tcp www ACCEPT net dmz udp 33434:33435 -############################################################################################################################################################################### -# WIFI to Firewall -# -ACCEPT WiFi fw tcp ssh,137,139,445 -ACCEPT WiFi fw udp 137:139,445 -ACCEPT WiFi fw udp 1024: 137 -ACCEPT WiFi fw udp ntp ntp -############################################################################################################################################################################### -# Firewall to WIFI -# -ACCEPT fw WiFi tcp 137,139,445 -ACCEPT fw WiFi udp 137:139,445 -ACCEPT fw WiFi udp 1024: 137 -ACCEPT fw WiFi udp ntp ntp -############################################################################################################################################################################## -# WIFI to DMZ -# -DNAT- WiFi dmz:206.124.146.177 all - - 192.168.1.193 -ACCEPT WiFi dmz tcp smtp,www,ftp,imaps,domain,https,ssh,8080 - -ACCEPT WiFi dmz udp domain -############################################################################################################################################################################## -# WIFI to loc -# -ACCEPT WiFi loc udp 137:139 -ACCEPT WiFi loc tcp 22,80,137,139,445,901,3389 -ACCEPT WiFi loc udp 1024: 137 -ACCEPT WiFi loc udp 177 -############################################################################################################################################################################## -# loc to WiFi -# -ACCEPT loc WiFi udp 137:139 -ACCEPT loc WiFi tcp 137,139,445 -ACCEPT loc WiFi udp 1024: 137 -ACCEPT loc WiFi tcp 6000:6010 + ############################################################################################################################################################################### # Firewall to Internet # @@ -694,4 +640,241 @@ group { + +Although most of our internal systems use one-to-one NAT, my wife's system (192.168.1.4) uses IP Masquerading (actually SNAT) - as does my SuSE system (192.168.1.3), our laptop (192.168.3.8) and + as do my SuSE system (192.168.1.3), our laptop (192.168.3.8) and visitors with laptops. #INTERFACE SUBNET ADDRESS eth0:2 eth2 206.124.146.179 -eth0 eth3 206.124.146.179 #LAST LINE -- ADD YOUR ENTRIES ABOVE THIS LINE -- DO NOT REMOVE
++Only the changes from the defaults are shown. + +BRIDGING=Yes +
++#ZONE DISPLAY COMMENTS +net Net Internet +loc Local Local networks +WiFi WireLess Wireless Network +#LAST LINE - ADD YOUR ENTRIES ABOVE THIS ONE - DO NOT REMOVE + +
++#SOURCE DEST POLICY LOG LIMIT:BURST +fw fw ACCEPT +loc net ACCEPT +net loc ACCEPT +net fw ACCEPT +loc fw ACCEPT +loc WiFi ACCEPT +fw WiFi ACCEPT +fw net ACCEPT +fw loc ACCEPT +# +# THE FOLLOWING POLICY MUST BE LAST +# +all all REJECT info +#LAST LINE -- DO NOT REMOVE +
++#ZONE INTERFACE BROADCAST OPTIONS +- br0 192.168.1.255 +#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE +
++#ZONE HOST(S) OPTIONS +net br0:eth1 +loc br0:eth0 +WiFi br0:eth2 maclist +#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS LINE -- DO NOT REMOVE +
++The first rule allows a transparent WWW proxy (Squid) to run on + my bridge/firewall. Squid listens on port 3128. + +The remaining rules protect the local systems and bridge from + the WiFi network. Note that we don't restrict WiFi→net traffic + since the only directly-accessible system in the net zone is the + firewall (Wookie and the Firewall are connected by a cross-over + cable). + +#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL +# PORT PORT(S) DEST +REDIRECT loc 3128 tcp www - !192.168.1.0/24 + +ACCEPT WiFi loc udp 137:139 +ACCEPT WiFi loc tcp 22,80,137,139,445,901,3389 +ACCEPT WiFi loc udp 1024: 137 +ACCEPT WiFi loc udp 177 + +ACCEPT loc WiFi udp 137:139 +ACCEPT loc WiFi tcp 137,139,445 +ACCEPT loc WiFi udp 1024: 137 +ACCEPT loc WiFi tcp 6000:6010 + +ACCEPT WiFi fw tcp ssh,137,139,445 +ACCEPT WiFi fw udp 137:139,445 +ACCEPT WiFi fw udp 1024: 137 +ACCEPT WiFi fw udp ntp + +#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE +
++#INTERFACE HOST(S) OPTIONS +br0 0.0.0.0/0 routeback +#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE +
++#INTERFACE MAC IP ADDRESSES (Optional) +br0:eth2 00:A0:1C:DB:0C:A0 192.168.1.7 #Work Laptop +br0:eth2 00:04:59:0e:85:b9 #WAP11 +br0:eth2 00:06:D5:45:33:3c #WET11 +br0:eth2 00:0b:c1:53:cc:97 192.168.1.8 #TIPPER +#LAST LINE -- ADD YOUR ENTRIES ABOVE THIS LINE -- DO NOT REMOVE +
++This file is SuSE-specific and creates the bridge device + + +br0 . A script for other + disbributions would be similar.#!/bin/sh +################################################################################ +# Script to create a bridge between eth0, eth1 and eth2 +# +# This program is under GPL [http://www.gnu.org/copyleft/gpl.htm] +# +# (c) 2004 - Tom Eastep (teastep@shorewall.net) +# +# Modify the following variables to match your configuration +# +# chkconfig: 2345 05 89 +# description: Layer 2 Bridge +# +################################################################################ + +PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin + +do_stop() { + echo "Stopping Bridge" + brctl delbr br0 + ip link set eth0 down + ip link set eth1 down + ip link set eth2 down +} + +do_start() { + + echo "Starting Bridge" + ip link set eth0 up + ip link set eth1 up + ip link set eth2 up + brctl addbr br0 + brctl addif br0 eth0 + brctl addif br0 eth1 + brctl addif br0 eth2 +} + +case "$1" in + start) + do_start + ;; + stop) + do_stop + ;; + restart) + do_stop + sleep 1 + do_start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac +exit 0 +
++This file is SuSE-specific + +BOOTPROTO='static' +BROADCAST='192.168.1.255' +IPADDR='192.168.1.3' +NETWORK='192.168.1.0' +NETMASK='255.255.255.0' +REMOTE_IPADDR='' +STARTMODE='onboot' +UNIQUE='3hqH.MjuOqWfSZ+C' +WIRELESS='no' +MTU='' +
++This file is SuSE-specific + +192.168.1.0 - 255.255.255.0 br0 +default 192.168.1.254 - - +
Copyright © 2001-2002, 2004 Thomas M. Eastep
Permission 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”.
2004-02-12
Abstract
In addition to those applications described in the - /etc/shorewall/rules documentation, here are some other - services/applications that you may need to configure your firewall to - accommodate.
Table of Contents
Beginning with Shorewall 2.0.0, the Shorewall distribution contains - a library of user-defined actions that allow for easily allowing or - blocking a particular application. Check your /etc/shorewall/actions.std - file for a list of the actions in your distribution. If you find what you - need, you simply use the action in a rule. For example, to allow DNS - queries from the dmz zone to the - net zone:
#ACTION SOURCE DESTINATION -AllowPing dmz net |
In the rules that are shown in this document, the ACTION is shown as - ACCEPT. You may need to use DNAT (see FAQ 30) - or you may want DROP or REJECT if you are trying to block the application.
Example: You want to port forward FTP from the net to your server at - 192.168.1.4 in your DMZ. The FTP section below gives you:
#ACTION SOURCE DESTINATION PROTO DEST PORT(S) -ACCEPT <source> <destination> tcp 21 |
You would code your rule as follows:
#ACTION SOURCE DESTINATION PROTO DEST PORT(S) -DNAT net dmz:192.168.1.4 tcp 21 |
#ACTION SOURCE DESTINATION PROTO DEST PORT(S) -ACCEPT <source> <destination> udp 53 -ACCEPT <source> <destination> tcp 53 |
#ACTION SOURCE DESTINATION PROTO DEST PORT(S) -ACCEPT <source> <destination> tcp 21 |
Look here for much more information.
#ACTION SOURCE DESTINATION PROTO DEST PORT(S) -ACCEPT <source> <destination> udp 4000 -ACCEPT <source> <destination> tcp 4000:4100 |
UDP Port 4000. You will also need to open a range of TCP ports which - you can specify to your ICQ client. By default, clients use 4000-4100.
#ACTION SOURCE DESTINATION PROTO DEST PORT(S) -ACCEPT <source> <destination> tcp 143 #Unsecure IMAP -ACCEPT <source> <destination> tcp 993 #Secure IMAP |
#ACTION SOURCE DESTINATION PROTO DEST PORT(S) -ACCEPT <source> <destination> 50 -ACCEPT <source> <destination> 51 -ACCEPT <source> <destination> udp 500 -ACCEPT <destination> <source> 50 -ACCEPT <destination> <source> 51 -ACCEPT <destination> <source> udp 500 |
I personally use the following rules for opening access from zone z1 - to a server with IP address a.b.c.d in zone z2. I have found though that - different distributions behave differently so your milage may vary.
#ACTION SOURCE DESTINATION PROTO DEST PORT(S) -ACCEPT <z1> <z2>:a.b.c.d tcp 111 -ACCEPT <z1> <z2>:a.b.c.d udp 111 -ACCEPT <z1> <z2>:a.b.c.d udp 2049 -ACCEPT <z1> <z2>:a.b.c.d udp 32700: |
#ACTION SOURCE DESTINATION PROTO DEST PORT(S) -ACCEPT <source> <destination> udp 123 |
#ACTION SOURCE DESTINATION PROTO DEST PORT(S) -ACCEPT <source> <destination> udp 5632 -ACCEPT <source> <destination> tcp 5631 |
TCP Port 110 (Secure Pop3 is TCP Port 995)
#ACTION SOURCE DESTINATION PROTO DEST PORT(S) -ACCEPT <source> <destination> tcp 110 #Unsecure Pop3 -ACCEPT <source> <destination> tcp 995 #Secure Pop3 |
#ACTION SOURCE DESTINATION PROTO DEST PORT(S) -ACCEPT <source> <destination> 47 -ACCEPT <source> <destination> tcp 1723 |
#ACTION SOURCE DESTINATION PROTO DEST PORT(S) -ACCEPT <source> <destination> tcp 137,139,445 -ACCEPT <source> <destination> udp 137:139 -ACCEPT <destination> <source> tcp 137,139,445 -ACCEPT <destination> <source> udp 137:139 |
Also, see this page.
#ACTION SOURCE DESTINATION PROTO DEST PORT(S) -ACCEPT <source> <destination> udp 33434:33443 #Good for 10 hops -ACCEPT <source> <destination> icmp 8 |
UDP traceroute uses ports 33434 through 33434+<max number of - hops>-1
#ACTION SOURCE DESTINATION PROTO DEST PORT(S) -ACCEPT <source> <destination> tcp 119 |
TCP Port 119
Vncviewer to Vncserver -- TCP port 5900 + <display number>.
#ACTION SOURCE DESTINATION PROTO DEST PORT(S) -ACCEPT <source> <destination> tcp 5901 #Display Number 1 -ACCEPT <source> <destination> tcp 5902 #Display Number 2 -... |
Vncserver to Vncviewer in listen mode -- TCP port 5500.
#ACTION SOURCE DESTINATION PROTO DEST PORT(S) -ACCEPT <source> <destination> tcp 5500 |
#ACTION SOURCE DESTINATION PROTO DEST PORT(S) -ACCEPT <source> <destination> tcp 80 #Insecure HTTP -ACCEPT <source> <destination> tcp 443 #Secure HTTP |
Didn't find what you are looking for -- have you looked in your - own /etc/services file?
Still looking? Try http://www.networkice.com/advice/Exploits/Ports
Revision History | ||
---|---|---|
Revision 1.6 | 2004-01-26 | TE |
Add - PCAnywhere. | ||
Revision 1.5 | 2004-02-05 | TE |
Added - information about VNC viewers in listen mode. | ||
Revision 1.4 | 2004-01-26 | TE |
Correct - ICQ. | ||
Revision 1.3 | 2004-01-04 | TE |
Alphabetize | ||
Revision 1.2 | 2004-01-03 | TE |
Add - rules file entries. | ||
Revision 1.1 | 2002-07-30 | TE |
Initial - version converted to Docbook XML |
Allow. -
Allow.
Allowaction in @@ -406,7 +407,8 @@ AllowSSH net fw
Copyright © 2002-2004 Thomas M. Eastep
Permission 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”.
2004-02-12
Table of Contents
Setting up a Linux system as a firewall for a small network with DMZ - is a fairly straight-forward task if you understand the basics and follow - the documentation.
This guide doesn't attempt to acquaint you with all of the - features of Shorewall. It rather focuses on what is required to configure - Shorewall in one of its more popular configurations:
Linux system used as a firewall/router for a small local - network.
Single public IP address.
If you have more than one public IP address, this is not the - guide you want -- see the Shorewall - Setup Guide instead.
DMZ connected to a separate ethernet interface.
Connection through DSL, Cable Modem, ISDN, Frame Relay, dial-up, - ...
Here is a schematic of a typical installation.
Shorewall requires that you have the iproute/iproute2 - package installed (on RedHat™, the package is - called iproute). You can tell if this package is - installed by the presence of an ip program on your - firewall system. As root, you - can use the which command to check for this program:
[root@gateway root]# which ip
-/sbin/ip
-[root@gateway root]# |
I recommend that you first read through the guide to familiarize - yourself with what's involved then go back through it again making - your configuration changes.
If you edit your configuration files on a - Windows™ system, you must save them as - Unix™ files if your editor supports that option - or you must run them through dos2unix before trying - to use them. Similarly, if you copy a configuration file from your - Windows™ hard drive to a floppy disk, you must - run dos2unix against the copy before using it with - Shorewall.
If you have an ADSL Modem and you use PPTP to communicate with a - server in that modem, you must make the changes - recommended here in addition to those detailed below. ADSL with - PPTP is most commonly found in Europe, notably in Austria.
The configuration files for Shorewall are contained in the directory - /etc/shorewall -- for simple setups, you will only - need to deal with a few of these as described in this guide. After you - have installed Shorewall, download the three-interface sample, un-tar it (tar - -zxvf three-interfaces.tgz) - and and copy the files to /etc/shorewall (the files - will replace files with the same names that were placed in - /etc/shorewall when Shorewall was installed).
As each file is introduced, I suggest that you look through the - actual file on your system -- each file contains detailed configuration - instructions and default entries.
Shorewall views the network where it is running as being composed of - a set of zones. In the three-interface sample configuration, the following - zone names are used:
Name | Description |
---|---|
net | The Internet |
loc | Your Local Network |
dmz | Demilitarized Zone |
Zone names are defined in /etc/shorewall/zones.
Shorewall also recognizes the firewall system as its own zone - by - default, the firewall itself is known as fw.
Rules about what traffic to allow and what traffic to deny are - expressed in terms of zones.
You express your default policy for connections from one zone to - another zone in the /etc/shorewall/policy file.
You define exceptions to those default policies in the - /etc/shorewall/rules file.
For each connection request entering the firewall, the request is - first checked against the /etc/shorewall/rules file. - If no rule in that file matches the connection request then the first - policy in /etc/shorewall/policy that matches the - request is applied. If that policy is REJECT or DROP the request is first - checked against the rules in /etc/shorewall/common if - that file exists; otherwise the file /etc/shorewall/common.def - is checked
The /etc/shorewall/policy file included with - the three-interface sample has the following policies:
#SOURCE DEST POLICY LOG LEVEL LIMIT:BURST -loc net ACCEPT -net all DROP info -all all REJECT info |
In the three-interface sample, the line below is included but - commented out. If you want your firewall system to have full access to - servers on the internet, uncomment that line.
#SOURCE DEST POLICY LOG LEVEL LIMIT:BURST -fw net ACCEPT |
The above policy will:
allow all connection requests from your local network to the - internet
drop (ignore) all connection requests from the internet to your - firewall or local network
optionally accept all connection requests from the firewall to - the internet (if you uncomment the additional policy)
reject all other connection requests.
At this point, edit your /etc/shorewall/policy - file and make any changes that you wish.
The firewall has three network interfaces. Where Internet - connectivity is through a cable or DSL “Modem”, the External - Interface will be the ethernet adapter that is connected to that - “Modem” (e.g., eth0) - unless you connect via Point-to-Point Protocol over - Ethernet (PPPoE) or Point-to-Point Tunneling Protocol - (PPTP) in which case the External Interface will be a ppp - interface (e.g., ppp0). If you - connect via a regular modem, your External Interface will also be - ppp0. If you connect using ISDN, - you external interface will be ippp0.
If your external interface is ppp0 - or ippp0 then you will want to set - CLAMPMSS=yes in /etc/shorewall/shorewall.conf.
Your Local Interface will be an ethernet adapter (eth0, eth1 - or eth2) and will be connected to - a hub or switch. Your local computers will be connected to the same switch - (note: If you have only a single local system, you can connect the - firewall directly to the computer using a cross-over cable).
Your DMZ Interface will also be an ethernet adapter (eth0, eth1 - or eth2) and will be connected to - a hub or switch. Your DMZ computers will be connected to the same switch - (note: If you have only a single DMZ system, you can connect the firewall - directly to the computer using a cross-over cable).
Do not connect the internal and external interface to the same hub - or switch except for testing AND you are running Shorewall version 1.4.7 - or later. When using these recent versions, you can test using this kind - of configuration if you specify the arp_filter option in - /etc/shorewall/interfaces for all interfaces - connected to the common hub/switch. Using such a setup with a production - firewall is strongly recommended against.
The Shorewall three-interface sample configuration assumes that the - external interface is eth0, the - local interface is eth1 and the - DMZ interface is eth2. If your - configuration is different, you will have to modify the sample - /etc/shorewall/interfaces file accordingly. While you - are there, you may wish to review the list of options that are specified - for the interfaces. Some hints:
If your external interface is ppp0 - or ippp0, you can replace the - “detect” in the second column with “-” - (without the quotes).
If your external interface is ppp0 - or ippp0 or if you have a static - IP address, you can remove “dhcp” from the option list.
Before going further, we should say a few words about Internet - Protocol (IP) addresses. Normally, your ISP will assign you a single - Public IP address. This address may be assigned via the Dynamic Host - Configuration Protocol (DHCP) or as part of establishing your connection - when you dial in (standard modem) or establish your PPP connection. In - rare cases, your ISP may assign you a static IP address; that means that - you configure your firewall's external interface to use that address - permanently. Regardless of how the address is assigned, it will be shared - by all of your systems when you access the Internet. You will have to - assign your own addresses for your internal network (the local and DMZ - Interfaces on your firewall plus your other computers). RFC 1918 reserves - several Private IP address ranges for this purpose:
10.0.0.0 - 10.255.255.255 -172.16.0.0 - 172.31.255.255 -192.168.0.0 - 192.168.255.255 |
Before starting Shorewall, you should look at the IP address of your - external interface and if it is one of the above ranges, you should remove - the norfc1918 option from the external interface's - entry in /etc/shorewall/interfaces.
You will want to assign your local addresses from one sub-network or - subnet and your DMZ addresses from another subnet. For our purposes, we - can consider a subnet to consists of a range of addresses x.y.z.0 - x.y.z.255. - Such a subnet will have a Subnet Mask of 255.255.255.0. - The address x.y.z.0 is reserved - as the Subnet Address and x.y.z.255 - is reserved as the Subnet Broadcast Address. In Shorewall, a subnet is - described using Classless InterDomain Routing (CIDR) notation with - consists of the subnet address followed by /24. The - 24 refers to the number of consecutive “1” - bits from the left of the subnet mask.
Table 1. Example sub-network
Range: | 10.10.10.0 - - 10.10.10.255 |
Subnet Address: | 10.10.10.0 |
Broadcast Address: | 10.10.10.255 |
CIDR Notation: | 10.10.10.0/24 |
It is conventional to assign the internal interface either the first - usable address in the subnet (10.10.10.1 - in the above example) or the last usable address (10.10.10.254).
One of the purposes of subnetting is to allow all computers in the - subnet to understand which other computers can be communicated with - directly. To communicate with systems outside of the subnetwork, systems - send packets through a gateway (router).
Your local computers (Local Computers 1 & 2) should be - configured with their default gateway set to the IP address of the - firewall's internal interface and your DMZ computers (DMZ Computers 1 - & 2) should be configured with their default gateway set to the IP - address of the firewall's DMZ interface.
The foregoing short discussion barely scratches the surface - regarding subnetting and routing. If you are interested in learning more - about IP addressing and routing, I highly recommend “IP - Fundamentals: What Everyone Needs to Know about Addressing & Routing”, - Thomas A. Maufer, Prentice-Hall, 1999, ISBN 0-13-975483-0.
The remainder of this quide will assume that you have configured - your network as shown here:
Figure 3. DMZ
The default gateway for the DMZ computers would be 10.10.11.254 and the default gateway - for the Local computers would be 10.10.10.254.
Your ISP might assign your external interface an RFC 1918 - address. If that address is in the 10.10.10.0/24 - subnet then you will need to select a DIFFERENT RFC 1918 subnet - for your local network and if it is in the 10.10.11.0/24 subnet then you will - need to select a different RFC 1918 subnet for your DMZ.
The addresses reserved by RFC 1918 are sometimes referred to as - non-routable because the Internet backbone routers don't forward - packets which have an RFC-1918 destination address. When one of your local - systems (let's assume local computer 1) sends a connection request to - an internet host, the firewall must perform Network Address Translation - (NAT). The firewall rewrites the source address in the packet to be the - address of the firewall's external interface; in other words, the - firewall makes it look as if the firewall itself is initiating the - connection. This is necessary so that the destination host will be able to - route return packets back to the firewall (remember that packets whose - destination address is reserved by RFC 1918 can't be routed accross - the internet). When the firewall receives a return packet, it rewrites the - destination address back to 10.10.10.1 and forwards the packet on to local - computer 1.
On Linux systems, the above process is often referred to as IP - Masquerading and you will also see the term Source Network Address - Translation (SNAT) used. Shorewall follows the convention used with - Netfilter:
Masquerade - describes the case where you let your firewall system automatically detect - the external interface address.
SNAT - refers to the case when you explicitly specify the source address that you - want outbound packets from your local network to use.
- In Shorewall, both Masquerading and SNAT are configured with entries in - the /etc/shorewall/masq - file.
If your external firewall interface is eth0, - your local interface eth1 and your - DMZ interface is eth2 then you do - not need to modify the file provided with the sample. Otherwise, edit - /etc/shorewall/masq - and change it to match your configuration.
If, despite all advice to the contrary, you are using this guide and - want to use one-to-one NAT or Proxy ARP for your DMZ, remove the entry for - eth2 from /etc/shorewall/masq.
If your external IP is static, you can enter it in the third column - in the /etc/shorewall/masq - entry if you like although your firewall will work fine if you leave that - column empty. Entering your static IP in column 3 makes processing - outgoing packets a little more efficient.
If you are using the Debian package, please check your - shorewall.conf file to ensure that the following are - set correctly; if they are not, change them appropriately: -
NAT_ENABLED=Yes - (Shorewall versions earlier than 1.4.6)
IP_FORWARDING=On
One of your goals will be to run one or more servers on your DMZ - computers. Because these computers have RFC-1918 addresses, it is not - possible for clients on the internet to connect directly to them. It is - rather necessary for those clients to address their connection requests to - your firewall who rewrites the destination address to the address of your - server and forwards the packet to that server. When your server responds, - the firewall automatically performs SNAT to rewrite the source address in - the response.
The above process is called Port Forwarding or - Destination Network Address Translation (DNAT). You - configure port forwarding using DNAT rules in the /etc/shorewall/rules - file.
The general form of a simple port forwarding rule in /etc/shorewall/rules is: -
#ACTION SOURCE DEST PROTO DEST PORT(S) -DNAT net dmz:<server local ip address>[:<server port>] <protocol> <port> |
- If you don't specify the <server port>, - it is assumed to be the same as <port>.
Example 1. You run a Web Server on DMZ Computer 2 and you want to forward - incoming TCP port 80 to that system
#ACTION SOURCE DEST PROTO DEST PORT(S) -DNAT net dmz:10.10.11.2 tcp 80 -ACCEPT loc dmz:10.10.11.2 tcp 80 |
Entry - 1 forwards port 80 from the Internet.
Entry - 2 allows connections from the local network.
- Several important points to keep in mind:
When - you are connecting to your server from your local systems, you must use - the server's internal IP address (10.10.11.2).
Many - ISPs block incoming connection requests to port 80. If you have problems - connecting to your web server, try the following rule and try connecting - to port 5000 (e.g., connect to http://w.x.y.z:5000 where - w.x.y.z is your external IP).
#ACTION SOURCE DEST PROTO DEST PORT(S) SOURCE -# PORT(S) -DNAT net dmz:10.10.11.2:80 tcp 80 5000 |
If - you want to be able to access your server from the local network using - your external address, then if you have a static external IP you can - replace the loc->dmz rule above with:
#ACTION SOURCE DEST PROTO DEST PORT(S) SOURCE ORIGINAL
-# PORT(S) DEST
-DNAT loc dmz:10.10.11.2 tcp 80 - <external ip> |
If - you have a dynamic ip then you must ensure that your external interface - is up before starting Shorewall and you must take steps as follows - (assume that your external interface is eth0):
Include - the following in /etc/shorewall/params:
ETH0_IP=$(find_interface_address - eth0)
Make your - loc->dmz rule:
#ACTION SOURCE DEST PROTO DEST PORT(S) SOURCE ORIGINAL -# PORT(S) DEST -DNAT loc dmz:10.10.11.2 tcp 80 - $ETH0_IP |
If - you want to access your server from the DMZ using your external IP - address, see FAQ 2a.
At this point, add the DNAT and ACCEPT rules for your servers.
Normally, when you connect to your ISP, as part of getting an IP - address your firewall's Domain Name Service (DNS) - resolver will be automatically configured (e.g., the /etc/resolv.conf - file will be written). Alternatively, your ISP may have given you the IP - address of a pair of DNS name servers for you to manually configure as - your primary and secondary name servers. It is your responsibility to - configure the resolver in your internal systems. You can take one of two - approaches:
You can configure your internal - systems to use your ISP's name servers. If you ISP gave you the - addresses of their servers or if those addresses are available on their - web site, you can configure your internal systems to use those addresses. - If that information isn't available, look in /etc/resolv.conf - on your firewall system -- the name servers are given in “nameserver” - records in that file.
You can - configure a Caching Name Server on your firewall or - in your DMZ. Red Hat™ has an RPM for a caching name - server (which also requires the 'bind' RPM) and - for Bering users, there is dnscache.lrp. If you take - this approach, you configure your internal systems to use the caching name - server as their primary (and only) name server. You use the internal IP - address of the firewall (10.10.10.254 - in the example above) for the name server address if you choose to run the - name server on your firewall. To allow your local systems to talk to your - caching name server, you must open port 53 (both UDP and TCP) from the - local network to the server; you do that by adding the rules in - /etc/shorewall/rules.
- If you run the name server on the firewall: -
#ACTION SOURCE DEST PROTO DEST PORT(S) -AllowDNS loc fw -AllowDNS dmz fw |
Run name server on DMZ - computer 1:
#ACTION SOURCE DEST PROTO DEST PORT(S) -AllowDNS loc dmz:10.10.11.1 -AllowDNS fw dmz:10.10.11.1 |
In the rules shown above, “AllowDNS” is an example of a - defined action. Shorewall includes a number of - defined actions and you can add - your own. To see the list of actions included with your version of - Shorewall, look in the file /etc/shorewall/actions.std. - Those actions that accept connection requests have names that begin with - “Allow”.
You don't have to use defined actions when coding a rule in - /etc/shorewall/rules; the generated Netfilter ruleset - is slightly more efficient if you code your rules directly rather than - using defined actions. The first example above (name server on the - firewall) could also have been coded as follows:
#ACTION SOURCE DEST PROTO DEST PORT(S) -ACCEPT loc fw tcp 53 -ACCEPT loc fw udp 53 -ACCEPT dmz fw tcp 53 -ACCEPT dmz fw udp 53 |
In cases where Shorewall doesn't include a defined action to - meet your needs, you can either define the action yourself or you can - simply code the appropriate rules directly.
The three-interface sample includes the following rule: -
#ACTION SOURCE DEST PROTO DEST PORT(S) -AllowDNS fw net |
That rule allow DNS access from - your firewall and may be removed if you commented out the line in - /etc/shorewall/policy allowing all connections from - the firewall to the internet.
The sample also includes:
#ACTION SOURCE DEST PROTO DEST PORT(S) -AllowSSH loc fw -AllowSSH loc dmz |
Those rules allow you to run - an SSH server on your firewall and in each of your DMZ systems and to - connect to those servers from your local systems.
If you wish to enable other connections between your systems, the - general format for using a defined action is: -
#ACTION SOURCE DEST PROTO DEST PORT(S) -<action> <source zone> <destination zone> |
The general format when not using a defined action is:
#ACTION SOURCE DEST PROTO DEST PORT(S)
-ACCEPT <source zone> <destination zone> <protocol> <port> |
Example 2. You want to run a publicly-available DNS server on your firewall - system
Using defined actions:
#ACTION SOURCE DEST PROTO DEST PORT(S) -AllowDNS net fw |
Not using defined actions:
#ACTION SOURCE DEST PROTO DEST PORT(S) -ACCEPT net fw tcp 53 -ACCEPT net fw udp 53 |
Those rules would of course be in addition to the rules listed - above under "If you run the name server on your firewall".
If you don't know what port and protocol a particular - application uses, look here.
I don't recommend enabling telnet to/from the internet because - it uses clear text (even for login!). If you want shell access to your - firewall from the internet, use SSH:
#ACTION SOURCE DEST PROTO DEST PORT(S) -AllowSSH net fw |
Bering
- users will want to add the following two rules to be compatible with
- Jacques's Shorewall configuration:
#ACTION SOURCE DEST PROTO DEST PORT(S) -ACCEPT loc fw udp 53 -ACCEPT net fw tcp 80 |
Entry - 1 allows the DNS Cache to be used.
Entry - 2 allows the “weblet” to work.
Now modify /etc/shorewall/rules to add or - remove other connections as required.
The installation procedure - configures your system to start Shorewall at system boot but beginning - with Shorewall version 1.3.9 startup is disabled so that your system - won't try to start Shorewall before configuration is complete. Once - you have completed configuration of your firewall, you can enable - Shorewall startup by removing the file /etc/shorewall/startup_disabled. -
Users of the .deb package must edit - /etc/default/shorewall and set startup=1.
- The firewall is started using the shorewall start - command and stopped using shorewall stop. When the - firewall is stopped, routing is enabled on those hosts that have an entry - in /etc/shorewall/routestopped. - A running firewall may be restarted using the shorewall restart - command. If you want to totally remove any trace of Shorewall from your - Netfilter configuration, use shorewall clear.
The three-interface sample assumes that you want to enable routing - to/from eth1 (your local network) - and eth2 (DMZ) when Shorewall is - stopped. If these two interfaces don't connect to your local network - and DMZ or if you want to enable a different set of hosts, modify - /etc/shorewall/routestopped accordingly. -
If you are connected to your firewall from the internet, do - not issue a shorewall stop command unless you have - added an entry for the IP address that you are connected from to /etc/shorewall/routestopped. - Also, I don't recommend using shorewall restart; it - is better to create an alternate - configuration and test it using the shorewall try - command.
I highly recommend that you review the Common Configuration File Features - page -- it contains helpful tips about Shorewall features than make - administering your firewall easier.
dhcpfrom the option list.
netzone. Any + traffic that you generate from the local network will be associated + with your local interface and will be treated as loc->fw traffic.
-(minus the quotes).
-+ (minus the quotes).