Shorewall Firewall is a high level netfilter/iptables configuration tool. 1)
This document complements the LXC NAT Routing configuration Howto.
This document is based on:
- Tux4u®/Penguin Suite: PS-wheezy
- PS-app: emu-lxc 1.0.4
# apt-get install shorewall
Enable Linux kernel ip_forwarding:
# IP_FORWARDING=Keep IP_FORWARDING=On
# For information about entries in this file, type "man shorewall-zones" ############################################################################### #ZONE TYPE OPTIONS IN OUT # OPTIONS OPTIONS fw firewall net ipv4 lxc ipv4
Annotation of “fw zone”: 2)
Annotation of “lxc zone”: 3)
# For information about entries in this file, type "man shorewall-interfaces" ############################################################################### FORMAT 2 ############################################################################### #ZONE INTERFACE OPTIONS net eth0 dhcp,tcpflags,nosmurfs,routefilter,logmartians,sourceroute=0 lxc br0 routeback,bridge,tcpflags,nosmurfs,routefilter,logmartians
# For information about entries in this file, type "man shorewall-policy" ############################################################################### #SOURCE DEST POLICY LOG LEVEL LIMIT:BURST $FW net ACCEPT $FW lxc ACCEPT lxc net ACCEPT lxc $FW ACCEPT net all DROP info # THE FOLLOWING POLICY MUST BE LAST all all REJECT info
# For information about entries in this file, type "man shorewall-rules" ###################################################################################################################################################################################### #ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH # PORT PORT(S) DEST LIMIT GROUP #SECTION ALL #SECTION ESTABLISHED #SECTION RELATED SECTION NEW # Don't allow connection pickup from the net # Invalid(DROP) net all Ping(ACCEPT) net $FW # # Connections from net # ==================== #ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH # PORT PORT(S) DEST LIMIT GROUP SSH(ACCEPT) net:192.168.1.0/24 $FW # DNAT rules # ========== #ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH # PORT PORT(S) DEST LIMIT GROUP DNAT net lxc:172.16.1.1 tcp 80 - 192.168.1.101
# cd /etc/shorewall # shorewall check .
# cd /etc/shorewall # shorewall start
Annotation of “shorewall start”: 4)
More information on shorewall commands:
$ man shorewall
Edit the “/etc/default/shorewall” and set “startup=1”:
## /etc/default/shorewall # prevent startup with default configuration # set the following varible to 1 in order to allow Shorewall to start # startup=0 startup=1
Links | |
---|---|
http://www.shorewall.net | Shorewall Firewall Homepage |
$ man -k shorewall | List of Shorewall commands and files |
/usr/share/doc/shorewall/* | Shorewall documentation and examples |
Copyright © 2014 Integrated Services; Tux4u.nl
Author: Marjan Waldorp; lxc/lxc-shorewallnat 2014-09-01
If 192.168.1.254 is the IP address of your internal interface then you can write $FW:192.168.1.254 in a rule but you may not write loc:192.168.1.254. Similarly, it is nonsensical to add 192.168.1.254 to the loc zone using an entry in /etc/shorewall/hosts.Shorewall Two-Interface example: Some Things to Keep in Mind