]>
git.ipfire.org Git - ipfire-2.x.git/blob - config/firewall/firewall-policy
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2013 Alexander Marx <amarx@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/ethernet
/settings
)
23 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/firewall
/settings
)
24 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/optionsfw
/settings
)
27 /sbin
/iptables
--wait "$@"
34 if [ -f "/var/ipfire/red/iface" ]; then
35 IFACE
="$(</var/ipfire/red/iface)"
38 # Figure out what devices are configured.
42 case "${CONFIG_TYPE}" in
60 # Allow access from GREEN
61 iptables
-A POLICYIN
-i "${GREEN_DEV}" -j ACCEPT
64 case "${HAVE_IPSEC},${POLICY}" in
67 iptables
-A POLICYIN
-m policy
--pol ipsec
--dir in -j ACCEPT
72 # Allow direct access to the internal IP addresses of the firewall
73 # from remote subnets if forward policy is allowed.
74 case "${HAVE_OPENVPN},${POLICY}" in
77 iptables
-A POLICYIN
-i tun
+ -j ACCEPT
81 case "${FWPOLICY2}" in
83 if [ "${DROPINPUT}" = "on" ]; then
84 iptables
-A POLICYIN
-m limit
--limit 10/minute
-j LOG
--log-prefix "REJECT_INPUT "
86 iptables
-A POLICYIN
-j REJECT
--reject-with icmp-host-unreachable
-m comment
--comment "DROP_INPUT"
89 if [ "${DROPINPUT}" = "on" ]; then
90 iptables
-A POLICYIN
-m limit
--limit 10/minute
-j LOG
--log-prefix "DROP_INPUT "
92 iptables
-A POLICYIN
-j DROP
-m comment
--comment "DROP_INPUT"
101 if [ "${DROPFORWARD}" = "on" ]; then
102 iptables
-A POLICYFWD
-m limit
--limit 10/minute
-j LOG
--log-prefix "REJECT_FORWARD "
104 iptables
-A POLICYFWD
-j REJECT
--reject-with icmp-host-unreachable
-m comment
--comment "DROP_FORWARD"
107 if [ "${DROPFORWARD}" = "on" ]; then
108 iptables
-A POLICYFWD
-m limit
--limit 10/minute
-j LOG
--log-prefix "DROP_FORWARD "
110 iptables
-A POLICYFWD
-j DROP
-m comment
--comment "DROP_FORWARD"
116 # Access from GREEN is granted to everywhere
117 if [ "${IFACE}" = "${GREEN_DEV}" ]; then
119 # don't check source IP/NET if IFACE is GREEN
120 iptables
-A POLICYFWD
-i "${GREEN_DEV}" -j ACCEPT
122 iptables
-A POLICYFWD
-i "${GREEN_DEV}" -s "${GREEN_NETADDRESS}/${GREEN_NETMASK}" -j ACCEPT
125 # Grant access for IPsec VPN connections
126 iptables
-A POLICYFWD
-m policy
--pol ipsec
--dir in -j ACCEPT
128 # Grant access for OpenVPN connections
129 iptables
-A POLICYFWD
-i tun
+ -j ACCEPT
131 if [ -n "${IFACE}" ]; then
132 if [ "${HAVE_BLUE}" = "true" ] && [ -n "${BLUE_DEV}" ]; then
133 iptables
-A POLICYFWD
-i "${BLUE_DEV}" -s "${BLUE_NETADDRESS}/${BLUE_NETMASK}" -o "${IFACE}" -j ACCEPT
136 if [ "${HAVE_ORANGE}" = "true" ] && [ -n "${ORANGE_DEV}" ]; then
137 iptables
-A POLICYFWD
-i "${ORANGE_DEV}" -s "${ORANGE_NETADDRESS}/${ORANGE_NETMASK}" -o "${IFACE}" -j ACCEPT
141 if [ "${DROPFORWARD}" = "on" ]; then
142 iptables
-A POLICYFWD
-m limit
--limit 10/minute
-j LOG
--log-prefix "DROP_FORWARD "
144 iptables
-A POLICYFWD
-m comment
--comment "DROP_FORWARD" -j DROP
151 case "${FWPOLICY1}" in
153 if [ "${DROPOUTGOING}" = "on" ]; then
154 iptables
-A POLICYOUT
-m limit
--limit 10/minute
-j LOG
--log-prefix "REJECT_OUTPUT "
156 iptables
-A POLICYOUT
-j REJECT
--reject-with icmp-host-unreachable
-m comment
--comment "DROP_OUTPUT"
159 if [ "${DROPOUTGOING}" == "on" ]; then
160 iptables
-A POLICYOUT
-m limit
--limit 10/minute
-j LOG
--log-prefix "DROP_OUTPUT "
162 iptables
-A POLICYOUT
-j DROP
-m comment
--comment "DROP_OUTPUT"
167 iptables
-A POLICYOUT
-j ACCEPT
168 iptables
-A POLICYOUT
-m comment
--comment "DROP_OUTPUT" -j DROP