]> git.ipfire.org Git - network.git/commitdiff
Merge branch 'master' into 6rd-new
authorStefan Schantl <stefan.schantl@ipfire.org>
Thu, 9 May 2013 04:33:46 +0000 (04:33 +0000)
committerStefan Schantl <stefan.schantl@ipfire.org>
Thu, 9 May 2013 04:33:46 +0000 (04:33 +0000)
54 files changed:
Makefile
firewall-config [moved from sysctl.d/firewall-acct.conf with 91% similarity, mode: 0755]
firewall4
firewall6
functions.cli
functions.cli.firewall
functions.config
functions.conntrack [new file with mode: 0644]
functions.constants
functions.constants-firewall
functions.dhclient
functions.firewall
functions.hook
functions.iptables
functions.ipv4
functions.ipv6
functions.ppp
functions.sysctl [new file with mode: 0644]
functions.util
header-port
header-zone
helpers/firewall-kernel-init [new file with mode: 0755]
hooks/ports/batman-adv
hooks/ports/batman-adv-port
hooks/ports/bonding
hooks/ports/dummy
hooks/ports/ethernet
hooks/ports/macvlan
hooks/ports/vlan
hooks/ports/wireless-ap
hooks/zones/6to4-tunnel
hooks/zones/aiccu
hooks/zones/bridge
hooks/zones/bridge.configs/ipv4-dhcp
hooks/zones/bridge.configs/ipv4-static
hooks/zones/bridge.configs/ipv6-static
hooks/zones/bridge.configs/pppoe-server
hooks/zones/bridge.ports/ethernet
hooks/zones/isdn
hooks/zones/isdn-server
hooks/zones/modem
hooks/zones/pppoe
hooks/zones/switch
hooks/zones/teredo
hooks/zones/wireless
man/firewall-config.xml [new file with mode: 0644]
ppp/ip-updown
sysctl.d/network-ipv4.conf [deleted file]
sysctl.d/network-ipv6.conf [deleted file]
systemd/firewall-init.service [new file with mode: 0644]
systemd/firewall4.service
systemd/firewall6.service
systemd/network.service
systemd/network@.service

index 5a6645ed68a295ff36e0b8f52fa6f82bd6b050fe..ff79ad8c48e9dfc0e9bcd7d97637b1841df771b2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -45,6 +45,7 @@ CLEANFILES =
 
 # man pages
 MAN_PAGES = \
+       man/firewall-config.8 \
        man/network.8 \
        man/network-config.8 \
        man/network-device.8 \
@@ -103,6 +104,7 @@ install: $(MAN_PAGES)
        -mkdir -pv $(DESTDIR)$(tmpfilesdir)
        -mkdir -pv $(DESTDIR)$(datadir)/firewall
 
+       install -m 755 -v firewall-config $(DESTDIR)$(sbindir)
        install -m 755 -v firewall6 $(DESTDIR)$(sbindir)
        install -m 755 -v firewall4 $(DESTDIR)$(sbindir)
        install -m 755 -v network $(DESTDIR)$(sbindir)
old mode 100644 (file)
new mode 100755 (executable)
similarity index 91%
rename from sysctl.d/firewall-acct.conf
rename to firewall-config
index 253f8db..d8d8d4f
@@ -1,3 +1,4 @@
+#!/bin/bash
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
 #                                                                             #
 ###############################################################################
 
-# Enable connection tracking accounting.
-net.netfilter.nf_conntrack_acct=1
+. /usr/lib/network/functions
+
+# Read firewall configuration.
+firewall_config_read
+
+firewall_cli_config "$@"
+
+exit ${EXIT_ERROR}
index 68fa8aeafad3f421935c7bd65b2b70cd9b3e283a..5de6bfa963d143c4504978709cfb0a237632a572 100755 (executable)
--- a/firewall4
+++ b/firewall4
@@ -22,7 +22,7 @@
 . /usr/lib/network/functions
 
 # Read firewall configuration.
-firewall_config_read "ipv4"
+firewall_config_read
 
 firewall_cli "ipv4" "$@"
 
index 74afeef652b78eb365b6cf081e2663efaa7a9232..70ae2ffe85ca4f24d5520943bd4439d0936019fa 100755 (executable)
--- a/firewall6
+++ b/firewall6
@@ -22,7 +22,7 @@
 . /usr/lib/network/functions
 
 # Read firewall configuration.
-firewall_config_read "ipv6"
+firewall_config_read
 
 firewall_cli "ipv6" "$@"
 
index 2d35e6420354108c82f203f31033940360cf3337..3389b4106898d22c15a399978061e963b746d23d 100644 (file)
@@ -348,6 +348,18 @@ function cli_get_val() {
        echo "${@#*=}"
 }
 
+function cli_get_bool() {
+       local value="$(cli_get_val "$@")"
+
+       if enabled value; then
+               print "true"
+               return ${EXIT_TRUE}
+       fi
+
+       print "false"
+       return ${EXIT_FALSE}
+}
+
 function cli_usage() {
        local command="$@"
        local basename="$(basename ${0})"
index 39f0a4345b168c4e9b114b7c499d79b221f98396..7d3557d22104d42231dae81c5f050fe560354301 100755 (executable)
@@ -57,10 +57,6 @@ function firewall_cli() {
                        firewall_cli_panic "${protocol}" "$@"
                        ;;
 
-               config)
-                       firewall_cli_config "${protocol}" $@
-                       ;;
-
                zone)
                        firewall_cli_zone $@
                        ;;
@@ -108,20 +104,16 @@ function firewall_cli_panic() {
 }
 
 function firewall_cli_config() {
-       local protocol="${1}"
-       assert isset protocol
-       shift
-
        if cli_help_requested $@; then
-               cli_usage root-config
+               cli_show_man firewall-config
                exit ${EXIT_OK}
        fi
 
        if [ -n "${1}" ]; then
                config_set "$@"
-               firewall_config_write "${protocol}"
+               firewall_config_write
        else
-               firewall_config_print "${protocol}"
+               firewall_config_print
        fi
 }
 
index 11e924669331c792b701c6a9ed643ea61da155c2..6f84b743d9f3e1a7939d563d18dc77d6371c5f3f 100644 (file)
@@ -133,7 +133,7 @@ function config_print() {
        local param
 
        for param in $(listsort $@); do
-               printf "%-24s = %s\n" "${param}" "${!param}"
+               printf "%-32s = %s\n" "${param}" "${!param}"
        done
 }
 
@@ -218,60 +218,14 @@ function network_config_print() {
        config_print ${NETWORK_CONFIG_FILE_PARAMS}
 }
 
-function firewall_config_file() {
-       local protocol="${1}"
-       assert isset protocol
-
-       local file
-       case "${protocol}" in
-               ipv6)
-                       file="${FIREWALL6_CONFIG_FILE}"
-                       ;;
-               ipv4)
-                       file="${FIREWALL4_CONFIG_FILE}"
-                       ;;
-       esac
-       assert isset file
-
-       print "${file}"
-       return ${EXIT_OK}
-}
-
-function firewall_config_env() {
-       local protocol="${1}"
-       assert isset protocol
-
-       case "${protocol}" in
-               ipv6)
-                       file="${FIREWALL6_CONFIG_FILE}"
-                       params="${FIREWALL6_CONFIG_PARAMS}"
-                       ;;
-               ipv4)
-                       file="${FIREWALL4_CONFIG_FILE}"
-                       params="${FIREWALL4_CONFIG_PARAMS}"
-                       ;;
-       esac
-       assert isset file
-       assert isset params
-}
-
 function firewall_config_read() {
-       local file params
-       firewall_config_env "$@"
-
-       config_read "${file}" "${params}"
+       config_read "${FIREWALL_CONFIG_FILE}" "${FIREWALL_CONFIG_PARAMS}"
 }
 
 function firewall_config_write() {
-       local file params
-       firewall_config_env "$@"
-
-       config_write "${file}" "${params}"
+       config_write "${FIREWALL_CONFIG_FILE}" "${FIREWALL_CONFIG_PARAMS}"
 }
 
 function firewall_config_print() {
-       local file params
-       firewall_config_env "$@"
-
-       config_print "${params}"
+       config_print "${FIREWALL_CONFIG_PARAMS}"
 }
diff --git a/functions.conntrack b/functions.conntrack
new file mode 100644 (file)
index 0000000..aa432ef
--- /dev/null
@@ -0,0 +1,70 @@
+#!/bin/bash
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2013  IPFire Network Development Team                         #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+# Accounting
+
+function conntrack_get_accounting() {
+       sysctl_get "net.netfilter.nf_conntrack_acct"
+}
+
+function conntrack_set_accounting() {
+       local value="${1}"
+       assert isset value
+
+       # Convert boolean values into 0 and 1.
+       if enabled value; then
+               log INFO "Enabling connection tracking accounting"
+               value="1"
+       else
+               log INFO "Disabling connection tracking accounting"
+               value="0"
+       fi
+
+       sysctl_set "net.netfilter.nf_conntrack_acct" "${value}"
+}
+
+# Max. connections
+
+function conntrack_get_max_connections() {
+       sysctl_get "net.netfilter.nf_conntrack_max"
+}
+
+function conntrack_set_max_connections() {
+       local value="${1}"
+       assert isinteger value
+
+       log INFO "Conntrack: Setting max. amount of concurrent connections to ${value}"
+       sysctl_set "net.netfilter.nf_conntrack_max" "${value}"
+}
+
+# UDP timeout
+
+function conntrack_get_udp_timeout() {
+       sysctl_get "net.netfilter.nf_conntrack_udp_timeout"
+}
+
+function conntrack_set_udp_timeout() {
+       local value="${1}"
+       assert isinteger value
+
+       log INFO "Conntrack: Setting UDP timeout to ${value}s"
+       sysctl_set "net.netfilter.nf_conntrack_udp_timeout" "${value}"
+}
index 21b44fcad413fb47250bafc20e15f565fccda768..018488411649c111884862ca0a510e9aa997dcf2 100644 (file)
@@ -51,6 +51,7 @@ NETWORK_CONFIG_ROUTES_PARAMS="network gateway unreachable prohibit blackhole mtu
 EXIT_OK=0
 EXIT_ERROR=1
 EXIT_CONF_ERROR=2
+EXIT_COMMAND_NOT_FOUND=127
 EXIT_ERROR_ASSERT=128
 
 EXIT_TRUE=0
index decd708443b6187f5a0336a32efc0ce5e8f06c98..f1eaf505b5531c10b0c80a9dcc275ffe3597457a 100644 (file)
@@ -25,8 +25,7 @@ IPTABLES_TMPDIR=
 
 FIREWALL_CONFIG_DIR="/etc/firewall"
 FIREWALL_ZONES_DIR="${FIREWALL_CONFIG_DIR}/zones"
-FIREWALL4_CONFIG_FILE="${FIREWALL_CONFIG_DIR}/config4"
-FIREWALL6_CONFIG_FILE="${FIREWALL_CONFIG_DIR}/config6"
+FIREWALL_CONFIG_FILE="${FIREWALL_CONFIG_DIR}/config"
 FIREWALL_CONFIG_RULES="${FIREWALL_CONFIG_DIR}/rules"
 
 FIREWALL_MACROS_DIRS="${FIREWALL_CONFIG_DIR}/macros"
@@ -50,8 +49,61 @@ FIREWALL_CONFIG_PARAMS="${FIREWALL_CONFIG_PARAMS} FIREWALL_NFLOG_THRESHOLD"
 FIREWALL_CLAMP_PATH_MTU="false"
 FIREWALL_CONFIG_PARAMS="${FIREWALL_CONFIG_PARAMS} FIREWALL_CLAMP_PATH_MTU"
 
