]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - src/initscripts/system/firewall
:xMerge branch 'next' of ssh://git.ipfire.org/pub/git/ipfire-2.x into next-switch...
[ipfire-2.x.git] / src / initscripts / system / firewall
index cb533cc94b12f2ee3c4368500bb7adbf20d8a490..65f1c979bb4007f1987fbfe897b5e1d91ed30f23 100644 (file)
@@ -32,30 +32,34 @@ iptables_init() {
        iptables -P FORWARD DROP
        iptables -P OUTPUT ACCEPT
 
+       # Enable TRACE logging to syslog
+       modprobe nf_log_ipv4
+       sysctl -q -w net.netfilter.nf_log.2=nf_log_ipv4
+
        # Empty LOG_DROP and LOG_REJECT chains
        iptables -N LOG_DROP
-       iptables -A LOG_DROP   -m limit --limit 10/minute -j LOG
+       iptables -A LOG_DROP   -m limit --limit 10/second -j LOG
        iptables -A LOG_DROP   -j DROP
        iptables -N LOG_REJECT
-       iptables -A LOG_REJECT -m limit --limit 10/minute -j LOG
+       iptables -A LOG_REJECT -m limit --limit 10/second -j LOG
        iptables -A LOG_REJECT -j REJECT
 
        # This chain will log, then DROPs packets with certain bad combinations
-       # of flags might indicate a port-scan attempt (xmas, null, etc)
+       # of flags might indicate a port-scan attempt (xmas, null, etc.)
        iptables -N PSCAN
        if [ "$DROPPORTSCAN" == "on" ]; then
-               iptables -A PSCAN -p tcp  -m limit --limit 10/minute -j LOG --log-prefix "DROP_TCP Scan " -m comment --comment "DROP_TCP PScan"
-               iptables -A PSCAN -p udp  -m limit --limit 10/minute -j LOG --log-prefix "DROP_UDP Scan " -m comment --comment "DROP_UDP PScan"
-               iptables -A PSCAN -p icmp -m limit --limit 10/minute -j LOG --log-prefix "DROP_ICMP Scan " -m comment --comment "DROP_ICMP PScan"
-               iptables -A PSCAN -f      -m limit --limit 10/minute -j LOG --log-prefix "DROP_FRAG Scan " -m comment --comment "DROP_FRAG PScan"
+               iptables -A PSCAN -p tcp  -m limit --limit 10/second -j LOG --log-prefix "DROP_TCP Scan "  -m comment --comment "DROP_TCP PScan"
+               iptables -A PSCAN -p udp  -m limit --limit 10/second -j LOG --log-prefix "DROP_UDP Scan "  -m comment --comment "DROP_UDP PScan"
+               iptables -A PSCAN -p icmp -m limit --limit 10/second -j LOG --log-prefix "DROP_ICMP Scan " -m comment --comment "DROP_ICMP PScan"
+               iptables -A PSCAN -f      -m limit --limit 10/second -j LOG --log-prefix "DROP_FRAG Scan " -m comment --comment "DROP_FRAG PScan"
        fi
        iptables -A PSCAN -j DROP -m comment --comment "DROP_PScan"
 
        # New tcp packets without SYN set - could well be an obscure type of port scan
-       # that's not covered above, may just be a broken windows machine
+       # that's not covered above, may just be a broken Windows machine
        iptables -N NEWNOTSYN
        if [ "$DROPNEWNOTSYN" == "on" ]; then
-               iptables -A NEWNOTSYN  -m limit --limit 10/minute -j LOG  --log-prefix "DROP_NEWNOTSYN "
+               iptables -A NEWNOTSYN  -m limit --limit 10/second -j LOG  --log-prefix "DROP_NEWNOTSYN "
        fi
        iptables -A NEWNOTSYN  -j DROP -m comment --comment "DROP_NEWNOTSYN"
 
@@ -96,6 +100,9 @@ iptables_init() {
 
        # Conntrack helpers (https://home.regit.org/netfilter-en/secure-use-of-helpers/)
 
+       # GRE (always enabled)
+       modprobe nf_conntrack_proto_gre
+
        # SIP
        if [ "${CONNTRACK_SIP}" = "on" ]; then
                modprobe nf_nat_sip
@@ -159,7 +166,7 @@ iptables_init() {
                iptables -t raw -A CONNTRACK -p tcp -j CT --helper amanda
        fi
 
-       # Fix for braindead ISP's
+       # Fix for braindead ISPs
        iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
 
        # CUSTOM chains, can be used by the users themselves
@@ -180,7 +187,7 @@ iptables_init() {
        iptables -A FORWARD -j P2PBLOCK
        iptables -A OUTPUT -j P2PBLOCK
        
-       # Guardian (IPS) chains
+       # IPS (Guardian) chains
        iptables -N GUARDIAN
        iptables -A INPUT -j GUARDIAN
        iptables -A FORWARD -j GUARDIAN
@@ -196,6 +203,14 @@ iptables_init() {
        iptables -A FORWARD -i tun+ -j OVPNBLOCK
        iptables -A FORWARD -o tun+ -j OVPNBLOCK
 
+       # IPS (Suricata) chains
+       iptables -N IPS_INPUT
+       iptables -N IPS_FORWARD
+       iptables -N IPS_OUTPUT
+       iptables -A INPUT -j IPS_INPUT
+       iptables -A FORWARD -j IPS_FORWARD
+       iptables -A OUTPUT -j IPS_OUTPUT
+
        # OpenVPN transfer network translation
        iptables -t nat -N OVPNNAT
        iptables -t nat -A POSTROUTING -j OVPNNAT
@@ -253,7 +268,7 @@ iptables_init() {
                iptables -A OUTPUT -o "${GREEN_DEV}" -j DHCPGREENOUTPUT
        fi
 
-       # allow DHCP on BLUE to be turned on/off
+       # Allow DHCP on BLUE to be turned on/off
        iptables -N DHCPBLUEINPUT
        iptables -N DHCPBLUEOUTPUT
        if [ -n "${BLUE_DEV}" ]; then
@@ -261,10 +276,10 @@ iptables_init() {
                iptables -A OUTPUT -o "${BLUE_DEV}" -j DHCPBLUEOUTPUT
        fi
 
-       # GeoIP block
-       iptables -N GEOIPBLOCK
-       iptables -A INPUT -j GEOIPBLOCK
-       iptables -A FORWARD -j GEOIPBLOCK
+       # Location Block
+       iptables -N LOCATIONBLOCK
+       iptables -A INPUT -j LOCATIONBLOCK
+       iptables -A FORWARD -j LOCATIONBLOCK
 
        # trafic from ipsecX/TUN/TAP interfaces, before "-i GREEN_DEV" accept everything
        iptables -N IPSECINPUT
@@ -371,6 +386,9 @@ iptables_init() {
        # run wirelessctrl
        /usr/local/bin/wirelessctrl
 
+       # run captivectrl
+       /usr/local/bin/captivectrl
+
        # POLICY CHAIN
        iptables -N POLICYIN
        iptables -A INPUT -j POLICYIN
@@ -427,7 +445,7 @@ iptables_red_up() {
                        iptables -A REDINPUT -p udp --source-port 67 --destination-port 68 -i $IFACE -j ACCEPT
                fi
 
-               # Outgoing masquerading (don't masqerade IPSEC (mark 50))
+               # Outgoing masquerading (don't masqerade IPsec (mark 50))
                iptables -t nat -A REDNAT -m mark --mark 50 -o $IFACE -j RETURN
 
                if [ "${IFACE}" = "${GREEN_DEV}" ]; then