gnu_linux_server:network_configuration:firewall6
                Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| gnu_linux_server:network_configuration:firewall6 [2012/01/29 04:56] – Règles pour adresses de liens locaux et multicast guillaume | gnu_linux_server:network_configuration:firewall6 [2021/01/04 20:41] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 6: | Line 6: | ||
| <code bash> | <code bash> | ||
| + | ### BEGIN INIT INFO | ||
| + | # Provides: | ||
| + | # Required-Start: | ||
| + | # Required-Stop: | ||
| + | # Default-Start: | ||
| + | # Default-Stop: | ||
| + | # Short-Description: | ||
| + | # Description: | ||
| + | ### END INIT INFO | ||
| + | |||
| #!/bin/bash | #!/bin/bash | ||
| . / | . / | ||
| + | |||
| + | # In debug mode there will be more outputs | ||
| + | # 0 to disable | ||
| + | # 1 to enable | ||
| + | DEBUG=0 | ||
| + | |||
| + | # Print message only in debug mode | ||
| + | # Usage: print_debug ${message} ${return_code} | ||
| + | # ${return_code} is optional | ||
| + | print_debug() { | ||
| + | [ ${DEBUG} -eq 0 ] && return 0 | ||
| + | [ $# -ne 1 ]       && | ||
| + | |||
| + | log_action_begin_msg ${1} | ||
| + | } | ||
| + | |||
| + | end_debug() { | ||
| + | [ ${DEBUG} -eq 0 ] && return 0 | ||
| + | [ $# -ne 1 ]       && | ||
| + | |||
| + | log_action_end_msg ${1} | ||
| + | } | ||
| deny_everything() { | deny_everything() { | ||
| - |  | + |  | 
| ip6tables -t filter -P INPUT DROP | ip6tables -t filter -P INPUT DROP | ||
| Line 17: | Line 49: | ||
| ip6tables -t filter -P OUTPUT | ip6tables -t filter -P OUTPUT | ||
| - |  | + |  | 
| } | } | ||
| accept_everything() { | accept_everything() { | ||
| - | log_action_begin_msg | + | print_debug | 
| - |  | + |  | 
| - | ip6tables -t filter -P FORWARD ACCEPT | + | ip6tables -t filter -P FORWARD ACCEPT | 
| - | ip6tables -t filter -P OUTPUT | + | ip6tables -t filter -P OUTPUT | 
| - | log_action_end_msg | + | end_debug | 
| } | } | ||
| cleanup_tables() { | cleanup_tables() { | ||
| - |  | + |  | 
| ip6tables -t filter -F | ip6tables -t filter -F | ||
| ip6tables -t filter -X | ip6tables -t filter -X | ||
| - |  | + |  | 
| } | } | ||
| dont_break_connections() { | dont_break_connections() { | ||
| - |  | + |  | 
| ip6tables -A INPUT  -m state --state RELATED, | ip6tables -A INPUT  -m state --state RELATED, | ||
| ip6tables -A OUTPUT -m state --state RELATED, | ip6tables -A OUTPUT -m state --state RELATED, | ||
| - |  | + |  | 
| } | } | ||
| allow_loopback() { | allow_loopback() { | ||
| - |  | + |  | 
| ip6tables -t filter -A INPUT -i lo -j ACCEPT | ip6tables -t filter -A INPUT -i lo -j ACCEPT | ||
| ip6tables -t filter -A OUTPUT -o lo -j ACCEPT | ip6tables -t filter -A OUTPUT -o lo -j ACCEPT | ||
| - |  | + |  | 
| } | } | ||
| allow_link_local_addresses() { | allow_link_local_addresses() { | ||
| - |  | + |  | 
| + | |||
| ip6tables -t filter -A INPUT -s fe80::/10 -j ACCEPT | ip6tables -t filter -A INPUT -s fe80::/10 -j ACCEPT | ||
| ip6tables -t filter -A OUTPUT -s fe80::/10 -j ACCEPT | ip6tables -t filter -A OUTPUT -s fe80::/10 -j ACCEPT | ||
| - | + | ||
| - |  | + |  | 
| } | } | ||
| + | |||
| allow_multicast_addresses() { | allow_multicast_addresses() { | ||
| - |  | + |  | 
| + | |||
| ip6tables -t filter -A INPUT -s ff00::/8 -j ACCEPT | ip6tables -t filter -A INPUT -s ff00::/8 -j ACCEPT | ||
| ip6tables -t filter -A OUTPUT -s ff00::/8 -j ACCEPT | ip6tables -t filter -A OUTPUT -s ff00::/8 -j ACCEPT | ||
| - | + | ||
| - |  | + |  | 
| } | } | ||
| open_input_port() { | open_input_port() { | ||
| - |  | + | [ $# -ne 2 ] && | 
| - |  | + | |
| - | fi | + | |
| - |  | + |  | 
| ip6tables -t filter -A INPUT -p " | ip6tables -t filter -A INPUT -p " | ||
| - |  | + |  | 
| } | } | ||
| open_output_port() { | open_output_port() { | ||
| - |  | + | [ $# -ne 2 ] && | 
| - |  | + | |
| - | fi | + | |
| - |  | + |  | 
| ip6tables -t filter -A OUTPUT -p " | ip6tables -t filter -A OUTPUT -p " | ||
| - |  | + |  | 
| } | } | ||
| allow_input_protocol() { | allow_input_protocol() { | ||
| - |  | + | [ $# -ne 1 ] && | 
| - |  | + | |
| - | fi | + | |
| - |  | + |  | 
| ip6tables -t filter -A INPUT -p " | ip6tables -t filter -A INPUT -p " | ||
| - |  | + |  | 
| } | } | ||
| allow_output_protocol() { | allow_output_protocol() { | ||
| - |  | + | [ $# -ne 1 ] && | 
| - |  | + | |
| - | fi | + | |
| - |  | + |  | 
| ip6tables -t filter -A OUTPUT -p " | ip6tables -t filter -A OUTPUT -p " | ||
| - |  | + |  | 
| } | } | ||
| Line 128: | Line 152: | ||
| # Stop fail to ban before configuring firewall | # Stop fail to ban before configuring firewall | ||
| / | / | ||
| - |  | + |  | 
| deny_everything | deny_everything | ||
| Line 235: | Line 259: | ||
| # Starting fail2ban again | # Starting fail2ban again | ||
| / | / | ||
| - |  | + |  | 
| - | exit 0 | + | |
| ;; | ;; | ||
| stop) | stop) | ||
| - |  | + |  | 
| accept_everything | accept_everything | ||
| cleanup_tables | cleanup_tables | ||
| - |  | + |  | 
| - | exit 0 | + | |
| ;; | ;; | ||
| Line 253: | Line 275: | ||
| exit 1 | exit 1 | ||
| ;; | ;; | ||
| + | esac | ||
| + | |||
| + | exit 0 | ||
| </ | </ | ||
gnu_linux_server/network_configuration/firewall6.1327812988.txt.gz · Last modified: 2021/01/04 20:40 (external edit)
                
                