-FIREWALL4_CONFIG_PARAMS="${FIREWALL_CONFIG_PARAMS}"
-FIREWALL6_CONFIG_PARAMS="${FIREWALL_CONFIG_PARAMS}"
+# Conntrack: Max. amount of simultaneous connections.
+CONNTRACK_MAX_CONNECTIONS="16384"
+FIREWALL_CONFIG_PARAMS="${FIREWALL_CONFIG_PARAMS} CONNTRACK_MAX_CONNECTIONS"
+
+# Conntrack: UDP timeout
+CONNTRACK_UDP_TIMEOUT="60"
+FIREWALL_CONFIG_PARAMS="${FIREWALL_CONFIG_PARAMS} CONNTRACK_UDP_TIMEOUT"
+
+# Use SYN cookies or not
+FIREWALL_SYN_COOKIES="true"
+FIREWALL_CONFIG_PARAMS="${FIREWALL_CONFIG_PARAMS} FIREWALL_SYN_COOKIES"
+
+# rp_filter
+FIREWALL_RP_FILTER="true"
+FIREWALL_CONFIG_PARAMS="${FIREWALL_CONFIG_PARAMS} FIREWALL_RP_FILTER"
+
+# Log martians
+FIREWALL_LOG_MARTIANS="false"
+FIREWALL_CONFIG_PARAMS="${FIREWALL_CONFIG_PARAMS} FIREWALL_LOG_MARTIANS"
+
+# Accept ICMP redirects
+FIREWALL_ACCEPT_ICMP_REDIRECTS="false"
+FIREWALL_CONFIG_PARAMS="${FIREWALL_CONFIG_PARAMS} FIREWALL_ACCEPT_ICMP_REDIRECTS"
+
+# ECN (Explicit Congestion Notification)
+FIREWALL_USE_ECN="false"
+FIREWALL_CONFIG_PARAMS="${FIREWALL_CONFIG_PARAMS} FIREWALL_USE_ECN"
+
+# Path MTU discovery
+FIREWALL_PMTU_DISCOVERY="true"
+FIREWALL_CONFIG_PARAMS="${FIREWALL_CONFIG_PARAMS} FIREWALL_PMTU_DISCOVERY"
+
+# Default TTL
+FIREWALL_DEFAULT_TTL="64"
+FIREWALL_CONFIG_PARAMS="${FIREWALL_CONFIG_PARAMS} FIREWALL_DEFAULT_TTL"
+
+# Log stealth scans
+FIREWALL_LOG_STEALTH_SCANS="true"
+FIREWALL_CONFIG_PARAMS="${FIREWALL_CONFIG_PARAMS} FIREWALL_LOG_STEALTH_SCANS"
+
+# Log packets with bad TCP flags
+FIREWALL_LOG_BAD_TCP_FLAGS="true"
+FIREWALL_CONFIG_PARAMS="${FIREWALL_CONFIG_PARAMS} FIREWALL_LOG_BAD_TCP_FLAGS"
+
+# Log INVALID TCP packets
+FIREWALL_LOG_INVALID_TCP="true"
+FIREWALL_CONFIG_PARAMS="${FIREWALL_CONFIG_PARAMS} FIREWALL_LOG_INVALID_TCP"
+
+# Log INVALID UDP packets
+FIREWALL_LOG_INVALID_UDP="true"
+FIREWALL_CONFIG_PARAMS="${FIREWALL_CONFIG_PARAMS} FIREWALL_LOG_INVALID_UDP"
+
+# Log INVALID ICMP packets
+FIREWALL_LOG_INVALID_ICMP="true"
+FIREWALL_CONFIG_PARAMS="${FIREWALL_CONFIG_PARAMS} FIREWALL_LOG_INVALID_ICMP"
 
 FIREWALL_SUPPORTED_PROTOCOLS="tcp udp icmp igmp esp ah gre"
 FIREWALL_PROTOCOLS_SUPPORTING_PORTS="tcp udp"
index d94684a83a50fd5644347ccf9a7b1c7a0493a5f2..29a6d664c00cd293c05418b5a9711d69b99dd1f1 100644 (file)
@@ -82,6 +82,7 @@ dhclient_write_config() {
        assert isset file
 
        local hostname=${HOSTNAME%%.*}
+       local prefix_delegation="false"
        local vendor=$(distro_get_pretty_name)
 
        while [ $# -gt 0 ]; do
@@ -89,6 +90,9 @@ dhclient_write_config() {
                        --hostname=*)
                                hostname=$(cli_get_val ${1})
                                ;;
+                       --prefix-delegation=*)
+                               prefix_delegation="$(cli_get_bool "${1}")"
+                               ;;
                        --vendor=*)
                                vendor=$(cli_get_val ${1})
                                ;;
@@ -124,6 +128,15 @@ dhclient_write_config() {
 
                if isset hostname; then
                        echo "  send host-name \"${hostname}\";"
+                       print
+               fi
+
+               # Prefix delegation (IPv6).
+               if enabled prefix_delegation; then
+                       print " # Prefix delegation"
+                       print " also request dhcp6.ia-pd 1;"
+                       print " send dhcp6.ia-na 1;"
+                       print
                fi
 
                echo "}"
index 3f0d5ff85394e039c222d1add7878a2598ab1a25..494e3bb367edc9be1286293cf7573d4763704a16 100644 (file)
 #                                                                             #
 ###############################################################################
 
+# This function initializes all kernel parameters that need to be adjusted
+# to run this firewall properly.
+function firewall_kernel_init() {
+       log INFO "Configuring kernel parameters..."
+       local option
+
+       # Enable conntrack accounting
+       conntrack_set_accounting "true"
+
+       # Adjust max. amount of simultaneous connections
+       conntrack_set_max_connections "${CONNTRACK_MAX_CONNECTIONS}"
+
+       # Increase UDP connection timeout (fixes DNS)
+       conntrack_set_udp_timeout "${CONNTRACK_UDP_TIMEOUT}"
+
+       # Disable sending redirects
+       log INFO "Disabling sending redirects"
+       sysctl_set_recursively "net.ipv6.conf" "send_redirects" 0
+       sysctl_set_recursively "net.ipv4.conf" "send_redirects" 0
+
+       # Enable source route protection
+       log INFO "Enabling source route protection"
+       sysctl_set_recursively "net.ipv6.conf" "accept_source_route" 0
+       sysctl_set_recursively "net.ipv4.conf" "accept_source_route" 0
+
+       # ICMP broadcast protection (smurf amplifier protection)
+       log INFO "Enabling ICMP broadcast protection (smurf amplifier protection)"
+       sysctl_set "net.ipv4.icmp_echo_ignore_broadcasts" 1
+
+       # ICMP Dead Error Message protection
+       log INFO "Enabling ICMP dead error message protection"
+       sysctl_set "net.ipv4.icmp_ignore_bogus_error_responses" 0
+
+       # Enable packet forwarding
+       log INFO "Enabling packet forwarding"
+       sysctl_set_recursively "net.ipv6.conf" "forwarding" 1
+       sysctl_set_recursively "net.ipv4.conf" "forwarding" 1
+
+       # Setting some kernel performance options
+       log INFO "Setting some kernel performance options"
+       for option in window_scaling timestamps sack dsack fack; do
+               sysctl_set "net.ipv4.tcp_${option}" 1
+       done
+       sysctl_set "net.ipv4.tcp_low_latency" 0
+
+       # Reduce DoS ability by reducing timeouts
+       log INFO "Reducing DoS ability"
+       sysctl_set "net.ipv4.tcp_fin_timeout" 30
+       sysctl_set "net.ipv4.tcp_keepalive_time" 1800
+
+       # Set number of times to retry SYN in a new connection
+       sysctl_set "net.ipv4.tcp_syn_retries" 3
+
+       # Set number of times to retry a SYN-ACK in a half-open new connection
+       sysctl_set "net.ipv4.tcp_synack_retries" 2
+
+       # Enable a fix for RFC1337 - time-wait assassination hazards in TCP
+       sysctl_set "net.ipv4.tcp_rfc1337" 1
+
+       # SYN-flood protection
+       if enabled FIREWALL_SYN_COOKIES; then
+               log INFO "Enabling SYN-flood protection via SYN-cookies"
+               sysctl_set_bool "net.ipv4.tcp_syncookies" 1
+       else
+               log INFO "Disabling SYN-flood protection via SYN-cookies"
+               sysctl_set_bool "net.ipv4.tcp_syncookies" 0
+       fi
+
+       # rp_filter
+       if enabled FIREWALL_RP_FILTER; then
+               log INFO "Enabling anti-spoof from non-routable IP addresses"
+               sysctl_set_recursively "net.ipv4.conf" "rp_filter" 1
+       else
+               log INFO "Disabling anti-spoof from non-routable IP addresses"
+               sysctl_set_recursively "net.ipv4.conf" "rp_filter" 0
+       fi
+
+       # Log martians
+       if enabled FIREWALL_LOG_MARTIANS; then
+               log INFO "Enabling the logging of martians"
+               sysctl_set_recursively "net.ipv4.conf" "log_martians" 1
+       else
+               log INFO "Disabling the logging of martians"
+               sysctl_set_recursively "net.ipv4.conf" "log_martians" 0
+       fi
+
+       # ICMP redirect messages
+       if enabled FIREWALL_ACCEPT_ICMP_REDIRECTS; then
+               log INFO "Enabling accepting ICMP-redirect messages"
+               sysctl_set_recursively "net.ipv6.conf" "accept_redirects" 1
+               sysctl_set_recursively "net.ipv4.conf" "accept_redirects" 1
+       else
+               log INFO "Disabling accepting ICMP-redirect messages"
+               sysctl_set_recursively "net.ipv6.conf" "accept_redirects" 0
+               sysctl_set_recursively "net.ipv4.conf" "accept_redirects" 0
+       fi
+
+       # Explicit Congestion Notification
+       if enabled FIREWALL_USE_ECN; then
+               log INFO "Enabling ECN (Explicit Congestion Notification)"
+               sysctl_set "net.ipv4.tcp_ecn" 1
+       else
+               log INFO "Disabling ECN (Explicit Congestion Notification)"
+               sysctl_set "net.ipv4.tcp_ecn" 2
+       fi
+
+       # Dynamic IP address hacking
+       log INFO "Enabling kernel support for dynamic IP addresses"
+       sysctl_set "net.ipv4.ip_dynaddr" 1
+
+       if enabled FIREWALL_PMTU_DISCOVERY; then
+               log INFO "Enabling PMTU discovery"
+               sysctl_set "net.ipv4.ip_no_pmtu_disc" 0
+       else
+               log INFO "Disabling PMTU discovery"
+               sysctl_set "net.ipv4.ip_no_pmtu_disc" 1
+       fi
+
+       # TTL
+       if ipv4_ttl_valid "${FIREWALL_DEFAULT_TTL}"; then
+               log INFO "Setting default TTL to ${FIREWALL_DEFAULT_TTL}"
+               sysctl_set "net.ipv4.ip_default_ttl" "${FIREWALL_DEFAULT_TTL}"
+       else
+               log ERROR "Invalid value for default TTL '${FIREWALL_DEFAULT_TTL}'"
+               log ERROR "  Must be between 10 and 255!"
+       fi
+
+       return ${EXIT_OK}
+}
+
 # High-level function which will create a ruleset for the current firewall
 # configuration and load it into the kernel.
 function firewall_start() {
@@ -53,7 +183,9 @@ function firewall_start() {
        iptables_init "${protocol}" "DROP"
 
        # Add default chains.
-       firewall_tcp_state_flags "${protocol}"
+       firewall_filter_rh0_headers "${protocol}"
+       firewall_filter_icmp "${protocol}"
+       firewall_filter_invalid_packets "${protocol}"
        firewall_custom_chains "${protocol}"
        firewall_connection_tracking "${protocol}"
        firewall_tcp_clamp_mss "${protocol}"
@@ -191,28 +323,145 @@ function firewall_custom_chains() {
        iptables "${protocol}" -t nat -A OUTPUT -j CUSTOMOUTPUT
 }
 
-function firewall_tcp_state_flags() {
+function firewall_filter_invalid_packets() {
        local protocol="${1}"
        assert isset protocol
 
-       log INFO "Creating TCP State Flags chain..."
+       local log_limit="-m limit --limit 5/m --limit-burst 10"
+
+       # Create a chain
+       iptables_chain_create "${protocol}" FILTER_INVALID
+       iptables "${protocol}" -A INPUT   -j FILTER_INVALID
+       iptables "${protocol}" -A OUTPUT  -j FILTER_INVALID
+       iptables "${protocol}" -A FORWARD -j FILTER_INVALID
+
+       # Create a chain where only TCP packets go
+       iptables_chain_create "${protocol}" FILTER_INVALID_TCP
+       iptables "${protocol}" -A FILTER_INVALID -p tcp -j FILTER_INVALID_TCP
+
+       # Create a chain where only UDP packets go
+       iptables_chain_create "${protocol}" FILTER_INVALID_UDP
+       iptables "${protocol}" -A FILTER_INVALID -p udp -j FILTER_INVALID_UDP
+
+       # Create a chain where only ICMP packets go
+       iptables_chain_create "${protocol}" FILTER_INVALID_ICMP
+       iptables "${protocol}" -A FILTER_INVALID -p icmp -j FILTER_INVALID_ICMP
+
+
+       # Optionally log all port scans
+
+       if enabled FIREWALL_LOG_STEALTH_SCANS; then
+               log INFO "Logging of stealth scans enabled"
+
+               # NMAP FIN/URG/PSH - XMAS scan
+               iptables "${protocol}" -A FILTER_INVALID_TCP -p tcp --tcp-flags ALL FIN,URG,PSH \
+                       "${log_limit}" -j "$(iptables_LOG "Stealth XMAS scan")"
+
+               # SYN/RST/ACK/FIN/URG
+               iptables "${protocol}" -A FILTER_INVALID_TCP -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG \
+                       "${log_limit}" -j "$(iptables_LOG "Stealth XMAS-PSH scan")"
+
+               # ALL/ALL
+               iptables "${protocol}" -A FILTER_INVALID_TCP -p tcp --tcp-flags ALL ALL \
+                       "${log_limit}" -j "$(iptables_LOG "Stealth XMAS-ALL scan")"
+
+               # NMAP FIN Stealth
+               iptables "${protocol}" -A FILTER_INVALID_TCP -p tcp --tcp-flags ALL FIN \
+                       "${log_limit}" -j "$(iptables_LOG "Stealth FIN scan")"
+
+               # SYN/RST
+               iptables "${protocol}" -A FILTER_INVALID_TCP -p tcp --tcp-flags SYN,RST SYN,RST \
+                       "${log_limit}" -j "$(iptables_LOG "Stealth SYN/RST scan")"
+
+               # SYN/FIN
+               iptables "${protocol}" -A FILTER_INVALID_TCP -p tcp --tcp-flags SYN,FIN SYN,FIN \
+                       "${log_limit}" -j "$(iptables_LOG "Stealth SYN/FIN scan")"
+
+               # Null scan
+               iptables "${protocol}" -A FILTER_INVALID_TCP -p tcp --tcp-flags ALL NONE \
+                       "${log_limit}" -j "$(iptables_LOG "Stealth NULL scan")"
+       else
+               log INFO "Logging of stealth scans disabled"
+       fi
+
+
+       # Drop scan packets
+
+       # NMAP FIN/URG/PSH
+       iptables "${protocol}" -A FILTER_INVALID_TCP -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
+
+       # SYN/RST/ACK/FIN/URG
+       iptables "${protocol}" -A FILTER_INVALID_TCP -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
+
+       # ALL/ALL
+       iptables "${protocol}" -A FILTER_INVALID_TCP -p tcp --tcp-flags ALL ALL -j DROP
+
+       # NMAP FIN Stealth
+       iptables "${protocol}" -A FILTER_INVALID_TCP -p tcp --tcp-flags ALL FIN -j DROP
+
+       # SYN/RST
+       iptables "${protocol}" -A FILTER_INVALID_TCP -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
 
-       iptables_chain_create "${protocol}" BADTCP_LOG
-       iptables "${protocol}" -A BADTCP_LOG -p tcp -j "$(iptables_LOG "Illegal TCP state: ")"
-       iptables "${protocol}" -A BADTCP_LOG -j DROP
+       # SYN/FIN
+       iptables "${protocol}" -A FILTER_INVALID_TCP -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
 
-       iptables_chain_create "${protocol}" BADTCP
-       iptables "${protocol}" -A BADTCP -p tcp --tcp-flags ALL NONE        -j BADTCP_LOG
-       iptables "${protocol}" -A BADTCP -p tcp --tcp-flags SYN,FIN SYN,FIN -j BADTCP_LOG
-       iptables "${protocol}" -A BADTCP -p tcp --tcp-flags SYN,RST SYN,RST -j BADTCP_LOG
-       iptables "${protocol}" -A BADTCP -p tcp --tcp-flags FIN,RST FIN,RST -j BADTCP_LOG
-       iptables "${protocol}" -A BADTCP -p tcp --tcp-flags ACK,FIN FIN     -j BADTCP_LOG
-       iptables "${protocol}" -A BADTCP -p tcp --tcp-flags ACK,PSH PSH     -j BADTCP_LOG
-       iptables "${protocol}" -A BADTCP -p tcp --tcp-flags ACK,URG URG     -j BADTCP_LOG
+       # Null scan
+       iptables "${protocol}" -A FILTER_INVALID_TCP -p tcp --tcp-flags ALL NONE -j DROP
 
-       iptables "${protocol}" -A INPUT   -p tcp -j BADTCP
-       iptables "${protocol}" -A OUTPUT  -p tcp -j BADTCP
-       iptables "${protocol}" -A FORWARD -p tcp -j BADTCP
+
+       # Log packets with bad flags
+
+       if enabled FIREWALL_LOG_BAD_TCP_FLAGS; then
+               log INFO "Logging of packets with bad TCP flags enabled"
+
+               # Option 64
+               iptables "${protocol}" -A FILTER_INVALID_TCP -p tcp --tcp-option 64 \
+                       "${log_limit}" -j "$(iptables_LOG "Bad TCP flag(64)")"
+
+               # Option 128
+               iptables "${protocol}" -A FILTER_INVALID_TCP -p tcp --tcp-option 128 \
+                       "${log_limit}" -j "$(iptables_LOG "Bad TCP flag(128)")"
+       else
+               log INFO "Logging of packets with bad TCP flags disabled"
+       fi
+
+       # Drop packets with bad flags
+
+       iptables "${protocol}" -A FILTER_INVALID_TCP -p tcp --tcp-option 64 -j DROP
+       iptables "${protocol}" -A FILTER_INVALID_TCP -p tcp --tcp-option 128 -j DROP
+
+
+       # Log invalid packets
+
+       if enabled FIREWALL_LOG_INVALID_TCP; then
+               log INFO "Logging of INVALID TCP packets enabled"
+
+               iptables "${protocol}" -A FILTER_INVALID_TCP -p tcp -m conntrack --ctstate INVALID \
+                       "${log_limit}" -j "$(iptables_LOG "INVALID TCP")"
+       else
+               log INFO "Logging of INVALID TCP packets disabled"
+       fi
+
+       if enabled FIREWALL_LOG_INVALID_UDP; then
+               log INFO "Logging of INVALID UDP packets enabled"
+
+               iptables "${protocol}" -A FILTER_INVALID_UDP -p udp -m conntrack --ctstate INVALID \
+                       "${log_limit}" -j "$(iptables_LOG "INVALID UDP")"
+       else
+               log INFO "Logging of INVALID UDP packets disabled"
+       fi
+
+       if enabled FIREWALL_LOG_INVALID_ICMP; then
+               log INFO "Logging of INVALID ICMP packets enabled"
+
+               iptables "${protocol}" -A FILTER_INVALID_ICMP -p icmp -m conntrack --ctstate INVALID \
+                       "${log_limit}" -j "$(iptables_LOG "INVALID ICMP")"
+       else
+               log INFO "Logging of INVALID ICMP packets disabled"
+       fi
+
+       # Drop all INVALID packets
+       iptables "${protocol}" -A FILTER_INVALID -m conntrack --ctstate INVALID -j DROP
 }
 
 function firewall_tcp_clamp_mss() {
@@ -251,8 +500,86 @@ function firewall_localhost_create_chains() {
        log DEBUG "Creating firewall chains for localhost..."
 
        # Accept everything on lo
-       iptables "${protocol}" -A INPUT  -i lo -m conntrack --ctstate NEW -j ACCEPT
-       iptables "${protocol}" -A OUTPUT -o lo -m conntrack --ctstate NEW -j ACCEPT
+       iptables "${protocol}" -A INPUT  -i lo -j ACCEPT
+       iptables "${protocol}" -A OUTPUT -o lo -j ACCEPT
+}
+
+function firewall_filter_rh0_headers() {
+       local protocol="${1}"
+       assert isset protocol
+
+       # Only IPv6.
+       [ "${protocol}" = "ipv6" ] || return ${EXIT_OK}
+
+       # Filter all packets that have RH0 headers
+       # http://www.ietf.org/rfc/rfc5095.txt
+       iptables_chain_create "${protocol}" FILTER_RH0
+       iptables "${protocol}" -A FILTER_RH0 -m rt --rt-type 0 -j DROP
+
+       iptables "${protocol}" -A INPUT   -j FILTER_RH0
+       iptables "${protocol}" -A FORWARD -j FILTER_RH0
+       iptables "${protocol}" -A OUTPUT  -j FILTER_RH0
+}
+
+function firewall_filter_icmp() {
+       local protocol="${1}"
+       assert isset protocol
+
+       # Only IPv6.
+       [ "${protocol}" = "ipv6" ] || return ${EXIT_OK}
+
+       local chain="FILTER_ICMPV6"
+
+       # Create an extra chain for handling ICMP packets.
+       iptables_chain_create "${protocol}" "${chain}_COMMON"
+
+       local suffix
+       for suffix in INC FWD OUT; do
+               iptables_chain_create "${protocol}" "${chain}_${suffix}"
+               iptables "${protocol}" -A "${chain}_${suffix}" -j "${chain}_COMMON"
+       done
+       iptables "${protocol}" -A INPUT   -p icmpv6 -j "${chain}_INC"
+       iptables "${protocol}" -A FORWARD -p icmpv6 -j "${chain}_FWD"
+       iptables "${protocol}" -A OUTPUT  -p icmpv6 -j "${chain}_OUT"
+
+       # Packets that must always pass the firewall.
+       # Type 4: Parameter Problem
+       local type
+       for type in ttl-zero-during-reassembly bad-header; do
+               iptables "${protocol}" -A "${chain}_COMMON" \
+                       -p icmpv6 --icmpv6-type "${type}" -j ACCEPT
+       done
+
+       # Packets that are accepted if they belong to an existing connection.
+       for type in echo-reply destination-unreachable packet-too-big \
+                       unknown-header-type unknown-option; do
+               iptables "${protocol}" -A "${chain}_COMMON" \
+                       -m conntrack --ctstate ESTABLISHED,RELATED \
+                       -p icmpv6 --icmpv6-type "${type}" -j ACCEPT
+       done
+
+       # Packets that are always discarded.
+       # Type 100, 101, 200, 201: Private Experimentation
+       for type in 100 101 200 201; do
+               iptables "${protocol}" -A "${chain}_COMMON" \
+                       -p icmpv6 --icmpv6-type "${type}" -j DROP
+       done
+
+       # Discard packets from local networks with hop limit smaller than $hoplimit.
+       # Type 148: Path solicitation
+       # Type 149: Path advertisement
+       local hoplimit=255
+       for type in {router,neighbour}-{advertisement,solicitation} 148 149; do
+               iptables "${protocol}" -A "${chain}_INC" \
+                       -p icmpv6 --icmpv6-type "${type}" \
+                       -m hl --hl-lt "${hoplimit}" -j DROP
+       done
+
+       # The firewall is always allowed to send ICMP echo requests.
+       iptables "${protocol}" -A "${chain}_OUT" \
+               -p icmpv6 --icmpv6-type echo-request -j ACCEPT
+
+       return ${EXIT_OK}
 }
 
 function firewall_zone_create_chains() {
index 792f2ba8e30e8df47f5dc19846acb477ad534d2a..6ee527d5a7c316c38b9ba5cdf26c7f88be7059f5 100644 (file)
 #                                                                             #
 ###############################################################################
 
+HOOK_COMMANDS_CONFIG="hook_create hook_down hook_status hook_up"
+
+HOOK_COMMANDS_PORT="hook_create hook_down hook_hotplug hook_hotplug_rename \
+       hook_info hook_status hook_up"
+
+HOOK_COMMANDS_ZONE="hook_create hook_discover hook_down hook_edit hook_help \
+       hook_info hook_remove hook_status hook_up \
+       \
+       hook_config_create hook_config_edit hook_config_remove hook_config_show \
+       \
+       hook_port hook_port_add hook_port_edit hook_port_remove hook_port_show \
+       hook_port_status hook_port_up hook_port_down \
+       \
+       hook_ppp_ip_pre_up hook_ppp_ipv4_down hook_ppp_ipv4_up \
+       hook_ipv6_down hook_ipv6_up hook_ppp_write_config"
+
 function hook_dir() {
        local type=${1}
 
@@ -44,16 +60,37 @@ function hook_exists() {
 }
 
 function hook_exec() {
-       local type=${1}
-       local hook=${2}
-       local cmd=${3}
-       shift 3
-
+       local type="${1}"
        assert isset type
+
+       local hook="${2}"
        assert isset hook
+
+       local cmd="${3}"
        assert isset cmd
 
        assert hook_exists "${type}" "${hook}"
+       shift 3
+
+       # Complete the hook command by prepending "hook_"
+       local hook_cmd="hook_${cmd}"
+
+       # Check if the hook action is valid.
+       local valid_commands
+       case "${type}" in
+               "config")
+                       valid_commands="${HOOK_COMMANDS_CONFIG}"
+                       ;;
+               "port")
+                       valid_commands="${HOOK_COMMANDS_PORT}"
+                       ;;
+               "zone")
+                       valid_commands="${HOOK_COMMANDS_ZONE}"
+                       ;;
+       esac
+       isset valid_commands && assert list_match "${hook_cmd}" ${valid_commands}
+
+       local hook_path="$(hook_dir ${type})/${hook}"
 
        # For performance reasons, all hooks are executed
        # in a subshell and so will inherit the currently
@@ -63,20 +100,26 @@ function hook_exec() {
                HOOK=$(basename ${hook})
 
                # Source the code of the hook.
-               source "$(hook_dir ${type})/${hook}"
+               source "${hook_path}"
 
                # Make sure HOOK is still properly set.
                assert isset HOOK
 
                # Execute the requested command.
-               _${cmd} $@
+               cmd "${hook_cmd}" "$@"
        )
        local ret=$?
 
-       if [ ${ret} -eq ${EXIT_ERROR_ASSERT} ]; then
-               log ERROR "Hook exited with an assertion error."
-               exit ${ret}
-       fi
+       case "${ret}" in
+               ${EXIT_COMMAND_NOT_FOUND})
+                       log ERROR "Hook command not implemented: ${hook_command} ($@)"
+                       exit ${EXIT_COMMAND_NOT_FOUND}
+                       ;;
+               ${EXIT_ERROR_ASSERT})
+                       log ERROR "Hook exited with an assertion error."
+                       exit ${EXIT_ERROR_ASSERT}
+                       ;;
+       esac
 
        return ${ret}
 }
index 3e1b929397b895d00dd8d3033a8099507e39c491..fe5197850ab46b755e708cac7ca65d05bcf9b2eb 100644 (file)
@@ -45,6 +45,18 @@ function iptables() {
 
                                assert isoneof table ${IPTABLES_TABLES}
                                ;;
+
+                       # Automatically convert ICMP to ICMPv6 for IPv6
+                       --protocol|-p)
+                               local proto="${2}"
+
+                               if [ "${protocol}" = "ipv6" -a "${proto}" = "icmp" ]; then
+                                       proto="icmpv6"
+                               fi
+
+                               list_append args "${1} ${proto}"
+                               shift 2
+                               ;;
                        *)
                                list_append args "${1}"
 
@@ -380,9 +392,25 @@ function iptables_dump() {
 }
 
 function iptables_LOG() {
-       local prefix=${1}
+       local prefix="${1}"
        local ret
 
+       # Automatically append a colon and whitespace.
+       case "${prefix}" in
+               # Everything is fine.
+               "*: ") ;;
+
+               # Ends with colon, add whitespace only.
+               "*:")
+                       prefix="${prefix} "
+                       ;;
+
+               # Append both.
+               *)
+                       prefix="${prefix}: "
+                       ;;
+       esac
+
        case "${FIREWALL_LOG_METHOD}" in
                nflog)
                        ret="NFLOG --nflog-threshold ${FIREWALL_NFLOG_THRESHOLD}"
index ba97aaa1d652cdb64b8bdcd143321ba51909d9fb..d7a6b85a71184093b8989de06670613ce0ac7046 100644 (file)
@@ -362,3 +362,15 @@ function ipv4_in_subnet() {
 
        return ${EXIT_FALSE}
 }
+
+function ipv4_ttl_valid() {
+       local ttl="${1}"
+
+       isinteger ttl || return ${EXIT_FALSE}
+
+       # Must be between 10 and 255.
+       [ "${ttl}" -lt  10 ] && return ${EXIT_FALSE}
+       [ "${ttl}" -gt 255 ] && return ${EXIT_FALSE}
+
+       return ${EXIT_TRUE}
+}
index 621af6349c95936afd75370ba9b9b58921c648b1..2667ae0b0036d912fc306bd224295c585b276b28 100644 (file)
 
 IP_SUPPORTED_PROTOCOLS="${IP_SUPPORTED_PROTOCOLS} ipv6"
 
-function ipv6_init() {
-       log INFO "Initializing IPv6 networking."
-
-       # Enable forwarding on all devices
-       #ipv6_device_forwarding_disable all
-       #ipv6_device_forwarding_disable default
-
-       # Disable autoconfiguration on all devices per default
-       #ipv6_device_autoconf_disable all
-       #ipv6_device_autoconf_disable default
-
-       # XXX do we need this?
-       #local device
-       #for device in $(devices_get_all); do
-       #       ipv6_device_forwarding_disable ${device}
-       #       ipv6_device_autoconf_disable ${device}
-       #done
-}
-
-init_register ipv6_init
-
 function ipv6_device_autoconf_enable() {
-       local device=${1}
+       local device="${1}"
+       assert device_exists "${device}"
 
-       assert isset device
-
-       # Allow setting default and all settings
-       if ! isoneof device all default; then
-               assert device_exists ${device}
-       fi
-
-       local val
-       for val in accept_ra accept_redirects; do
-               echo 1 > /proc/sys/net/ipv6/conf/${device}/${val}
-       done
+       sysctl_set "net.ipv6.conf.${device}.accept_ra" 1
+       sysctl_set "net.ipv6.conf.${device}.autoconf" 1
 }
 
 function ipv6_device_autoconf_disable() {
-       local device=${1}
-
-       assert isset device
-
-       # Allow setting default and all settings
-       if ! isoneof device all default; then
-               assert device_exists ${device}
-       fi
-
-       local val
-       for val in accept_ra accept_redirects; do
-               echo 0 > /proc/sys/net/ipv6/conf/${device}/${val}
-       done
-}
-
-function ipv6_device_forwarding_enable() {
-       local device=${1}
-
-       assert isset device
-
-       # Allow setting default and all settings
-       if ! isoneof device all default; then
-               assert device_exists ${device}
-       fi
+       local device="${1}"
+       assert device_exists "${device}"
 
-       echo 1 > /proc/sys/net/ipv6/conf/${device}/forwarding
-}
-
-function ipv6_device_forwarding_disable() {
-       local device=${1}
-
-       assert isset device
-
-       # Allow setting default and all settings
-       if ! isoneof device all default; then
-               assert device_exists ${device}
-       fi
-
-       echo 0 > /proc/sys/net/ipv6/conf/${device}/forwarding
+       sysctl_set "net.ipv6.conf.${device}.accept_ra" 0
+       sysctl_set "net.ipv6.conf.${device}.autoconf" 0
 }
 
 # Enable IPv6 RFC3041 privacy extensions if desired
 function ipv6_device_privacy_extensions_enable() {
-       local device=${1}
-       local type=${2}
-
-       assert isset device
-       assert device_exists ${device}
-
-       # Default value is rfc3041
-       if [ -z "${type}" ]; then
-               type="rfc3041"
-       fi
+       local device="${1}"
+       assert device_exists "${device}"
 
-       assert isset type
-
-       case "${type}" in
-               rfc3041)
-                       echo 2 > /proc/sys/net/ipv6/conf/${device}/use_tempaddr
-                       ;;
-               *)
-                       error_log "Given type '${type}' is not supported."
-                       return ${EXIT_ERROR}
-                       ;;
-       esac
-
-       return ${EXIT_OK}
+       sysctl_set "net.ipv6.conf.${device}.use_tempaddr" 2
 }
 
 function ipv6_device_privacy_extensions_disable() {
-       local device=${1}
-
-       assert isset device
-       assert device_exists ${device}
+       local device="${1}"
+       assert device_exists "${device}"
 
-       echo 0 > /proc/sys/net/ipv6/conf/${device}/use_tempaddr
+       sysctl_set "net.ipv6.conf.${device}.use_tempaddr" 0
 }
 
 function ipv6_is_valid() {
index 1b7d9a30e223a394fd2d7b6591294e6aa289c593..05ebed56e0738035990b025b7e0e07fe788c9084 100644 (file)
@@ -87,7 +87,7 @@ function ppp_common_ip_pre_up() {
        return ${EXIT_OK}
 }
 
-function ppp_common_ip_up() {
+function ppp_common_ipv4_up() {
        local zone=${1}
        shift
 
@@ -103,7 +103,7 @@ function ppp_common_ip_up() {
        return ${EXIT_OK}
 }
 
-function ppp_common_ip_down() {
+function ppp_common_ipv4_down() {
        local zone=${1}
        shift
 
diff --git a/functions.sysctl b/functions.sysctl
new file mode 100644 (file)
index 0000000..79b9ce9
--- /dev/null
@@ -0,0 +1,94 @@
+#!/bin/bash
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2013  IPFire Network Development Team                         #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+SYSCTL_PATH="/proc/sys"
+
+function sysctl_key_to_path() {
+       local key="${1}"
+       assert isset key
+
+       print "${SYSCTL_PATH}/${key//.//}"
+
+       return ${EXIT_OK}
+}
+
+function sysctl_key_exists() {
+       local key="${1}"
+       assert isset key
+
+       local path="$(sysctl_key_to_path "${key}")"
+
+       [ -e "${path}" ] && return ${EXIT_OK}
+       return ${EXIT_ERROR}
+}
+
+function sysctl_get() {
+       local key="${1}"
+       assert isset key
+
+       fread "$(sysctl_key_to_path "${key}")" || return $?
+       return ${EXIT_OK}
+}
+
+function sysctl_set() {
+       local key="${1}"
+       assert isset key
+
+       local value="${2}"
+
+       fwrite "$(sysctl_key_to_path "${key}")" "${value}" || return $?
+       return ${EXIT_OK}
+}
+
+function sysctl_set_bool() {
+       local key="${1}"
+
+       local value="${2}"
+       if enabled value; then
+               value="1"
+       else
+               value="0"
+       fi
+
+       sysctl_set "${key}" "${value}"
+}
+
+function sysctl_set_recursively() {
+       local basekey="${1}"
+       assert isset basekey
+
+       local subkey="${2}"
+       assert isset subkey
+
+       local value="${3}"
+
+       local basepath="$(sysctl_key_to_path "${basekey}")"
+       local subpath="/${subkey//\.//}"
+
+       local path
+       for path in $(find "${basepath}" -type f); do
+               [[ ${path} =~ ${subpath}$ ]] || continue
+
+               fwrite "${path}" "${value}"
+       done
+
+       return ${EXIT_OK}
+}
index 1fb1951529c5eb22c306aac60b264ed52d940afa..b975b6a0b926b25a8b58663df99cfeddcd42106b 100644 (file)
@@ -340,6 +340,10 @@ function cmd_exec() {
        exit ${EXIT_ERROR}
 }
 
+function cmd_not_implemented() {
+       assert false "not implemented"
+}
+
 function seq() {
        if [ $# -eq 2 ]; then
                eval echo {${1}..${2}}
index b07c99c5b4da1830906fa0cddc4417951a47c635..44e3cf18aab1995a88c45bd3d48b128bac320c76 100644 (file)
@@ -25,7 +25,7 @@ INFO_SETTINGS="HOOK PORT_PARENTS PORT_CHILDREN"
 # into the system and got its correct name.
 # The function is intended to create child ports and things
 # like that.
-function _hotplug() {
+function hook_hotplug() {
        exit ${EXIT_OK}
 }
 
@@ -34,20 +34,18 @@ function _hotplug() {
 # The first argument is the port which should be tested
 # against the second argument which is the device that
 # has been plugged in.
-function _hotplug_rename() {
+function hook_hotplug_rename() {
        exit ${EXIT_FALSE}
 }
 
-function _info() {
-       local port=${1}
-       shift
-
+function hook_info() {
+       local port="${1}"
        assert isset port
+       shift
 
-       config_read $(port_file ${port})
+       config_read "$(port_file ${port})"
 
-       local key
-       local val
+       local key val
        for key in PORT_PARENTS PORT_CHILDREN; do
                val="${key}_VAR"
                val=${!val}
@@ -61,10 +59,10 @@ function _info() {
        exit ${ERROR_OK}
 }
 
-function _status() {
-       local port=${1}
+function hook_status() {
+       local port="${1}"
        assert isset port
 
-       cli_device_headline ${port} --long
+       cli_device_headline "${port}" --long
        exit ${EXIT_OK}
 }
index 8233f61241fe092a97e2a897d5c37f3183cb2fa5..74cec328cd0002a39800e6ddb42af1267169e284 100644 (file)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
 #                                                                             #
 ###############################################################################
-#
-# Notes:
-#   - All functions in this scope must start with an underline (_) to not
-#     conflict with any functions that were defined somewhere else.
-#
-
-# _notimplemented
-#   Returns a soft error if a function was not implemented, yet.
-#
-function _notimplemented() {
-       warning "'$@' was not implemented."
-       exit ${EXIT_CONF_ERROR}
-}
 
-function _info() {
+function hook_info() {
        echo "HOOK=\"${HOOK}\""
 }
 
-function _create() {
-       local zone=${1}
+function hook_create() {
+       local zone="${1}"
+       assert isset zone
        shift
 
        config_read $(zone_dir ${zone})/settings
 
-       _parse_cmdline $@
+       hook_parse_cmdline $@
 
        config_write $(zone_dir ${zone})/settings ${HOOK_SETTINGS}
 
        exit ${EXIT_OK}
 }
 
-function _edit() {
-       _create $@
+function hook_edit() {
+       hook_create $@
 }
 
-function _rem() {
-       _notimplemented _rem
+function hook_remove() {
+       cmd_not_implemented
 }
 
-function _status() {
-       local zone=${1}
+function hook_status() {
+       local zone="${1}"
+       assert isset zone
 
        if device_is_up ${zone}; then
                exit ${STATUS_UP}
@@ -67,21 +56,21 @@ function _status() {
        exit ${STATUS_DOWN}
 }
 
-function _up() {
-       _notimplemented _up
+function hook_up() {
+       cmd_not_implemented
 }
 
-function _down() {
-       _notimplemented _down
+function hook_down() {
+       cmd_not_implemented
 }
 
-function _discover() {
+function hook_discover() {
        # This hook does not support a discovery
        exit ${DISCOVER_NOT_SUPPORTED}
 }
 
 # The default help function.
-function _help() {
+function hook_help() {
        # If no man page has been configured, we print an error message.
        if [ -z "${HOOK_MANPAGE}" ]; then
                error "There is no help available for hook '${HOOK}'. Exiting."
@@ -96,16 +85,17 @@ function _parse_cmdline() {
        return ${EXIT_OK}
 }
 
-function _port() {
-       local zone=${1}
-       local action=${2}
+function hook_port() {
+       local zone="${1}"
+       assert isset zone
+
+       local action="${2}"
        shift 2
 
        local ret
-
        case "${action}" in
                add|create|edit|rem|show)
-                       _port_${action} ${zone} $@
+                       hook_port_${action} "${zone}" $@
                        ret=$?
                        ;;
                *)
@@ -117,209 +107,213 @@ function _port() {
        exit ${ret}
 }
 
-function _port_add() {
-       _port_cmd add $@
+function hook_port_add() {
+       hook_port_cmd add "$@"
 }
 
-function _port_edit() {
-       _port_cmd edit $@
+function hook_port_edit() {
+       _port_cmd edit "$@"
 }
 
-function _port_rem() {
-       _port_cmd rem $@
+function hook_port_rem() {
+       hook_port_cmd remove "$@"
 }
 
-function _port_show() {
-       _notimplemented _port_show
+function hook_port_show() {
+       cmd_not_implemented
 }
 
-function _port_status() {
-       _port_cmd status $@
+function hook_port_status() {
+       hook_port_cmd status "$@"
 }
 
-function _port_cmd() {
-       local cmd=${1}
-       local zone=${2}
-       local port=${3}
-       shift 3
-
+function hook_port_cmd() {
+       local cmd="${1}"
        assert isset cmd
+
+       local zone="${2}"
        assert isset zone
+
+       local port="${3}"
        assert isset port
 
-       local hook_zone=$(zone_get_hook ${zone})
-       local hook_port=$(port_get_hook ${port})
+       shift 3
 
+       local hook_zone="$(zone_get_hook ${zone})"
        assert isset hook_zone
+
+       local hook_port="$(port_get_hook ${port})"
        assert isset hook_port
 
-       if ! listmatch ${hook_port} $(zone_get_supported_port_hooks ${zone}); then
-               error_log "Zone '${zone}' does not support port of type '${hook_port}'."
+       if ! listmatch "${hook_port}" $(zone_get_supported_port_hooks ${zone}); then
+               log ERROR "Zone '${zone}' does not support port of type '${hook_port}'."
                exit ${EXIT_ERROR}
        fi
 
-       hook_zone_port_exec ${hook_zone} ${hook_port} ${cmd} ${zone} ${port} $@
-
+       hook_zone_port_exec "${hook_zone}" "${hook_port}" "${cmd}" "${zone}" "${port}" "$@"
        exit $?
 }
 
-function _port_up() {
-       _port_cmd up $@
+function hook_port_up() {
+       hook_port_cmd up "$@"
 }
 
-function _port_down() {
-       _port_cmd down $@
+function hook_port_down() {
+       hook_port_cmd down "$@"
 }
 
-function _config() {
-       local zone=${1}
-       local action=${2}
+function hook_config() {
+       local zone="${1}"
+       assert isset zone
+
+       local action="${2}"
+       assert isset action
        shift 2
 
        local ret
-
        case "${action}" in
                create|edit|rem|show)
-                       _config_${action} ${zone} $@
-                       ret=$?
+                       hook_config_${action} "${zone}" "$@"
+                       exit $?
                        ;;
                *)
                        error "Unrecognized argument: '${action}'"
                        exit ${EXIT_ERROR}
                        ;;
        esac
-
-       exit ${ret}
 }
 
-# This function is not a public one
-function __configcmd() {
-       local cmd=${1}
-       local zone=${2}
-       local hook_config=${3}
-       shift 3
+function hook_config_cmd() {
+       local cmd="${1}"
+       assert isset cmd
 
-       local hook_zone=$(zone_get_hook ${zone})
+       local zone="${2}"
+       assert isset zone
 
-       if ! hook_zone_exists ${hook_zone}; then
-               error "Hook '${hook}' does not exist."
+       local hook_config="${3}"
+       assert isset hook_config
+
+       shift 3
+
+       local hook_zone="$(zone_get_hook "${zone}")"
+       if ! hook_zone_exists "${hook_zone}"; then
+               log ERROR "Hook '${hook}' does not exist."
                exit ${EXIT_ERROR}
        fi
 
-       if ! hook_config_exists ${hook_zone} ${hook_config}; then
-               error "Hook '${hook_config}' is not supported for zone '${zone}'."
+       if ! hook_config_exists "${hook_zone}" "${hook_config}"; then
+               log ERROR "Hook '${hook_config}' is not supported for zone '${zone}'."
                exit ${EXIT_ERROR}
        fi
 
-       hook_zone_config_exec ${hook_zone} ${hook_config} ${cmd} ${zone} $@
+       hook_zone_config_exec "${hook_zone}" "${hook_config}" "${cmd}" "${zone}" "$@"
 }
 
-function _config_create() {
-       local zone=${1}
-       local hook_config=${2}
-       shift 2
-
+function hook_config_create() {
+       local zone="${1}"
        assert isset zone
+
+       local hook_config="${2}"
        assert isset hook_config
-       assert zone_exists ${zone}
 
-       if ! listmatch ${hook_config} $(zone_get_supported_config_hooks ${zone}); then
-               error_log "Zone '${zone}' does not support configuration of type '${hook_config}'."
+       shift 2
+
+       if ! listmatch "${hook_config}" $(zone_get_supported_config_hooks ${zone}); then
+               log ERROR "Zone '${zone}' does not support configuration of type '${hook_config}'."
                exit ${EXIT_ERROR}
        fi
 
-       local hook_zone=$(zone_get_hook ${zone})
+       local hook_zone="$(zone_get_hook "${zone}")"
        assert isset hook_zone
 
-       hook_zone_config_exec ${hook_zone} ${hook_config} create ${zone} $@
-
+       hook_zone_config_exec "${hook_zone}" "${hook_config}" create "${zone}" "$@"
        exit $?
 }
 
-function _config_edit() {
-       __configcmd edit $@
+function hook_config_edit() {
+       hook_config_cmd edit "$@"
 }
 
-function _config_rem() {
-       _notimplemented _config_rem
+function hook_config_remove() {
+       cmd_not_implemented
 }
 
-function _config_show() {
-       _notimplemented _config_show
+function hook_config_show() {
+       cmd_not_implemented
 }
 
-function _ppp-write-config() {
-       _notimplemented _ppp_write_config
+function hook_ppp_write_config() {
+       cmd_not_implemented
 
        # Arguments: <zone> <filename>
 }
 
-function _ppp-ip-pre-up() {
-       local zone=${1}
+function hook_ppp_ip_pre_up() {
+       local zone="${1}"
+       assert isset zone
        shift
 
-       if ! zone_exists ${zone}; then
-               error "Zone '${zone}' does not exist."
+       if ! zone_exists "${zone}"; then
+               log ERROR "Zone '${zone}' does not exist."
                exit ${EXIT_ERROR}
        fi
 
-       ppp_common_ip_pre_up ${zone} $@
-
+       ppp_common_ip_pre_up "${zone}" "$@"
        exit $?
 }
 
-function _ppp-ip-up() {
-       local zone=${1}
+function hook_ppp_ipv4_up() {
+       local zone="${1}"
+       assert isset zone
        shift
 
-       if ! zone_exists ${zone}; then
-               error "Zone '${zone}' does not exist."
+       if ! zone_exists "${zone}"; then
+               log ERROR "Zone '${zone}' does not exist."
                exit ${EXIT_ERROR}
        fi
 
-       ppp_common_ip_up ${zone} $@
-
+       ppp_common_ipv4_up "${zone}" "$@"
        exit $?
 }
 
-function _ppp-ip-down() {
-       local zone=${1}
+function hook_ppp_ipv4_down() {
+       local zone="${1}"
+       assert isset zone
        shift
 
-       if ! zone_exists ${zone}; then
-               error "Zone '${zone}' does not exist."
+       if ! zone_exists "${zone}"; then
+               log ERROR "Zone '${zone}' does not exist."
                exit ${EXIT_ERROR}
        fi
 
-       ppp_common_ip_down ${zone} $@
-
+       ppp_common_ipv4_down "${zone}" "$@"
        exit $?
 }
 
-function _ppp-ipv6-up() {
-       local zone=${1}
+function hook_ppp_ipv6_up() {
+       local zone="${1}"
+       assert isset zone
        shift
 
-       if ! zone_exists ${zone}; then
+       if ! zone_exists "${zone}"; then
                error "Zone '${zone}' does not exist."
                exit ${EXIT_ERROR}
        fi
 
-       ppp_common_ipv6_up ${zone} $@
-
+       ppp_common_ipv6_up "${zone}" "$@"
        exit $?
 }
 
-function _ppp-ipv6-down() {
-       local zone=${1}
+function hook_ppp_ipv6_down() {
+       local zone="${1}"
+       assert isset zone
        shift
 
-       if ! zone_exists ${zone}; then
+       if ! zone_exists "${zone}"; then
                error "Zone '${zone}' does not exist."
                exit ${EXIT_ERROR}
        fi
 
-       ppp_common_ipv6_down ${zone} $@
-
+       ppp_common_ipv6_down "${zone}" "$@"
        exit $?
 }
diff --git a/helpers/firewall-kernel-init b/helpers/firewall-kernel-init
new file mode 100755 (executable)
index 0000000..dba615d
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/bash
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2012  IPFire Network Development Team                         #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+. /usr/lib/network/functions
+
+# Read firewall configuration.
+firewall_config_read
+
+# Initialize kernel parameters for the firewall.
+firewall_kernel_init
+
+exit ${EXIT_OK}
index a2cb151e0a055883a1519b5dd1e3c32dc28fdb7a..76e9250e6b635c5529fc70d01928f365c047cdf4 100755 (executable)
@@ -28,12 +28,12 @@ PORT_CHILDREN_VAR="SLAVES"
 ADDRESS=$(mac_generate)
 SLAVES=
 
-function _check() {
+function hook_check() {
        assert isset ADDRESS
        assert ismac ADDRESS
 }
 
-function _create() {
+function hook_create() {
        while [ $# -gt 0 ]; do
                case "${1}" in
                        --address=*)
@@ -57,7 +57,7 @@ function _create() {
        exit ${EXIT_OK}
 }
 
-function _edit() {
+function hook_edit() {
        local port=${1}
        assert isset port
        shift
@@ -94,7 +94,7 @@ function _edit() {
        exit ${EXIT_OK}
 }
 
-function _up() {
+function hook_up() {
        local port=${1}
        assert isset port
 
@@ -120,7 +120,7 @@ function _up() {
        exit ${EXIT_OK}
 }
 
-function _down() {
+function hook_down() {
        local port=${1}
        assert isset port
 
@@ -134,7 +134,7 @@ function _down() {
        exit ${EXIT_OK}
 }
 
-function _hotplug() {
+function hook_hotplug() {
        local port=${1}
        assert isset port
 
@@ -147,7 +147,7 @@ function _hotplug() {
        exit ${EXIT_OK}
 }
 
-function _status() {
+function hook_status() {
        local port=${1}
        assert isset port
 
index 0d44ba3532a94747c80bf936a1e0b603e01a0513..a9304684e8627e7f50355c5ea97bd0a7329cbe66 100755 (executable)
@@ -33,7 +33,7 @@ SSID=
 # to 1528, that normal ethernet packets with 1500 bytes can pass the network.
 MTU=1528
 
-function _check() {
+function hook_check() {
        assert isset ADDRESS
        assert ismac ADDRESS
        assert isset CHANNEL
@@ -45,7 +45,7 @@ function _check() {
        assert isset SSID
 }
 
-function _create() {
+function hook_create() {
        while [ $# -gt 0 ]; do
                case "${1}" in
                        --address=*)
@@ -85,7 +85,7 @@ function _create() {
        exit ${EXIT_OK}
 }
 
-function _edit() {
+function hook_edit() {
        local port=${1}
        assert isset port
        shift
@@ -118,7 +118,7 @@ function _edit() {
        exit ${EXIT_OK}
 }
 
-function _up() {
+function hook_up() {
        local port=${1}
        assert isset port
 
@@ -155,7 +155,7 @@ function _up() {
        exit ${EXIT_OK}
 }
 
-function _down() {
+function hook_down() {
        local port=${1}
        assert isset port
 
@@ -173,7 +173,7 @@ function _down() {
        exit ${EXIT_OK}
 }
 
-function _hotplug() {
+function hook_hotplug() {
        local port=${1}
        assert isset port
 
@@ -198,7 +198,7 @@ function _hotplug() {
        exit ${EXIT_OK}
 }
 
-function _find_parent() {
+function hook_find_parent() {
        local port=${1}
        assert isset port
 
index 3d8b987e2e8ac0eceff780a00c92d5c7334759b1..355eece1d53ca10bd2d8050f0727ee43b2dbe45f 100755 (executable)
@@ -27,7 +27,7 @@ ADDRESS=$(mac_generate)
 SLAVES=""
 MIIMON=100
 
-function _check() {
+function hook_check() {
        assert isset ADDRESS
        assert ismac ADDRESS
 
@@ -35,11 +35,11 @@ function _check() {
        assert isinteger MIIMON
 }
 
-function _create() {
+function hook_create() {
        _edit $@
 }
 
-function _edit() {
+function hook_edit() {
        local port=${1}
        assert isset port
        shift
@@ -95,7 +95,7 @@ function _edit() {
        exit ${EXIT_OK}
 }
 
-function _up() {
+function hook_up() {
        local device=${1}
        assert isset device
 
@@ -134,7 +134,7 @@ function _up() {
        exit ${EXIT_OK}
 }
 
-function _down() {
+function hook_down() {
        local device=${1}
 
        bonding_remove ${device}
index bfd0e5060ae2028205ab9c8bb9ff1169ba18e0fc..3af50cd070951c36cd032bcdca2cce5b45a9c571 100755 (executable)
 
 HOOK_SETTINGS="HOOK ADDRESS"
 
-function _check() {
+function hook_check() {
        assert ismac ADDRESS
 }
 
-function _create() {
+function hook_create() {
        while [ $# -gt 0 ]; do
                case "${1}" in
                        --address=*)
@@ -55,7 +55,7 @@ function _create() {
        exit ${EXIT_OK}
 }
 
-function _edit() {
+function hook_edit() {
        local port=${1}
        assert isset port
        shift
@@ -79,7 +79,7 @@ function _edit() {
        exit ${EXIT_OK} 
 }
 
-function _up() {
+function hook_up() {
        local port=${1}
        assert isset port
 
@@ -96,7 +96,7 @@ function _up() {
        exit ${EXIT_OK}
 }
 
-function _down() {
+function hook_down() {
        local port=${1}
        assert isset port
 
@@ -113,7 +113,7 @@ function _down() {
        exit ${EXIT_OK}
 }
 
-function _hotplug_rename() {
+function hook_hotplug_rename() {
        local port=${1}
        assert isset port
 
index 327036cad75a63978584fd16729a4c022511a47c..35a90bf9eef0d22bd5bd629b3fe6aa754bdc5a7e 100755 (executable)
@@ -26,7 +26,7 @@
 
 HOOK_SETTINGS="HOOK ADDRESS DEVICE"
 
-function _check() {
+function hook_check() {
        assert ismac DEVICE
 
        if isset ADDRESS; then
@@ -34,7 +34,7 @@ function _check() {
        fi
 }
 
-function _create() {
+function hook_create() {
        local port=${1}
        assert isset port
        shift
@@ -47,7 +47,7 @@ function _create() {
        exit ${EXIT_OK}
 }
 
-function _up() {
+function hook_up() {
        local port=${1}
        assert isset port
 
@@ -65,7 +65,7 @@ function _up() {
        exit ${EXIT_OK}
 }
 
-function _down() {
+function hook_down() {
        local port=${1}
        assert isset port
 
@@ -75,7 +75,7 @@ function _down() {
        exit ${EXIT_OK}
 }
 
-function _hotplug_rename() {
+function hook_hotplug_rename() {
        local port=${1}
        assert isset port
 
index 5770e9db4069f28a162b4e85db9c92096cfcb964..0214465ad9fa42a27509b6e35f6fcd04b2432a00 100755 (executable)
 
 HOOK_SETTINGS="HOOK ADDRESS PARENT"
 
-function _check() {
+function hook_check() {
        assert isset PARENT
        assert ismac ADDRESS
 }
 
-function _create() {
+function hook_create() {
        while [ $# -gt 0 ]; do
                case "${1}" in
                        --parent-device=*)
@@ -58,7 +58,7 @@ function _create() {
        exit ${EXIT_OK}
 }
 
-function _edit() {
+function hook_edit() {
        local port=${1}
        assert isset port
        shift
@@ -82,7 +82,7 @@ function _edit() {
        exit ${EXIT_OK} 
 }
 
-function _up() {
+function hook_up() {
        local port=${1}
        assert isset port
 
@@ -96,7 +96,7 @@ function _up() {
        exit ${EXIT_OK}
 }
 
-function _down() {
+function hook_down() {
        local port=${1}
 
        assert isset port
index 66b98eb3c7a156d3b06226494fcc7136b944b8ad..20550077fc3e8ab188709e855c76061da82149ed 100755 (executable)
@@ -25,7 +25,7 @@ HOOK_SETTINGS="HOOK ADDRESS PARENT_DEVICE TAG"
 
 PORT_PARENTS_VAR="PARENT"
 
-function _check() {
+function hook_check() {
        assert isset PARENT_DEVICE
        assert isinteger TAG
 
@@ -47,7 +47,7 @@ function _check() {
        done
 }
 
-function _create() {
+function hook_create() {
        while [ $# -gt 0 ]; do
                case "${1}" in
                        --parent-device=*)
@@ -73,7 +73,7 @@ function _create() {
        exit ${EXIT_OK}
 }
 
-function _edit() {
+function hook_edit() {
        local port=${1}
        assert isset port
        shift
@@ -97,7 +97,7 @@ function _edit() {
        exit ${EXIT_OK} 
 }
 
-function _up() {
+function hook_up() {
        local port=${1}
        assert isset port
 
@@ -114,7 +114,7 @@ function _up() {
        exit ${EXIT_OK}
 }
 
-function _down() {
+function hook_down() {
        local port=${1}
        assert isset port
 
index 391e682800257520c6b13dba49cc00658abbef67..c6d91da042a75b78e06c4132e17abe72a338947d 100755 (executable)
@@ -33,7 +33,7 @@ KEY=""
 MODE="g"
 SSID=
 
-function _check() {
+function hook_check() {
        assert isset ADDRESS
        assert ismac ADDRESS
        assert isset BROADCAST_SSID
@@ -55,7 +55,7 @@ function _check() {
        fi
 }
 
-function _create() {
+function hook_create() {
        while [ $# -gt 0 ]; do
                case "${1}" in
                        --broadcast-ssid=*)
@@ -104,7 +104,7 @@ function _create() {
        exit ${EXIT_OK}
 }
 
-function _edit() {
+function hook_edit() {
        local port=${1}
        shift
 
@@ -147,7 +147,7 @@ function _edit() {
        exit ${EXIT_OK} 
 }
 
-function _up() {
+function hook_up() {
        local port=${1}
        assert isset port
 
@@ -178,7 +178,7 @@ function _up() {
        exit ${EXIT_OK}
 }
 
-function _down() {
+function hook_down() {
        local port=${1}
        assert isset port
 
@@ -193,7 +193,7 @@ function _down() {
        exit ${EXIT_OK}
 }
 
-function _hotplug() {
+function hook_hotplug() {
        local port=${1}
        assert isset port
 
index 2fbb5bbfc8e942783b8b7501102835c9c0658412..450b7b9399db6d26514d6d497b530a7fe13032d0 100755 (executable)
@@ -44,7 +44,7 @@ TUNNEL_ID=
 USERNAME=
 PASSWORD=
 
-function _check() {
+function hook_check() {
        assert isset SERVER_ADDRESS
        assert isset LOCAL_ADDRESS
        assert isset LOCAL_ADDRESS6
@@ -56,7 +56,7 @@ function _check() {
        fi
 }
 
-function _parse_cmdline() {
+function hook_parse_cmdline() {
        local value
 
        while [ $# -gt 0 ]; do
@@ -97,7 +97,7 @@ function _parse_cmdline() {
        done
 }
 
-function _up() {
+function hook_up() {
        local zone=${1}
        assert isset zone
 
@@ -135,7 +135,7 @@ function _up() {
        exit ${EXIT_OK}
 }
 
-function _down() {
+function hook_down() {
        local zone=${1}
        assert isset zone
 
@@ -150,7 +150,7 @@ function _down() {
        exit ${EXIT_OK}
 }
 
-function _status() {
+function hook_status() {
        local zone=${1}
        assert isset zone
 
index c5fbdd0f5c9e74e93262670d8cc1aea8986744f0..e31f897775180184bc0deedd858bbfc023ff26bb 100755 (executable)
@@ -30,7 +30,7 @@ PROTOCOL="tic"
 TUNNEL_ID=
 REQUIRE_TLS="true"
 
-function _check() {
+function hook_check() {
        assert isset USERNAME
        assert isset PASSWORD
        assert isset SERVER
@@ -45,7 +45,7 @@ function _check() {
        fi
 }
 
-function _parse_cmdline() {
+function hook_parse_cmdline() {
        local value
 
        while [ $# -gt 0 ]; do
@@ -83,7 +83,7 @@ function _parse_cmdline() {
        done
 }
 
-function _up() {
+function hook_up() {
        local zone=${1}
        assert isset zone
 
@@ -93,7 +93,7 @@ function _up() {
        exit ${EXIT_OK}
 }
 
-function _down() {
+function hook_down() {
        local zone=${1}
        assert isset zone
 
@@ -103,7 +103,7 @@ function _down() {
        exit ${EXIT_OK}
 }
 
-function _status() {
+function hook_status() {
        local zone=${1}
        assert isset zone
 
index fabb008e3a157ea98ddcfb7493577542e7f94048..a534871bb3ba26998541fd2ecb46348f47154ce5 100755 (executable)
@@ -36,7 +36,7 @@ STP_HELLO=2
 STP_MAXAGE=20
 STP_PRIORITY=512
 
-function _check() {
+function hook_check() {
        assert ismac MAC
        assert isbool STP
        assert isoneof STP_MODE stp rstp
@@ -46,7 +46,7 @@ function _check() {
        assert isinteger MTU
 }
 
-function _parse_cmdline() {
+function hook_parse_cmdline() {
        while [ $# -gt 0 ]; do
                case "${1}" in
                        --stp=*)
@@ -78,7 +78,7 @@ function _parse_cmdline() {
        done
 }
 
-function _up() {
+function hook_up() {
        local zone=${1}
        assert isset zone
 
@@ -131,7 +131,7 @@ function _up() {
        exit ${EXIT_OK}
 }
 
-function _down() {
+function hook_down() {
        local zone=${1}
        assert isset zone
 
@@ -152,7 +152,7 @@ function _down() {
        exit ${EXIT_OK}
 }
 
-function _status() {
+function hook_status() {
        local zone=${1}
        assert isset zone
 
index 63f99dc0200fb254d9d6a46ebc6d8d8ce143964f..783c122699ded9d2cefd83e552f8db1f23319be7 100755 (executable)
@@ -26,12 +26,12 @@ HOOK_SETTINGS="HOOK DELAY"
 # Default settings.
 DELAY=0
 
-function _check() {
+function hook_check() {
        assert isset DELAY
        assert isinteger DELAY
 }
 
-function _create() {
+function hook_create() {
        local zone=${1}
        shift
 
@@ -49,7 +49,7 @@ function _create() {
        exit ${EXIT_OK}
 }
 
-function _up() {
+function hook_up() {
        local zone=${1}
        local config=${2}
        shift 2
@@ -65,7 +65,7 @@ function _up() {
        exit ${EXIT_OK}
 }
 
-function _down() {
+function hook_down() {
        local zone=${1}
        local config=${2}
        shift 2
@@ -81,7 +81,7 @@ function _down() {
        exit ${EXIT_OK}
 }
 
-function _status() {
+function hook_status() {
        local zone=${1}
        local config=${2}
        shift 2
index ba866ca6e5b31344cea3fcc083cbcdb14b28bb3a..f56a5551352ed2c15073c4a7df643c76f34aff7d 100755 (executable)
@@ -23,7 +23,7 @@
 
 HOOK_SETTINGS="HOOK ADDRESS PREFIX GATEWAY"
 
-function _check() {
+function hook_check() {
        assert isset ADDRESS
        assert isinteger PREFIX
 
@@ -33,7 +33,7 @@ function _check() {
        fi
 }
 
-function _create() {
+function hook_create() {
        local zone=${1}
        shift
 
@@ -65,7 +65,7 @@ function _create() {
        exit ${EXIT_OK}
 }
 
-function _up() {
+function hook_up() {
        local zone=${1}
        local config=${2}
        shift 2
@@ -91,7 +91,7 @@ function _up() {
        exit ${EXIT_OK}
 }
 
-function _down() {
+function hook_down() {
        local zone=${1}
        local config=${2}
        shift 2
@@ -111,7 +111,7 @@ function _down() {
        exit ${EXIT_OK}
 }
 
-function _status() {
+function hook_status() {
        local zone=${1}
        local config=${2}
        shift 2
index 57dfdefbe8bff54e5d313419c1e1c5fd432cd4e4..fb5513e0fbf967b8c9bebdb74a68711d34fbac41 100755 (executable)
@@ -23,7 +23,7 @@
 
 HOOK_SETTINGS="HOOK ADDRESS PREFIX GATEWAY"
 
-function _check() {
+function hook_check() {
        assert isset ADDRESS
        assert isinteger PREFIX
 
@@ -33,7 +33,7 @@ function _check() {
        fi
 }
 
-function _create() {
+function hook_create() {
        local zone=${1}
        shift
 
@@ -64,7 +64,7 @@ function _create() {
        exit ${EXIT_OK}
 }
 
-function _up() {
+function hook_up() {
        local zone=${1}
        local config=${2}
        shift 2
@@ -86,7 +86,7 @@ function _up() {
        exit ${EXIT_OK}
 }
 
-function _down() {
+function hook_down() {
        local zone=${1}
        local config=${2}
        shift 2
@@ -109,7 +109,7 @@ function _down() {
        exit ${EXIT_OK}
 }
 
-function _status() {
+function hook_status() {
        local zone=${1}
        local config=${2}
        shift 2
index 0b1cd4cc27828a7c150bc89c6d291ab81c82926d..9bf279a90ca349488878b8968cd98dd9ae61d3bb 100755 (executable)
@@ -37,13 +37,13 @@ SUBNET=
 # 0 = unlimited.
 MAX_SESSIONS=0
 
-function _check() {
+function hook_check() {
        assert isset MTU
        assert isset SUBNET
        assert isset MAX_SESSIONS
 }
 
-function _create() {
+function hook_create() {
        local zone=${1}
        shift
 
@@ -70,7 +70,7 @@ function _create() {
        exit ${EXIT_OK}
 }
 
-function _up() {
+function hook_up() {
        local zone=${1}
        local config=${2}
        shift 2
@@ -81,7 +81,7 @@ function _up() {
        exit ${EXIT_OK}
 }
 
-function _down() {
+function hook_down() {
        local zone=${1}
        local config=${2}
        shift 2
@@ -97,7 +97,7 @@ function _down() {
        exit ${EXIT_OK}
 }
 
-function _status() {
+function hook_status() {
        local zone=${1}
        local config=${2}
        shift 2
index 4ff10a36c80224dec25ac99e1e1e555cf66d8995..1b7d92b1e8f2fda33249b8905c6f732219da297b 100755 (executable)
@@ -23,7 +23,7 @@
 
 HOOK_SETTINGS="COST PRIORITY"
 
-function _check() {
+function hook_check() {
        local i
        for i in COST PRIORITY; do
                if isset ${i}; then
@@ -32,7 +32,7 @@ function _check() {
        done
 }
 
-function _add() {
+function hook_add() {
        local zone=${1}
        local port=${2}
        shift 2
@@ -64,11 +64,11 @@ function _add() {
        exit ${EXIT_OK}
 }
 
-function _edit() {
-       _add $@
+function hook_edit() {
+       hook_add $@
 }
 
-function _rem() {
+function hook_remove() {
        local zone=${1}
        local port=${2}
 
@@ -92,7 +92,7 @@ function _rem() {
        exit ${EXIT_OK}
 }
 
-function _up() {
+function hook_up() {
        local zone=${1}
        local port=${2}
 
@@ -114,7 +114,7 @@ function _up() {
        exit ${EXIT_OK}
 }
 
-function _down() {
+function hook_down() {
        local zone=${1}
        local port=${2}
 
@@ -131,7 +131,7 @@ function _down() {
        exit ${EXIT_OK}
 }
 
-function _status() {
+function hook_status() {
        local zone=${1}
        local port=${2}
 
index 366a65c7fbf186bb3d6940e42495078d1752dc20..d00706811bf10a7f127d6558ba2b5361521b789d 100755 (executable)
@@ -43,7 +43,7 @@ MODE="persistent"
 
 ISDN_ALLOWED_AUTHS="chap pap"
 
-function _check() {
+function hook_check() {
        assert isset USER
        assert isset SECRET
        assert isset LINKNAME
@@ -60,7 +60,7 @@ function _check() {
        isset AUTH && assert isoneof AUTH ${ISDN_ALLOWED_AUTHS}
 }
 
-function _parse_cmdline() {
+function hook_parse_cmdline() {
        local value
 
        while [ $# -gt 0 ]; do
@@ -117,7 +117,7 @@ function _parse_cmdline() {
        done
 }
 
-function _up() {
+function hook_up() {
        local zone=${1}
        shift
 
@@ -156,7 +156,7 @@ function _up() {
        exit ${EXIT_OK}
 }
 
-function _down() {
+function hook_down() {
        local zone=${1}
        shift
 
@@ -169,7 +169,7 @@ function _down() {
        exit ${EXIT_OK}
 }
 
-function _status() {
+function hook_status() {
        local zone=${1}
        assert isset zone
 
index 856e00a18eeb421166792466e681ae6fe526f3ec..e9d12cde56cde2ba3559d72cfee5e54d6d2bc28e 100755 (executable)
@@ -39,7 +39,7 @@ TIMEOUT=10
 
 MODE="persistent"
 
-function _check() {
+function hook_check() {
        assert isset LOCAL_ADDRESS
        assert isset REMOTE_ADDRESS
 
@@ -52,7 +52,7 @@ function _check() {
        isset AUTH && assert isoneof AUTH ${ISDN_ALLOWED_AUTHS}
 }
 
-function _parse_cmdline() {
+function hook_parse_cmdline() {
        local value
 
        while [ $# -gt 0 ]; do
@@ -112,7 +112,7 @@ function _parse_cmdline() {
        done
 }
 
-function _up() {
+function hook_up() {
        local zone=${1}
        shift
 
@@ -169,7 +169,7 @@ function _up() {
        exit ${EXIT_OK}
 }
 
-function _down() {
+function hook_down() {
        local zone=${1}
        shift
 
@@ -185,7 +185,7 @@ function _down() {
        exit ${EXIT_OK}
 }
 
-function _status() {
+function hook_status() {
        local zone=${1}
        assert isset zone
 
index 7794897ce0ccb2929159de49667fcb7c414b34b4..fa37ddf9f5f3b6b9c34f531ccae42b2273a68a57 100755 (executable)
@@ -66,7 +66,7 @@ HOOK_SETTINGS="${HOOK_SETTINGS} PIN"
 PHONE_NUMBER=
 HOOK_SETTINGS="${HOOK_SETTINGS} PHONE_NUMBER"
 
-function _check() {
+function hook_check() {
        assert isset DEVICE
        assert isset PHONE_NUMBER
 
@@ -82,7 +82,7 @@ function _check() {
        isset AUTH && assert isoneof AUTH ${MODEM_ALLOWED_AUTH_METHODS}
 }
 
-function _parse_cmdline() {
+function hook_parse_cmdline() {
        local value
 
        while [ $# -gt 0 ]; do
@@ -128,7 +128,7 @@ function _parse_cmdline() {
        done
 }
 
-function _up() {
+function hook_up() {
        local zone=${1}
        assert isset zone
 
@@ -174,7 +174,7 @@ function _up() {
        exit ${EXIT_OK}
 }
 
-function _down() {
+function hook_down() {
        local zone=${1}
        assert isset zone
 
@@ -184,7 +184,7 @@ function _down() {
        exit ${EXIT_OK}
 }
 
-function _status() {
+function hook_status() {
        local zone=${1}
        assert isset zone
 
@@ -275,7 +275,7 @@ function _status() {
        exit ${EXIT_OK}
 }
 
-function _ppp_write_config() {
+function hook_ppp_write_config() {
        local zone=${1}
        assert isset zone
 
index dd44fa618e67845c43db2b8ab9003d99c35685b8..ee89346487b53a219e6304be4d8704b7e4aaf25f 100755 (executable)
@@ -22,7 +22,7 @@
 . /usr/lib/network/header-zone
 
 HOOK_SETTINGS="HOOK ACCESS_CONCENTRATOR AUTH USERNAME PASSWORD"
-HOOK_SETTINGS="${HOOK_SETTINGS} SERVICE_NAME MTU PORT"
+HOOK_SETTINGS="${HOOK_SETTINGS} SERVICE_NAME MTU PORT IPV6 PREFIX_DELEGATION"
 
 # User credentials for the dialin.
 USERNAME=""
@@ -48,7 +48,13 @@ MTU=1492
 PPPOE_SUPPORTED_AUTH_METHODS="${PPP_SUPPORTED_AUTH_METHODS}"
 PPPOE_PLUGIN="rp-pppoe.so"
 
-function _check() {
+# Request an IPv6 address.
+IPV6="true"
+
+# Use IPv6 prefix delegation.
+PREFIX_DELEGATION="false"
+
+function hook_check() {
        assert isset USERNAME
        assert isset PASSWORD
 
@@ -57,9 +63,12 @@ function _check() {
        # Check for a valid port setting.
        assert isset PORT
        assert port_exists ${PORT}
+
+       assert isset IPV6
+       assert isset PREFIX_DELEGATION
 }
 
-function _parse_cmdline() {
+function hook_parse_cmdline() {
        while [ $# -gt 0 ]; do
                case "${1}" in
                        --access-concentrator=*)
@@ -68,6 +77,14 @@ function _parse_cmdline() {
                        --auth=*)
                                AUTH=$(cli_get_val ${1})
                                ;;
+                       --ipv6=*)
+                               local value="$(cli_get_val "${1}")"
+                               if enabled value; then
+                                       IPV6="true"
+                               else
+                                       IPV6="false"
+                               fi
+                               ;;
                        --mtu=*)
                                MTU=$(cli_get_val ${1})
                                ;;
@@ -77,6 +94,9 @@ function _parse_cmdline() {
                        --port=*)
                                PORT=$(cli_get_val ${1})
                                ;;
+                       --prefix-delegation=*)
+                               PREFIX_DELEGATION="$(cli_get_bool "${1}")"
+                               ;;
                        --service-name=*)
                                SERVICE_NAME=$(cli_get_val ${1})
                                ;;
@@ -91,7 +111,7 @@ function _parse_cmdline() {
        done
 }
 
-function _up() {
+function hook_up() {
        local zone=${1}
        assert isset zone
 
@@ -107,7 +127,7 @@ function _up() {
        exit ${EXIT_OK}
 }
 
-function _down() {
+function hook_down() {
        local zone=${1}
        assert isset zone
 
@@ -123,7 +143,7 @@ function _down() {
        exit ${EXIT_OK}
 }
 
-function _discover() {
+function hook_discover() {
        local device=${1}
 
        if [ "$(device_get_type ${device})" != "real" ]; then
@@ -153,7 +173,7 @@ function _discover() {
        exit ${DISCOVER_OK}
 }
 
-function _status() {
+function hook_status() {
        local zone=${1}
        assert isset zone
 
@@ -205,7 +225,7 @@ function _status() {
        exit ${EXIT_OK}
 }
 
-function _ppp_write_config() {
+function hook_ppp_write_config() {
        local zone=${1}
        assert isset zone
 
@@ -237,6 +257,7 @@ function _ppp_write_config() {
                --password="${PASSWORD}" \
                --mtu="${MTU}" \
                --auth="${AUTH}" \
+               --ipv6="${IPV6}" \
                \
                --plugin="${PPPOE_PLUGIN}" \
                --plugin-options="${plugin_options}"
index f1718e730c97fd4740248ae2aee3c46d961a8236..4e65e9990840ec39a5638e37d51e9c74ad3f309b 100755 (executable)
@@ -27,12 +27,12 @@ HOOK_SETTINGS="HOOK MAC MTU"
 MAC=$(mac_generate)
 MTU=1500
 
-function _check() {
+function hook_check() {
        assert ismac MAC
        assert isinteger MTU
 }
 
-function _parse_cmdline() {
+function hook_parse_cmdline() {
        while [ $# -gt 0 ]; do
                case "${1}" in
                        --mtu=*)
@@ -49,7 +49,7 @@ function _parse_cmdline() {
        done
 }
 
-function _up() {
+function hook_up() {
        local zone=${1}
        shift
 
@@ -72,7 +72,7 @@ function _up() {
        exit ${EXIT_OK}
 }
 
-function _down() {
+function hook_down() {
        local zone=${1}
        shift
 
@@ -89,7 +89,7 @@ function _down() {
        exit ${EXIT_OK}
 }
 
-function _status() {
+function hook_status() {
        local zone=${1}
        assert isset zone
 
index 32f48d451f93e29552109201f7bfa382a45843cb..ece306de8945e8c7b418e5360d33811c1886a8ae 100755 (executable)
@@ -25,11 +25,11 @@ HOOK_SETTINGS="HOOK SERVER"
 
 SERVER=""
 
-function _check() {
+function hook_check() {
        assert isset SERVER
 }
 
-function _parse_cmdline() {
+function hook_parse_cmdline() {
        local value
 
        while [ $# -gt 0 ]; do
@@ -46,7 +46,7 @@ function _parse_cmdline() {
        done
 }
 
-function _up() {
+function hook_up() {
        local zone=${1}
        assert isset zone
 
@@ -55,7 +55,7 @@ function _up() {
        exit ${EXIT_OK}
 }
 
-function _down() {
+function hook_down() {
        local zone=${1}
        assert isset zone
 
@@ -64,7 +64,7 @@ function _down() {
        exit ${EXIT_OK}
 }
 
-function _status() {
+function hook_status() {
        local zone=${1}
        assert isset zone
 
index 327388ba2cbc8e6beeb394924303a60e5cd9263f..f4b853a4b354feb29fa8b95f0bfdd6b787669d63 100755 (executable)
@@ -31,7 +31,7 @@ SSID=
 KEY=
 ENCRYPTION_MODE=
 
-function _check() {
+function hook_check() {
        assert isset SSID
 
        if isset ADDRESS; then
@@ -46,7 +46,7 @@ function _check() {
        fi
 }
 
-function _parse_cmdline() {
+function hook_parse_cmdline() {
        while [ $# -gt 0 ]; do
                case "${1}" in
                        --phy=*|--parent-device=*)
@@ -76,7 +76,7 @@ function _parse_cmdline() {
        PHY=$(phy_get_address ${PHY})
 }
 
-function _up() {
+function hook_up() {
        local zone=${1}
        assert isset zone
 
@@ -100,7 +100,7 @@ function _up() {
        exit ${EXIT_OK}
 }
 
-function _down() {
+function hook_down() {
        local zone=${1}
        shift
 
@@ -118,7 +118,7 @@ function _down() {
        exit ${EXIT_OK}
 }
 
-function _status() {
+function hook_status() {
        local zone=${1}
        assert isset zone
 
diff --git a/man/firewall-config.xml b/man/firewall-config.xml
new file mode 100644 (file)
index 0000000..ae011e1
--- /dev/null
@@ -0,0 +1,285 @@
+<?xml version="1.0"?>
+<!DOCTYPE refentry PUBLIC "-//OASIS/DTD DocBook XML V4.2//EN"
+       "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
+
+<refentry id="firewall-config">
+       <refentryinfo>
+               <title>firewall-config</title>
+               <productname>network</productname>
+
+               <authorgroup>
+                       <author>
+                               <contrib>Developer</contrib>
+                               <firstname>Michael</firstname>
+                               <surname>Tremer</surname>
+                               <email>michael.tremer@ipfire.org</email>
+                       </author>
+               </authorgroup>
+       </refentryinfo>
+
+       <refmeta>
+               <refentrytitle>firewall-config</refentrytitle>
+               <manvolnum>8</manvolnum>
+       </refmeta>
+
+       <refnamediv>
+               <refname>firewall-config</refname>
+               <refpurpose>Firewall Configuration Control Program</refpurpose>
+       </refnamediv>
+
+       <refsynopsisdiv>
+               <cmdsynopsis>
+                       <command>firewall-config</command>
+               </cmdsynopsis>
+
+               <cmdsynopsis>
+                       <command>firewall-config <replaceable>KEY=VALUE</replaceable></command>
+               </cmdsynopsis>
+       </refsynopsisdiv>
+
+       <refsect1>
+               <title>Description</title>
+
+               <para>
+                       The <command>firewall-config</command> command may be used to set
+                       global firewall configuration options.
+               </para>
+               <para>
+                       Please have a look at the individual man pages for more options.
+               </para>
+       </refsect1>
+
+       <refsect1>
+               <title>Commands</title>
+
+               <para>
+                       If no additional argument is given, running the command will
+                       dump a list of all configuration variables and their current values.
+               </para>
+
+               <para>
+                       You may set a new value by adding the variable name and the new
+                       value to the command line.
+               </para>
+       </refsect1>
+
+       <refsect1>
+               <title>Variables</title>
+
+               <variablelist>
+                       <varlistentry>
+                               <term>
+                                       <varname>CONNTRACK_MAX_CONNECTIONS</varname> = <replaceable>16384</replaceable>
+                               </term>
+
+                               <listitem>
+                                       <para>
+                                               Limits the max. number of simultaneous connections.
+                                       </para>
+                                       <para>
+                                               Modify this if you want to handle a larger number of concurrent
+                                               connections. Every connection will use approx. 16 kBytes of memory.
+                                       </para>
+                               </listitem>
+                       </varlistentry>
+
+                       <varlistentry>
+                               <term>
+                                       <varname>CONNTRACK_UDP_TIMEOUT</varname> = <replaceable>60</replaceable>
+                               </term>
+
+                               <listitem>
+                                       <para>
+                                               Defines the timeout (in seconds) the kernel will wait until
+                                               a half-assured UDP connection is fully established.
+                                       </para>
+                               </listitem>
+                       </varlistentry>
+
+                       <varlistentry>
+                               <term>
+                                       <varname>FIREWALL_ACCEPT_ICMP_REDIRECTS</varname> = [true|<emphasis>false</emphasis>]
+                               </term>
+
+                               <listitem>
+                                       <para>
+                                               Enable if you want to accept ICMP redirect messages.
+                                       </para>
+                               </listitem>
+                       </varlistentry>
+
+                       <varlistentry>
+                               <term>
+                                       <varname>FIREWALL_CLAMP_PATH_MTU</varname> = [true|<emphasis>false</emphasis>]
+                               </term>
+
+                               <listitem>
+                                       <para>
+                                               If Path MTU Discovery does not work well, enable this option.
+                                               It sets the MSS value of a packet so that the remote site would
+                                               never send a packet bigger than the MSS value.
+                                       </para>
+                                       <para>
+                                               No ICMP packets are needed to make this work, so use this on
+                                               networks with broken ICMP filtering.
+                                       </para>
+                               </listitem>
+                       </varlistentry>
+
+                       <varlistentry>
+                               <term>
+                                       <varname>FIREWALL_DEFAULT_TTL</varname> = <replaceable>64</replaceable>
+                               </term>
+
+                               <listitem>
+                                       <para>
+                                               Here you can change the default TTL used for sending packets.
+                                       </para>
+                                       <para>
+                                               The given value must be between 10 and 255.
+                                               Don't mess with this unless you know what you are doing.
+                                       </para>
+                               </listitem>
+                       </varlistentry>
+
+                       <varlistentry>
+                               <term>
+                                       <varname>FIREWALL_LOG_BAD_TCP_FLAGS</varname> = [<emphasis>true</emphasis>|false]
+                               </term>
+
+                               <listitem>
+                                       <para>
+                                               Enable this to log TCP packets with bad flags or options.
+                                       </para>
+                               </listitem>
+                       </varlistentry>
+
+                       <varlistentry>
+                               <term>
+                                       <varname>FIREWALL_LOG_INVALID_ICMP</varname> = [<emphasis>true</emphasis>|false]
+                               </term>
+
+                               <listitem>
+                                       <para>
+                                               Enable this to log INVALID ICMP packets.
+                                       </para>
+                               </listitem>
+                       </varlistentry>
+
+                       <varlistentry>
+                               <term>
+                                       <varname>FIREWALL_LOG_INVALID_TCP</varname> = [<emphasis>true</emphasis>|false]
+                               </term>
+
+                               <listitem>
+                                       <para>
+                                               Enable this to log INVALID TCP packets.
+                                       </para>
+                               </listitem>
+                       </varlistentry>
+
+                       <varlistentry>
+                               <term>
+                                       <varname>FIREWALL_LOG_INVALID_UDP</varname> = [<emphasis>true</emphasis>|false]
+                               </term>
+
+                               <listitem>
+                                       <para>
+                                               Enable this to log INVALID UDP packets.
+                                       </para>
+                               </listitem>
+                       </varlistentry>
+
+                       <varlistentry>
+                               <term>
+                                       <varname>FIREWALL_LOG_MARTIANS</varname> = [true|<emphasis>false</emphasis>]
+                               </term>
+
+                               <listitem>
+                                       <para>
+                                               Enable this to log packets with impossible addresses.
+                                       </para>
+                               </listitem>
+                       </varlistentry>
+
+                       <varlistentry>
+                               <term>
+                                       <varname>FIREWALL_LOG_STEALTH_SCANS</varname> = [<emphasis>true</emphasis>|false]
+                               </term>
+
+                               <listitem>
+                                       <para>
+                                               Enable this to log all stealth scans.
+                                       </para>
+                               </listitem>
+                       </varlistentry>
+
+                       <varlistentry>
+                               <term>
+                                       <varname>FIREWALL_PMTU_DISCOVERY</varname> = [<emphasis>true</emphasis>|false]
+                               </term>
+
+                               <listitem>
+                                       <para>
+                                               Enables Path MTU Discovery.
+                                               Disable it when you are experiencing problems.
+                                       </para>
+                               </listitem>
+                       </varlistentry>
+
+                       <varlistentry>
+                               <term>
+                                       <varname>FIREWALL_RP_FILTER</varname> = [<emphasis>true</emphasis>|false]
+                               </term>
+
+                               <listitem>
+                                       <para>
+                                               Enable to drop connection from non-routable IPs,
+                                               e.g. prevent source routing.
+                                       </para>
+                               </listitem>
+                       </varlistentry>
+
+                       <varlistentry>
+                               <term>
+                                       <varname>FIREWALL_SYN_COOKIES</varname> = [<emphasis>true</emphasis>|false]
+                               </term>
+
+                               <listitem>
+                                       <para>
+                                               Enable for SYN-flood protection.
+                                       </para>
+                               </listitem>
+                       </varlistentry>
+
+                       <varlistentry>
+                               <term>
+                                       <varname>FIREWALL_USE_ECN</varname> = [true|<emphasis>false</emphasis>]
+                               </term>
+
+                               <listitem>
+                                       <para>
+                                               Enables the ECN (Explicit Congestion Notification) TCP flag.
+                                       </para>
+                                       <para>
+                                               Some routers on the Internet still do not support ECN properly,
+                                               so this is not enabled by default.
+                                               When this setting is disabled, ECN is only advertised
+                                               when asked for.
+                                       </para>
+                               </listitem>
+                       </varlistentry>
+               </variablelist>
+       </refsect1>
+
+       <refsect1>
+               <title>See Also</title>
+
+               <para>
+                       <citerefentry>
+                               <refentrytitle>firewall</refentrytitle>
+                               <manvolnum>8</manvolnum>
+                       </citerefentry>
+               </para>
+       </refsect1>
+</refentry>
index 656fa4b0d6ebba8a5bae0dd61578205d0745b6fb..9c1ac7e1d1a6a82b0cce0acb27c03a1d16d169d7 100755 (executable)
@@ -53,15 +53,31 @@ if isset ZONE && zone_exists ${ZONE}; then
        assert hook_zone_exists ${HOOK}
 
        PROGNAME=$(basename ${0})
-       assert isset PROGNAME
+       METHOD=""
+       case "${PROGNAME}" in
+               ip-pre-up)
+                       METHOD="ppp_ip_pre_up"
+                       ;;
+               ipv6-down)
+                       METHOD="ppp_ipv6_down"
+                       ;;
+               ipv6-up)
+                       METHOD="ppp_ipv6_up"
+                       ;;
+               ip-down)
+                       METHOD="ppp_ipv4_down"
+                       ;;
+               ip-up)
+                       METHOD="ppp_ipv4_up"
+                       ;;
+       esac
+       assert isset METHOD
 
-       log DEBUG "${PROGNAME} was called with the following parameters:"
+       log DEBUG "${PROGNAME}/${METHOD} was called with the following parameters:"
        log DEBUG "  $@"
 
-       hook_zone_exec ${HOOK} ppp-${PROGNAME} ${ZONE}
-       ret=$?
-
-       exit ${ret}
+       hook_zone_exec "${HOOK}" "${METHOD}" "${ZONE}"
+       exit $?
 fi
 
 exit ${EXIT_OK}
diff --git a/sysctl.d/network-ipv4.conf b/sysctl.d/network-ipv4.conf
deleted file mode 100644 (file)
index a6d6e5e..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-# Kernel configuration file for IPv4
-#
-
-# Enable IPv4 packet forwarding
-net.ipv4.ip_forward = 1
-
-# Enable source route verification
-net.ipv4.conf.default.rp_filter = 1
-
-# Do not accept source routing
-net.ipv4.conf.default.accept_source_route = 0
-
-# Enable ARP filter
-net.ipv4.conf.default.arp_filter = 1
diff --git a/sysctl.d/network-ipv6.conf b/sysctl.d/network-ipv6.conf
deleted file mode 100644 (file)
index 87af728..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-# Kernel configuration file for IPv6
-#
-
-# Enable IPv6 forwarding
-net.ipv6.conf.all.forwarding = 1
-net.ipv6.conf.default.forwarding = 1
diff --git a/systemd/firewall-init.service b/systemd/firewall-init.service
new file mode 100644 (file)
index 0000000..5e06bb6
--- /dev/null
@@ -0,0 +1,8 @@
+[Unit]
+Description=Initialize kernel parameters for the firewalls
+Before=network.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/usr/lib/network/helpers/firewall-kernel-init
index 9a147051a9e29650e3cfd85d0c5ef91ca798e839..45d20b2c69e6d51f9386a5dde10f1591c966a6ad 100644 (file)
@@ -1,6 +1,8 @@
 [Unit]
 Description=Firewall for IPv4
-Before=network.service
+After=firewall-init.service
+Before=network.target
+Requires=firewall-init.service
 
 [Service]
 Type=oneshot
index 1b3abad5637753349190b8a9798d45ce4fade3b9..eedeea4ecb5ba7b7273b5c8c068e2ec283e8dd2b 100644 (file)
@@ -1,6 +1,8 @@
 [Unit]
 Description=Firewall for IPv6
-Before=network.service
+After=firewall-init.service
+Before=network.target
+Requires=firewall-init.service
 
 [Service]
 Type=oneshot
index 0fdb7de040a5d822e5b33ffd7f783beb228ba6e2..5b884ed9dc0ee8144e5be3b6dbc8585e6dd2c308 100644 (file)
@@ -1,6 +1,8 @@
 [Unit]
 Description=Network Connectivity
+After=firewall-init.service
 Before=network.target
+Requires=firewall-init.service
 
 [Service]
 Type=oneshot
index 2ae3a72e2c29bee655f770dfbb24d271023d809a..07df33adbd7a4225d365fc35a7d9ab176c213a8d 100644 (file)
@@ -1,5 +1,7 @@
 [Unit]
 Description=Network Connectivity for zone %I
+After=firewall-init.service
+Requires=firewall-init.service
 
 [Service]
 Type=oneshot