iptables:basic_firewall
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
iptables:basic_firewall [2016/10/20 19:45] – peter | iptables:basic_firewall [2019/11/29 16:38] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== IPTables - Basic Firewall ====== | ||
- | ===== Verify the IPTables package is installed ===== | ||
- | |||
- | <code bash> | ||
- | dpkg --list | grep iptables | ||
- | </ | ||
- | |||
- | Returns | ||
- | |||
- | < | ||
- | ii iptables | ||
- | </ | ||
- | |||
- | |||
- | ===== Verify the Kernel Module is loaded ===== | ||
- | |||
- | <code bash> | ||
- | lsmod | grep ip_tables | ||
- | </ | ||
- | |||
- | Returns | ||
- | |||
- | < | ||
- | ip_tables | ||
- | </ | ||
- | |||
- | |||
- | |||
- | ===== Creating iptables rules ===== | ||
- | |||
- | <code bash> | ||
- | iptables -P INPUT DROP | ||
- | iptables -P OUTPUT DROP | ||
- | |||
- | # Allowing Loopback Traffic. | ||
- | iptables -I INPUT -i lo -j ACCEPT | ||
- | |||
- | # Allow established connections. | ||
- | iptables -A INPUT -m conntrack --ctstate ESTABLISHED, | ||
- | |||
- | # Allow SSH access. | ||
- | # iptables -I INPUT -p tcp --dport 22 -j ACCEPT | ||
- | iptables -A INPUT -p tcp --dport 22 -s 192.168.1.2 -j ACCEPT | ||
- | |||
- | |||
- | # Enable Web. | ||
- | # iptables -A INPUT -p tcp --dport 80 -j ACCEPT | ||
- | # iptables -A INPUT -p tcp --dport 443 -j ACCEPT | ||
- | |||
- | |||
- | # Enable FTP. | ||
- | # iptables -A INPUT -p tcp --dport 21 -j ACCEPT | ||
- | # iptables -A INPUT -p tcp --dport 20 -j ACCEPT | ||
- | |||
- | |||
- | # To block an IP range. | ||
- | iptables -I INPUT 3 -s 192.168.123.0/ | ||
- | |||
- | </ | ||
- | |||
- | |||
- | ===== Enable kernel modules ===== | ||
- | |||
- | To have FTP work correctly with iptables, ensure that the **ip_conntrack_ftp** module is loaded. | ||
- | |||
- | <code bash> | ||
- | modprobe ip_conntrack_ftp | ||
- | </ | ||
- | |||
- | Check that the module is loaded | ||
- | |||
- | <code bash> | ||
- | lsmod | grep conntrack | ||
- | </ | ||
- | |||
- | Returns | ||
- | |||
- | < | ||
- | nf_conntrack_ftp | ||
- | nf_conntrack_ipv4 | ||
- | nf_defrag_ipv4 | ||
- | xt_conntrack | ||
- | nf_conntrack | ||
- | x_tables | ||
- | </ | ||
- | |||
- | |||
- | ===== Setup an init script ===== | ||
- | |||
- | <file bash / | ||
- | #!/bin/bash | ||
- | # | ||
- | # Start and stop the Firewall. | ||
- | # Modify the following settings as required: | ||
- | |||
- | ### BEGIN INIT INFO | ||
- | # Provides: | ||
- | # Required-Start: | ||
- | # Required-Stop: | ||
- | # Default-Start: | ||
- | # Default-Stop: | ||
- | ### END INIT INFO | ||
- | |||
- | |||
- | IPTABLES=/ | ||
- | NAME=firewall-sharewiz | ||
- | |||
- | |||
- | opts=" | ||
- | |||
- | #if [[ $1 == start ]] ; then | ||
- | |||
- | case " | ||
- | start) | ||
- | / | ||
- | ;; | ||
- | |||
- | stop) | ||
- | $IPTABLES --flush | ||
- | $IPTABLES -t nat --flush | ||
- | $IPTABLES -F -t mangle | ||
- | $IPTABLES -P INPUT ACCEPT | ||
- | $IPTABLES -P OUTPUT ACCEPT | ||
- | $IPTABLES -P FORWARD ACCEPT | ||
- | $IPTABLES -t nat -P POSTROUTING ACCEPT | ||
- | $IPTABLES -t nat -P PREROUTING ACCEPT | ||
- | $IPTABLES -t nat -P OUTPUT ACCEPT | ||
- | ;; | ||
- | |||
- | restart|reload) | ||
- | # $0 stop | ||
- | # $0 start | ||
- | |||
- | $IPTABLES --flush | ||
- | $IPTABLES -t nat --flush | ||
- | $IPTABLES -F -t mangle | ||
- | $IPTABLES -P INPUT ACCEPT | ||
- | $IPTABLES -P OUTPUT ACCEPT | ||
- | $IPTABLES -P FORWARD ACCEPT | ||
- | $IPTABLES -t nat -P POSTROUTING ACCEPT | ||
- | $IPTABLES -t nat -P PREROUTING ACCEPT | ||
- | $IPTABLES -t nat -P OUTPUT ACCEPT | ||
- | |||
- | / | ||
- | ;; | ||
- | |||
- | |||
- | status) | ||
- | $IPTABLES --list | ||
- | $IPTABLES -t nat --list | ||
- | $IPTABLES -t mangle --list | ||
- | ;; | ||
- | |||
- | |||
- | *) | ||
- | echo " | ||
- | exit 1 | ||
- | ;; | ||
- | |||
- | |||
- | |||
- | esac | ||
- | |||
- | exit 0· | ||
- | </ | ||
- | |||
- | Set permissions | ||
- | |||
- | <code bash> | ||
- | chmod 755 / | ||
- | </ | ||
- | |||
- | |||
- | |||
- | ===== Create the firewall script ===== | ||
- | |||
- | <code bash> | ||
- | vi / | ||
- | </ | ||
- | |||
- | and populate as | ||
- | |||
- | <file bash / | ||
- | #!/bin/bash | ||
- | # | ||
- | # Modify the following settings as required: | ||
- | # | ||
- | # You should check/test that the firewall really works, using | ||
- | # iptables -vnL, nmap, ping, telnet, ... | ||
- | # | ||
- | # TODO: ICQ, MSN, GTalk, Skype, Yahoo, etc... | ||
- | |||
- | IPTABLES=/ | ||
- | IP6TABLES=/ | ||
- | LOAD_MODULES=yes | ||
- | LOAD_MODULES_IPV6=no | ||
- | DEPMOD=/ | ||
- | MODPROBE=/ | ||
- | RMMOD=/ | ||
- | ARP=/ | ||
- | |||
- | |||
- | # | ||
- | # REJECT target works basically the same as the DROP target, but it also sends | ||
- | # back an error message to the host sending the packet that was blocked. | ||
- | # | ||
- | # The REJECT target is as of today only valid in the INPUT, FORWARD and OUTPUT | ||
- | # chains or their sub chains. | ||
- | # | ||
- | |||
- | # REJECT --reject-with tcp-reset | ||
- | # REJECT --icmp-net-unreachable | ||
- | # REJECT --icmp-host-unreachable | ||
- | # REJECT --icmp-port-unreachable | ||
- | # REJECT --icmp-proto-unreachable | ||
- | # REJECT --icmp-net-prohibited | ||
- | # REJECT --icmp-host-prohibited | ||
- | |||
- | |||
- | # | ||
- | # | ||
- | # Interfaces | ||
- | # | ||
- | # | ||
- | # | ||
- | |||
- | # | ||
- | #ifconfig em1 | grep -m 1 inet | tr -d [:alpha:] | ||
- | # | ||
- | # | ||
- | # | ||
- | #unset tmp | ||
- | |||
- | # | ||
- | # Internet Interface | ||
- | # | ||
- | # | ||
- | # | ||
- | INET_IFACE=" | ||
- | # | ||
- | INET_GW=" | ||
- | INET_IP=" | ||
- | INET_NET=" | ||
- | INET_BCAST=" | ||
- | # | ||
- | |||
- | # | ||
- | # Local Interface Information | ||
- | # | ||
- | # | ||
- | LOCAL_IFACE=" | ||
- | # | ||
- | LOCAL_IP=" | ||
- | LOCAL_NET=" | ||
- | LOCAL_BCAST=" | ||
- | # | ||
- | |||
- | # | ||
- | # Localhost Interface | ||
- | # | ||
- | LO_IFACE=" | ||
- | LO_IP=" | ||
- | # | ||
- | |||
- | # | ||
- | # Standard Definitions | ||
- | # | ||
- | ALL=" | ||
- | CLASS_A=" | ||
- | CLASS_B=" | ||
- | CLASS_C=" | ||
- | CLASS_D_MULTICAST=" | ||
- | CLASS_E_RESERVED_NET=" | ||
- | LOOPBACK=" | ||
- | P_PORTS=" | ||
- | UP_PORTS=" | ||
- | # | ||
- | |||
- | # | ||
- | # DNS servers | ||
- | # | ||
- | DNS_SERVERS=" | ||
- | # | ||
- | |||
- | ########################################################################### | ||
- | # | ||
- | # Module loading. | ||
- | # | ||
- | if [ $LOAD_MODULES == " | ||
- | # | ||
- | # Initially load modules | ||
- | # | ||
- | $DEPMOD -a | ||
- | |||
- | # | ||
- | # Required modules | ||
- | # | ||
- | $MODPROBE ip_tables | ||
- | #$MODPROBE ip6_tables | ||
- | $MODPROBE ip_conntrack | ||
- | $MODPROBE ip_conntrack_ftp | ||
- | $MODPROBE iptable_filter | ||
- | $MODPROBE iptable_mangle | ||
- | $MODPROBE iptable_nat | ||
- | $MODPROBE ip_nat_ftp | ||
- | $MODPROBE ipt_LOG | ||
- | $MODPROBE ipt_limit | ||
- | $MODPROBE ipt_state | ||
- | # | ||
- | # To prevent the dmesg command showing errors such as:· | ||
- | # xt_recent: hitcount (25) is larger than packets to be remembered (20) | ||
- | # | ||
- | # The following command shows all the xt_recent parameters: | ||
- | # head / | ||
- | # | ||
- | # ls -al / | ||
- | # | ||
- | # Use modinfo xt_recent to see the possible parameters. | ||
- | # | ||
- | # ls -1 / | ||
- | # Any of the parameters can be checked by simply: | ||
- | # cat / | ||
- | # | ||
- | #$RMMOD xt_recent | ||
- | $MODPROBE xt_recent ip_list_tot=100000 ip_pkt_list_tot=255 | ||
- | #$MODPROBE ipt_recent ip_list_tot=100000 ip_pkt_list_tot=255 | ||
- | # | ||
- | # Non-Required modules | ||
- | # | ||
- | #$MODPROBE ipt_owner | ||
- | #$MODPROBE ipt_REJECT | ||
- | #$MODPROBE ipt_MASQUERADE | ||
- | #$MODPROBE ip_conntrack_ftp | ||
- | #$MODPROBE ip_conntrack_irc | ||
- | #$MODPROBE ip_nat_ftp | ||
- | #$MODPROBE ip_nat_irc | ||
- | # | ||
- | fi | ||
- | |||
- | |||
- | |||
- | |||
- | # | ||
- | # What to allow | ||
- | # | ||
- | # 0=no | ||
- | # 1=yes | ||
- | # | ||
- | ALLOW_APPLESHARE_IN=0 | ||
- | ALLOW_APPLESHARE_OUT=0 | ||
- | ALLOW_BITTORRENT_IN=0 | ||
- | ALLOW_BITTORRENT_OUT=0 | ||
- | ALLOW_BOOTP_CLIENT_IN=0 | ||
- | ALLOW_BOOTP_CLIENT_OUT=0 | ||
- | ALLOW_BOOTP_SERVER_IN=0 | ||
- | ALLOW_BOOTP_SERVER_OUT=0 | ||
- | ALLOW_CHARGEN_IN=0 | ||
- | ALLOW_CHARGEN_OUT=0 | ||
- | ALLOW_CORBA_IIOP_IN=0 | ||
- | ALLOW_CORBA_IIOP_OUT=0 | ||
- | ALLOW_CUPS_IN=0 | ||
- | ALLOW_CUPS_OUT=0 | ||
- | ALLOW_CVS_IN=0 | ||
- | ALLOW_CVS_OUT=0 | ||
- | ALLOW_DAYTIME_IN=0 | ||
- | ALLOW_DAYTIME_OUT=0 | ||
- | ALLOW_DHCP_BROADCAST_IN=1 | ||
- | ALLOW_DHCP_BROADCAST_OUT=1 | ||
- | ALLOW_DISCARD_IN=0 | ||
- | ALLOW_DISCARD_OUT=0 | ||
- | ALLOW_DNS_IN=1 | ||
- | ALLOW_DNS_OUT=1 | ||
- | ALLOW_ECHO_IN=0 | ||
- | ALLOW_ECHO_OUT=0 | ||
- | ALLOW_FINGER_IN=0 | ||
- | ALLOW_FINGER_OUT=0 | ||
- | ALLOW_FTP_IN=1 | ||
- | ALLOW_FTP_OUT=1 | ||
- | ALLOW_HTTP_IN=1 | ||
- | ALLOW_HTTP_OUT=1 | ||
- | ALLOW_HTTPS_IN=1 | ||
- | ALLOW_HTTP_OUT=1 | ||
- | ALLOW_HTTPS_IN=1 | ||
- | ALLOW_HTTPS_OUT=1 | ||
- | ALLOW_ICMP_PARAM_PROBLEM_IN=0 | ||
- | ALLOW_IDENT_IN=1 | ||
- | ALLOW_IDENT_OUT=1 | ||
- | ALLOW_IMAP_IN=1 | ||
- | ALLOW_IMAP_OUT=1 | ||
- | ALLOW_IMAPS_IN=1 | ||
- | ALLOW_IMAPS_OUT=1 | ||
- | ALLOW_IRC_IN=0 | ||
- | ALLOW_IRC_OUT=0 | ||
- | ALLOW_KAZAA_IN=0 | ||
- | ALLOW_KAZAA_OUT=0 | ||
- | ALLOW_KPASSWD_IN=0 | ||
- | ALLOW_KPASSWD_OUT=0 | ||
- | ALLOW_KRB5_IN=0 | ||
- | ALLOW_KRB5_OUT=0 | ||
- | ALLOW_LDAP_IN=0 | ||
- | ALLOW_LDAP_OUT=0 | ||
- | ALLOW_LDAPS_IN=0 | ||
- | ALLOW_LDAPS_OUT=0 | ||
- | ALLOW_LINUX_CONF_IN=0 | ||
- | ALLOW_LINUX_CONF_OUT=0 | ||
- | ALLOW_LINUX_MOUNTD_BUG_IN=0 | ||
- | ALLOW_LINUX_MOUNTD_BUG_OUT=0 | ||
- | ALLOW_MS_EXCHANGE_IN=0 | ||
- | ALLOW_MS_EXCHANGE_OUT=0 | ||
- | ALLOW_MS_FILE_SERVER_FOR_MACINTOSH_IN=0 # 548 Enables Macintosh computer users to store and access files on a computer running Windows Server 2003. | ||
- | ALLOW_MS_FILE_SERVER_FOR_MACINTOSH_OUT=0 # 548 Enables Macintosh computer users to store and access files on a computer running Windows Server 2003 | ||
- | ALLOW_MS_FT_DS_IN=0 | ||
- | ALLOW_MS_FT_DS_OUT=0 | ||
- | ALLOW_MS_RPC_IN=0 | ||
- | ALLOW_MS_RPC_OUT=0 | ||
- | ALLOW_MS_RPC_OVER_HTTP_IN=0 | ||
- | ALLOW_MS_RPC_OVER_HTTP_OUT=0 | ||
- | ALLOW_MSSQL_IN=0 | ||
- | ALLOW_MSSQL_OUT=0 | ||
- | ALLOW_MSSQL_MONITOR_IN=0 | ||
- | ALLOW_MSSQL_MONITOR_OUT=0 | ||
- | ALLOW_MYSQL_IN=0 | ||
- | ALLOW_MYSQL_OUT=0 | ||
- | ALLOW_NC_IN=0 | ||
- | ALLOW_NC_OUT=0 | ||
- | ALLOW_NCP_IN=0 | ||
- | ALLOW_NCP_OUT=0 | ||
- | ALLOW_NETWORK_LOG_CLIENT_IN=0 | ||
- | ALLOW_NETWORK_LOG_CLIENT_OUT=0 | ||
- | ALLOW_NFS_IN=0 | ||
- | ALLOW_NFS_OUT=0 | ||
- | ALLOW_NNTP_IN=0 | ||
- | ALLOW_NNTP_OUT=0 | ||
- | ALLOW_NTP_IN=1 | ||
- | ALLOW_NTP_OUT=1 | ||
- | ALLOW_OPENVPN_IN=0 | ||
- | ALLOW_OPENVPN_OUT=0 | ||
- | ALLOW_PCANYWHERE_IN=0 | ||
- | ALLOW_PCANYWHERE_OUT=0 | ||
- | ALLOW_PC_SERVER_BACKDOOR_IN=0 | ||
- | ALLOW_PC_SERVER_BACKDOOR_OUT=0 | ||
- | ALLOW_PHASE_ZERO_IN=0 | ||
- | ALLOW_PHASE_ZERO_OUT=0 | ||
- | ALLOW_PING_IN=0 | ||
- | ALLOW_PING_OUT=1 | ||
- | ALLOW_PLESK_IN=0 | ||
- | ALLOW_PLESK_OUT=0 | ||
- | ALLOW_POP2_IN=0 | ||
- | ALLOW_POP2_OUT=0 | ||
- | ALLOW_POP3_IN=1 | ||
- | ALLOW_POP3_OUT=1 | ||
- | ALLOW_POP3S_IN=1 | ||
- | ALLOW_POP3S_OUT=1 | ||
- | ALLOW_POSTGRESQL_IN=0 | ||
- | ALLOW_POSTGRESQL_OUT=0 | ||
- | ALLOW_PRINT_IN=0 »»·»· | ||
- | ALLOW_PRINT_OUT=0 »·»·»· | ||
- | ALLOW_REAL_SERVER_IN=0 | ||
- | ALLOW_REAL_SERVER_OUT=0 | ||
- | ALLOW_ROUTE_IN=0 | ||
- | ALLOW_ROUTE_OUT=0 | ||
- | ALLOW_RWHO_IN=0 | ||
- | ALLOW_RWHO_OUT=0 | ||
- | ALLOW_RWHOIS_IN=1 | ||
- | ALLOW_RWHOIS_OUT=1 | ||
- | ALLOW_SAMBA_IN=1 | ||
- | ALLOW_SAMBA_OUT=1 | ||
- | ALLOW_SGI_IRIX_TCPMUX_IN=0 | ||
- | ALLOW_SGI_IRIX_TCPMUX_OUT=0 | ||
- | ALLOW_SMTP_IN=1 »·»·»· | ||
- | ALLOW_SMTP_OUT=1 »»·»· | ||
- | ALLOW_SMTPS_IN=0 | ||
- | ALLOW_SMTPS_OUT=0 | ||
- | ALLOW_SNMP_IN=0 | ||
- | ALLOW_SNMP_OUT=0 | ||
- | ALLOW_SOCKS5_IN=0 | ||
- | ALLOW_SOCKS5_OUT=0 | ||
- | ALLOW_SSH_IN=1 | ||
- | ALLOW_SSH_OUT=1 | ||
- | ALLOW_SQL_IN=0 | ||
- | ALLOW_SQL_OUT=0 | ||
- | ALLOW_SQUID_IN=0 »»·»· | ||
- | ALLOW_SQUID_OUT=0 »·»·»· | ||
- | ALLOW_SUB7_IN=0 | ||
- | ALLOW_SUB7_OUT=0 | ||
- | ALLOW_SUBMISSION_IN=1 | ||
- | ALLOW_SUBMISSION_OUT=1 | ||
- | ALLOW_SUNRPC_IN=0 | ||
- | ALLOW_SUNRPC_OUT=0 | ||
- | ALLOW_SVN_IN=0 | ||
- | ALLOW_SVN_OUT=0 | ||
- | ALLOW_TELNET_IN=0 | ||
- | ALLOW_TELNET_OUT=0 | ||
- | ALLOW_TFTP_IN=0 | ||
- | ALLOW_TFTP_OUT=0 | ||
- | ALLOW_TIME_IN=0 | ||
- | ALLOW_TIME_OUT=0 | ||
- | ALLOW_TIME_SERVER_IN=0 | ||
- | ALLOW_TIME_SERVER_OUT=0 | ||
- | ALLOW_TOMCAT_IN=0 | ||
- | ALLOW_TOMCAT_OUT=0»·»·»· | ||
- | ALLOW_TOR_OUT=0 | ||
- | ALLOW_TRACEROUTE_IN=0 | ||
- | ALLOW_TRACEROUTE_OUT=1 | ||
- | ALLOW_UNIX_SYSSTAT_IN=0 | ||
- | ALLOW_UNIX_SYSSTAT_OUT=0 | ||
- | ALLOW_UPNP_IN=0 | ||
- | ALLOW_UPNP_OUT=0 | ||
- | ALLOW_WEBLOGIN_IN=1 | ||
- | ALLOW_WEBLOGIN_OUT=0 | ||
- | ALLOW_WHOIS_IN=1 »»·»· | ||
- | ALLOW_WHOIS_OUT=1 »·»·»· | ||
- | ALLOW_WINDOWS_MESSAGE_IN=0 | ||
- | ALLOW_WINDOWS_MESSAGE_IN=0 | ||
- | ALLOW_TRACEROUTE_IN=1 | ||
- | ALLOW_TRACEROUTE_OUT=1 | ||
- | ALLOW_XDMCP_IN=0 | ||
- | ALLOW_XDMCP_OUT=0 | ||
- | ALLOW_XWINDOWS_IN=0 | ||
- | ALLOW_XWINDOWS_OUT=0 | ||
- | ALLOW_XWINDOWS_FONTSERVER_IN=0 | ||
- | ALLOW_XWINDOWS_FONTSERVER_OUT=0 | ||
- | |||
- | BLOCK_AKAMAI=1 | ||
- | BLOCK_BROADCASTS=1 | ||
- | BLOCK_BRUTE_FORCE_ATTACKS=1 | ||
- | BLOCK_CONNECTIONS_COUNT=1 | ||
- | BLOCK_DROPBOX_LAN_SYNC_BROADCASTS=1 | ||
- | BLOCK_FACEBOOK=0 | ||
- | BLOCK_FLOODS=1 | ||
- | BLOCK_SAMBA_WITHOUT_LOGGING=0 | ||
- | BLOCK_OVERSIZE_ICMP_PACKETS=1 | ||
- | BLOCK_VIRUSES=1 | ||
- | |||
- | DO_BAD_PACKETS_LAST=0 »·»·»· | ||
- | DO_KERNEL_SECURE=1 »»·»· | ||
- | DO_LOG_SCANS=1 »»·»·»· | ||
- | DO_MASQUERADE=0 »·»·»· | ||
- | DO_PORT_KNOCKING=0 »»·»· | ||
- | DO_QUICK_NTP=0 »»·»·»· | ||
- | DO_QUOTA=0 | ||
- | DO_REJECT_INSTEAD_OF_DROP=0 | ||
- | DO_STEALTH_ALL_IN=0 | ||
- | DO_WHITELISTING=0 »·»·»· | ||
- | # | ||
- | |||
- | # | ||
- | # | ||
- | # /proc sysctl settings | ||
- | # | ||
- | PROC_SYSCTL_IP_FORWARD=1»·»· | ||
- | PROC_SYSCTL_BLOCK_ALL_PINGS_IN=1 | ||
- | PROC_SYSCTL_BLOCK_BROADCAST_PINGS_IN=1 # Don't respond to broadcast pings (smurf) | ||
- | PROC_SYSCTL_ICMP_ERROR_MESG=1»»· | ||
- | PROC_SYSCTL_LOG_MARTIANS=1»·»· | ||
- | PROC_SYSCTL_IP_SPOOFING=1»»· | ||
- | PROC_SYSCTL_REDUCE_DOS=1»·»· | ||
- | PROC_SYSCTL_SYN_COOKIES=1»»· | ||
- | PROC_SYSCTL_TIME_STAMPS=1»»· | ||
- | PROC_SYSCTL_SOURCE_ROUTED=1»»· | ||
- | PROC_SYSCTL_ACCEPT_REDIRECTS=1»·»· | ||
- | PROC_SYSCTL_SEND_REDIRECTS=1»·»· | ||
- | PROC_SYSCTL_SECURE_REDIRECTS=1»·»· | ||
- | PROC_SYSCTL_DISABLE_BOOTP_RELAY=1 | ||
- | PROC_SYSCTL_DISABLE_PROXY_ARP=1 | ||
- | # | ||
- | |||
- | # | ||
- | # Trusted hosts | ||
- | # | ||
- | # Hosts that are auto allowed into the system if WhiteListing | ||
- | # is allowed. | ||
- | # | ||
- | TRUSTED_HOSTS=" | ||
- | UNTRUSTED_HOSTS=" | ||
- | # | ||
- | # | ||
- | |||
- | # | ||
- | # Port Knocking | ||
- | # | ||
- | # Port knocking is a method of externally opening ports on a firewall by· | ||
- | # generating a connection attempt on a set of prespecified closed ports. | ||
- | # | ||
- | # Once a correct sequence of connection attempts is received, the firewall· | ||
- | # rules are dynamically modified to allow the host which sent the connection· | ||
- | # attempts to connect over specific port(s). | ||
- | # | ||
- | PORT_KNOCK_1=" | ||
- | PORT_KNOCK_2=" | ||
- | PORT_KNOCK_3=" | ||
- | PORT_KNOCK_ALLOW=" | ||
- | # | ||
- | |||
- | # | ||
- | # Websites to stop | ||
- | # | ||
- | # | ||
- | # | ||
- | |||
- | # | ||
- | # Connection limits | ||
- | # | ||
- | # Against brute-force attacks. | ||
- | # | ||
- | # 4 connect/ | ||
- | # Offense #1 10 min 30 min 1 hour 2 hours 3 hours | ||
- | # Offense #2 30 min 1 hour 2 hours 3 hours 6 hours·· | ||
- | # Offense #3 1 hour 2 hours 3 hours 6 hours 1 day· | ||
- | # Offense #4 2 hours 3 hours 6 hours 1 day 1 week | ||
- | # Offense #5 3 hours 6 hours 1 day 1 week 1 month | ||
- | # Offense #6 6 hours 1 day 1 week 1 month 1 month· | ||
- | # Offense #7 1 day 1 week 1 month 1 month 1 month | ||
- | # Offense #8 1 week 1 month 1 month 1 month 1 month | ||
- | # Offense #9 1 month 1 month 1 month 1 month 1 month | ||
- | # | ||
- | CONNECTION_MAX_1=4 | ||
- | CONNECTION_MAX_2=5 | ||
- | CONNECTION_MAX_3=10 | ||
- | CONNECTION_MAX_4=25 | ||
- | CONNECTION_MAX_5=50 | ||
- | CONNECTION_MAX_6=75 | ||
- | CONNECTION_MAX_7=100 | ||
- | CONNECTION_MAX_8=200 | ||
- | CONNECTION_MAX_9=255 | ||
- | # | ||
- | CONNECTION_LIMIT_1=60 | ||
- | CONNECTION_LIMIT_2=180 | ||
- | CONNECTION_LIMIT_3=600 | ||
- | CONNECTION_LIMIT_4=1200 | ||
- | CONNECTION_LIMIT_5=2400 | ||
- | CONNECTION_LIMIT_6=3600 | ||
- | CONNECTION_LIMIT_7=7200 | ||
- | CONNECTION_LIMIT_8=10800 | ||
- | CONNECTION_LIMIT_9=21600 | ||
- | # | ||
- | # Offence timeouts | ||
- | CONNECTION_TIMEOUT_1=600 | ||
- | CONNECTION_TIMEOUT_2=1800 | ||
- | CONNECTION_TIMEOUT_3=3600 | ||
- | CONNECTION_TIMEOUT_4=7200 | ||
- | CONNECTION_TIMEOUT_5=10800 | ||
- | CONNECTION_TIMEOUT_6=21600 | ||
- | CONNECTION_TIMEOUT_7=86400 | ||
- | CONNECTION_TIMEOUT_8=604800 | ||
- | CONNECTION_TIMEOUT_9=2635200 | ||
- | |||
- | |||
- | # | ||
- | # Log limit | ||
- | # | ||
- | LOG_LEVEL=7 | ||
- | # | ||
- | # | ||
- | # | ||
- | # | ||
- | |||
- | # | ||
- | # String Search Algorith | ||
- | # | ||
- | STRING_ALGO=" | ||
- | STRING_ALGO2=" | ||
- | # | ||
- | |||
- | # | ||
- | # Quota limits | ||
- | # | ||
- | QUOTA_LIMIT_TCP=" | ||
- | QUOTA_LIMIT_UDP=" | ||
- | QUOTA_LIMIT_ICMP=" | ||
- | # | ||
- | |||
- | # | ||
- | # DNS limits | ||
- | # | ||
- | # Limits the number of DNS queries per second to 5/s | ||
- | # with a burst rate of 15/s and does not require buffer space changes. | ||
- | # | ||
- | # Limit the requests per second to 5, which leads to 35 requests in 7 seconds. | ||
- | # To solve the first-second burst, allow for 15 requests to happen in each of· | ||
- | # the seven seconds. | ||
- | |||
- | # DNS open time. | ||
- | DNS_TIMEOUT=" | ||
- | |||
- | # DNS Requests per second | ||
- | DNS_BURST=" | ||
- | |||
- | # DNS Requests per 7 seconds | ||
- | DNS_TOTAL_REQUESTS=" | ||
- | # | ||
- | |||
- | # | ||
- | # Flooding limits | ||
- | # | ||
- | # | ||
- | # Limit per second | ||
- | LIMIT_PER_SECOND=" | ||
- | # | ||
- | |||
- | # Limit for SYN connections | ||
- | LIMIT_SYN_MAX=" | ||
- | # | ||
- | |||
- | # Limit for SYN-Flood detection | ||
- | LIMIT_SYN=" | ||
- | # | ||
- | |||
- | # | ||
- | # Burst Limit for SYN-Flood detection | ||
- | LIMIT_SYN_BURST=" | ||
- | # | ||
- | |||
- | # | ||
- | # Overall Limit for Logging in Logging-Chains | ||
- | LIMIT_LOG=" | ||
- | # | ||
- | |||
- | # | ||
- | # Burst Limit for Logging in Logging-Chains | ||
- | LIMIT_LOG_BURST=" | ||
- | # | ||
- | |||
- | # | ||
- | # Overall Limit for TCP-Flood-Detection | ||
- | LIMIT_TCP=" | ||
- | # | ||
- | |||
- | # | ||
- | # Burst Limit for TCP-Flood-Detection | ||
- | LIMIT_TCP_BURST=" | ||
- | # | ||
- | |||
- | # | ||
- | # Overall Limit for UDP-Flood-Detection | ||
- | LIMIT_UDP=" | ||
- | # | ||
- | |||
- | # | ||
- | # Burst Limit for TCP-Flood-Detection | ||
- | LIMIT_UDP_BURST=" | ||
- | # | ||
- | |||
- | # | ||
- | # Overall Limit for Ping-Flood-Detection | ||
- | LIMIT_PING=" | ||
- | # | ||
- | |||
- | # | ||
- | # Burst Limit for Ping-Flood-Detection | ||
- | LIMIT_PING_BURST=" | ||
- | # | ||
- | |||
- | # | ||
- | #********** Do not edit beyond this line ********** | ||
- | # | ||
- | |||
- | # | ||
- | # IP Mask for all IP addresses | ||
- | PORTS_UNIVERSE=" | ||
- | PORTS_BROADCAST=" | ||
- | # | ||
- | |||
- | # | ||
- | # Ports for Dropbox Lan Sync Broadcasts | ||
- | PORTS_DROPBOX_LAN_SYNC_BROADCASTS=" | ||
- | # | ||
- | |||
- | # | ||
- | # Ports for IRC-Connection-Tracking | ||
- | PORTS_IRC=" | ||
- | # | ||
- | |||
- | # | ||
- | # Ports for TOR | ||
- | # (http:// | ||
- | PORTS_TOR=" | ||
- | # | ||
- | |||
- | # | ||
- | # Ports for traceroute | ||
- | PORTS_TRACEROUTE_SRC=" | ||
- | PORTS_TRACEROUTE_DEST=" | ||
- | # | ||
- | |||
- | # | ||
- | # Specification of the high unprivileged IP ports. | ||
- | PORTS_UNPRIV=" | ||
- | PORTS_PSSH=" | ||
- | # | ||
- | |||
- | # | ||
- | # Specification of X Window System (TCP) | ||
- | PORTS_XWIN=" | ||
- | # | ||
- | |||
- | # | ||
- | # AKAMAI· | ||
- | # | ||
- | # http:// | ||
- | # | ||
- | RANGE_AKAMAI=" | ||
- | RANGE_AKAMAI=" | ||
- | RANGE_AKAMAI=" | ||
- | |||
- | # | ||
- | # IANA RESERVED· | ||
- | # | ||
- | RANGE_IANA_RESERVED=" | ||
- | RANGE_IANA_RESERVED=" | ||
- | RANGE_IANA_RESERVED=" | ||
- | RANGE_IANA_RESERVED=" | ||
- | # | ||
- | |||
- | # | ||
- | # Mitigate ARP spoofing/ | ||
- | # | ||
- | # Hardcode static ARP cache entries here | ||
- | # $ARP -s IP-ADDRESS MAC-ADDRESS | ||
- | # | ||
- | |||
- | # | ||
- | # Delete all existing rules | ||
- | # | ||
- | $IPTABLES -F | ||
- | $IPTABLES -t nat -F | ||
- | $IPTABLES -t mangle -F | ||
- | $IPTABLES -X | ||
- | $IPTABLES -t nat -X | ||
- | $IPTABLES -t mangle -X | ||
- | # | ||
- | |||
- | # | ||
- | # Zero all packets and counters. | ||
- | # | ||
- | $IPTABLES -Z | ||
- | $IPTABLES -t nat -Z | ||
- | $IPTABLES -t mangle -Z | ||
- | |||
- | # | ||
- | # Set Policies | ||
- | # By default, drop everything except outgoing traffic | ||
- | # | ||
- | $IPTABLES -P INPUT DROP | ||
- | $IPTABLES -P FORWARD DROP | ||
- | $IPTABLES -P OUTPUT DROP | ||
- | # | ||
- | |||
- | # Set the nat/ | ||
- | $IPTABLES -t nat -P PREROUTING ACCEPT | ||
- | $IPTABLES -t nat -P OUTPUT ACCEPT | ||
- | $IPTABLES -t nat -P POSTROUTING ACCEPT | ||
- | |||
- | $IPTABLES -t mangle -P PREROUTING ACCEPT | ||
- | $IPTABLES -t mangle -P INPUT ACCEPT | ||
- | $IPTABLES -t mangle -P FORWARD ACCEPT | ||
- | $IPTABLES -t mangle -P OUTPUT ACCEPT | ||
- | $IPTABLES -t mangle -P POSTROUTING ACCEPT | ||
- | |||
- | #if [ $BLOCK_BROADCASTS -eq 1 ] | ||
- | #then | ||
- | #$IPTABLES -A INPUT DROP | ||
- | #$IPTABLES -A INPUT -d $INET_BCAST -i INET_IFACE -j DROP | ||
- | #$IPTABLES -A INPUT -d 192.168.255.255 | ||
- | #$IPTABLES -A INPUT -d 255.255.255.255 -i INET_IFACE -j DROP | ||
- | #$IPTABLES -A INPUT -m pkttype --pkt-type broadcast -j DROP | ||
- | #fi | ||
- | |||
- | # | ||
- | # | ||
- | # Kernel configuration. | ||
- | # For details see: | ||
- | # * http:// | ||
- | # * http:// | ||
- | # * http:// | ||
- | # * / | ||
- | # * / | ||
- | # | ||
- | # Save these settings in the / | ||
- | # | ||
- | # | ||
- | if [ $DO_KERNEL_SECURE -eq 1 ] | ||
- | then | ||
- | |||
- | # | ||
- | # Allow port forwarding - Enable IP NAT in the Linux kernel | ||
- | # | ||
- | #echo 1 > / | ||
- | if [ $PROC_SYSCTL_IP_FORWARD -eq 1 ] ; then | ||
- | if [ -f / | ||
- | echo 1 > / | ||
- | echo " | ||
- | fi | ||
- | fi | ||
- | # | ||
- | |||
- | # | ||
- | # Disabling IP Spoofing | ||
- | # | ||
- | #echo 2 > / | ||
- | if [ $PROC_SYSCTL_IP_SPOOFING -eq 1 ] ; then | ||
- | if [ -f / | ||
- | echo " | ||
- | echo " | ||
- | fi | ||
- | # | ||
- | |||
- | # | ||
- | # Enable IP spoofing protection (i.e. source address verification). | ||
- | # Note: This is special, as it seems to only be enabled if you set | ||
- | # */ | ||
- | # */ | ||
- | # | ||
- | # Turn on reverse path filtering. This helps make sure that packets use· | ||
- | # legitimate source addresses, by automatically rejecting incoming packets· | ||
- | # if the routing table entry for their source address doesn' | ||
- | # network interface they' | ||
- | # it prevents so-called IP spoofing, however it can pose problems if you use· | ||
- | # asymmetric routing (packets from you to a host take a different path than· | ||
- | # packets from that host to you) or if you operate a non-routing host which· | ||
- | # has several IP addresses on different interfaces.· | ||
- | # (Note - If you turn on IP forwarding, you will also get this). | ||
- | # | ||
- | for i in / | ||
- | # | ||
- | fi | ||
- | # | ||
- | |||
- | # | ||
- | # Ignore all incoming ICMP echo requests (i.e. disable ping). | ||
- | # Usually not a good idea, as some protocols and users need/want this. | ||
- | # echo 1 > / | ||
- | # | ||
- | if [ $PROC_SYSCTL_BLOCK_ALL_PINGS_IN -eq 1 ] | ||
- | then | ||
- | #echo 1 > / | ||
- | if [ -f / | ||
- | echo " | ||
- | echo " | ||
- | fi | ||
- | else | ||
- | #echo 0 > / | ||
- | if [ -f / | ||
- | echo " | ||
- | echo " | ||
- | fi | ||
- | fi | ||
- | # | ||
- | |||
- | # | ||
- | # Don't respond to broadcast pings | ||
- | # Ignore ICMP echo requests to broadcast/ | ||
- | # want to participate in smurf (and similar) DoS attacks. | ||
- | # For details see: http:// | ||
- | # | ||
- | if [ $PROC_SYSCTL_BLOCK_BROADCAST_PINGS_IN -eq 1 ] | ||
- | then | ||
- | #echo 1 > / | ||
- | if [ -f / | ||
- | echo " | ||
- | echo " | ||
- | fi | ||
- | else | ||
- | #echo 0 > / | ||
- | if [ -f / | ||
- | echo " | ||
- | echo " | ||
- | fi | ||
- | fi | ||
- | # | ||
- | |||
- | # | ||
- | # Disable multicast routing. Should not be needed, usually. | ||
- | # TODO: This throws an " | ||
- | # | ||
- | # The proc entry containing that value is read-only, and cannot be made writable easily. | ||
- | # | ||
- | #for i in / | ||
- | # | ||
- | |||
- | # | ||
- | # Protect against SYN flood attacks (see http:// | ||
- | # | ||
- | #echo 1 > / | ||
- | if [ $PROC_SYSCTL_SYN_COOKIES -eq 1 ] ; then | ||
- | if [ -e / | ||
- | echo " | ||
- | echo " | ||
- | fi | ||
- | fi | ||
- | # | ||
- | |||
- | # | ||
- | # Kill timestamps | ||
- | # | ||
- | #echo 0 > / | ||
- | if [ $PROC_SYSCTL_TIME_STAMPS -eq 1 ] ; then | ||
- | if [ -e / | ||
- | echo " | ||
- | echo " | ||
- | fi | ||
- | fi | ||
- | # | ||
- | |||
- | # | ||
- | # Block source routing | ||
- | # | ||
- | # Don't accept source routed packets. | ||
- | # to generate traffic pretending to be from inside your network, but· | ||
- | # which is routed back along the path from which it came, namely outside,· | ||
- | # so attackers can compromise your network. | ||
- | # used for legitimate purposes. | ||
- | # | ||
- | #echo 0 > / | ||
- | if [ $PROC_SYSCTL_SOURCE_ROUTED -eq 1 ] ; then | ||
- | if [ -e / | ||
- | echo " | ||
- | echo " | ||
- | fi | ||
- | # | ||
- | |||
- | # | ||
- | # Don't accept source routed packets. | ||
- | # | ||
- | for i in / | ||
- | # | ||
- | fi | ||
- | # | ||
- | |||
- | # | ||
- | # Kill redirects | ||
- | # | ||
- | # Disable ICMP redirect acceptance. ICMP redirects can be used to alter· | ||
- | # your routing tables, possibly to a bad end. | ||
- | # | ||
- | #echo 0 > / | ||
- | #echo 0 > / | ||
- | if [ $PROC_SYSCTL_ACCEPT_REDIRECTS -eq 1 ] ; then | ||
- | if [ -e / | ||
- | echo " | ||
- | echo " | ||
- | fi | ||
- | |||
- | for i in / | ||
- | fi | ||
- | # | ||
- | if [ $PROC_SYSCTL_SEND_REDIRECTS -eq 1 ] ; then | ||
- | if [ -e / | ||
- | echo " | ||
- | echo " | ||
- | fi | ||
- | |||
- | for i in / | ||
- | fi | ||
- | # | ||
- | |||
- | # | ||
- | # Don't accept or send ICMP redirects. | ||
- | # | ||
- | #for i in / | ||
- | #for i in / | ||
- | # | ||
- | |||
- | # | ||
- | # Enable secure redirects, i.e. only accept ICMP redirects for gateways | ||
- | # listed in the default gateway list. Helps against MITM attacks. | ||
- | # | ||
- | #for i in / | ||
- | if [ $PROC_SYSCTL_SECURE_REDIRECTS -eq 1 ] ; then | ||
- | for i in / | ||
- | fi | ||
- | # | ||
- | # | ||
- | |||
- | # | ||
- | # Enable bad error message protection | ||
- | # Don't log invalid responses to broadcast frames, they just clutter the logs. | ||
- | # | ||
- | #echo 1 > / | ||
- | if [ $PROC_SYSCTL_ICMP_ERROR_MESG -eq 1 ] ; then | ||
- | if [ -f / | ||
- | echo " | ||
- | echo " | ||
- | fi | ||
- | fi | ||
- | # | ||
- | |||
- | # | ||
- | # Log martians | ||
- | # | ||
- | # Log packets with impossible addresses | ||
- | # Log spoofed packets, source routed packets, redirect packets. | ||
- | # | ||
- | #echo 1 > / | ||
- | if [ $PROC_SYSCTL_LOG_MARTIANS -eq 1 ] ; then | ||
- | if [ -f / | ||
- | echo " | ||
- | echo " | ||
- | fi | ||
- | # | ||
- | |||
- | # | ||
- | # Log packets with impossible addresses. | ||
- | # | ||
- | for i in / | ||
- | # | ||
- | fi | ||
- | # | ||
- | |||
- | # | ||
- | # Disable bootp_relay. Should not be needed, usually. | ||
- | # | ||
- | if [ $PROC_SYSCTL_DISABLE_BOOTP_RELAY -eq 1 ] ; then | ||
- | for i in / | ||
- | fi | ||
- | # | ||
- | |||
- | # | ||
- | # Disable proxy_arp. Should not be needed, usually. | ||
- | # | ||
- | if [ $PROC_SYSCTL_DISABLE_PROXY_ARP -eq 1 ] ; then | ||
- | for i in / | ||
- | fi | ||
- | # | ||
- | |||
- | # | ||
- | # TODO: These may mitigate ARP poisoning attacks? | ||
- | # / | ||
- | # / | ||
- | # TODO: Check rest of / | ||
- | # Are there any security-relevant options I missed? Check especially: | ||
- | # icmp_ratelimit, | ||
- | # | ||
- | |||
- | # | ||
- | # Set out local port range | ||
- | # | ||
- | #echo "32768 61000" > / | ||
- | # | ||
- | |||
- | # | ||
- | # Reduce timeouts for DoS protection | ||
- | # | ||
- | #echo 30 > / | ||
- | # | ||
- | |||
- | # | ||
- | # Other | ||
- | # | ||
- | #echo 2400 > / | ||
- | #echo 0 > / | ||
- | #echo 0 > / | ||
- | # | ||
- | if [ $PROC_SYSCTL_REDUCE_DOS -eq 1 ] ; then | ||
- | echo " | ||
- | echo " | ||
- | echo " | ||
- | echo " | ||
- | echo " | ||
- | fi | ||
- | |||
- | # | ||
- | fi | ||
- | # | ||
- | |||
- | # | ||
- | # | ||
- | # Completely disable IPv6. | ||
- | # | ||
- | # Block all IPv6 traffic | ||
- | # | ||
- | # | ||
- | # If the ip6tables command is available, try to block all IPv6 traffic. | ||
- | # | ||
- | if test -x $IP6TABLES; then | ||
- | |||
- | # | ||
- | # Set the default policies. | ||
- | # Drop everything. | ||
- | $IP6TABLES -P INPUT DROP 2>/ | ||
- | $IP6TABLES -P FORWARD DROP 2>/ | ||
- | $IP6TABLES -P OUTPUT DROP 2>/ | ||
- | |||
- | # | ||
- | # The mangle table can pass everything. | ||
- | $IP6TABLES -t mangle -P PREROUTING ACCEPT 2>/ | ||
- | $IP6TABLES -t mangle -P INPUT ACCEPT 2>/ | ||
- | $IP6TABLES -t mangle -P FORWARD ACCEPT 2>/ | ||
- | $IP6TABLES -t mangle -P OUTPUT ACCEPT 2>/ | ||
- | $IP6TABLES -t mangle -P POSTROUTING ACCEPT 2>/ | ||
- | |||
- | # | ||
- | # Delete all rules. | ||
- | $IP6TABLES -F 2>/ | ||
- | $IP6TABLES -t mangle -F 2>/ | ||
- | |||
- | # | ||
- | # Delete all chains. | ||
- | $IP6TABLES -X 2>/ | ||
- | $IP6TABLES -t mangle -X 2>/ | ||
- | |||
- | # | ||
- | # Zero all packets and counters. | ||
- | $IP6TABLES -Z 2>/ | ||
- | $IP6TABLES -t mangle -Z 2>/ | ||
- | |||
- | fi | ||
- | |||
- | # | ||
- | # Shellshock | ||
- | $IP6TABLES -A INPUT -m string --algo bm --hex-string '|28 29 20 7B|' -j DROP | ||
- | $IP6TABLES -A INPUT -m string --algo bm --hex-string '|28 29 20 7B|' -j DROP | ||
- | |||
- | # | ||
- | # | ||
- | # Create the chains | ||
- | # | ||
- | $IPTABLES -N IANA_RESERVED | ||
- | $IPTABLES -N BAD_PACKETS | ||
- | $IPTABLES -N BAD_TCP_PACKETS | ||
- | |||
- | if [ $DO_WHITELISTING -eq 1 ] | ||
- | then | ||
- | $IPTABLES -N WHITELIST | ||
- | fi | ||
- | |||
- | if [ $DO_PORT_KNOCKING -eq 1 ] | ||
- | then | ||
- | $IPTABLES -N PORT_KNOCK | ||
- | $IPTABLES -N PORT_KNOCK_STAGE1 | ||
- | $IPTABLES -N PORT_KNOCK_STAGE2 | ||
- | $IPTABLES -N PORT_KNOCK_STAGE3 | ||
- | fi | ||
- | |||
- | $IPTABLES -N PRIVATE_PACKETS | ||
- | $IPTABLES -N BLACKLIST | ||
- | |||
- | if [ $BLOCK_BRUTE_FORCE_ATTACKS -eq 1 ] | ||
- | then | ||
- | $IPTABLES -N ATTACK | ||
- | $IPTABLES -N ATTACK2 | ||
- | $IPTABLES -N ATTACK_CHECK | ||
- | $IPTABLES -N ATTACKED1 | ||
- | $IPTABLES -N ATTACKED2 | ||
- | $IPTABLES -N ATTACKED3 | ||
- | $IPTABLES -N ATTACKED4 | ||
- | $IPTABLES -N ATTACKED5 | ||
- | $IPTABLES -N ATTACKED6 | ||
- | $IPTABLES -N ATTACKED7 | ||
- | $IPTABLES -N ATTACKED8 | ||
- | $IPTABLES -N ATTACKED9 | ||
- | $IPTABLES -N BAN1 | ||
- | $IPTABLES -N BAN2 | ||
- | $IPTABLES -N BAN3 | ||
- | $IPTABLES -N BAN4 | ||
- | $IPTABLES -N BAN5 | ||
- | $IPTABLES -N BAN6 | ||
- | $IPTABLES -N BAN7 | ||
- | $IPTABLES -N BAN8 | ||
- | $IPTABLES -N BAN9 | ||
- | fi | ||
- | |||
- | |||
- | if [ $BLOCK_FLOODS -eq 1 ] | ||
- | then | ||
- | $IPTABLES -N FLOODS | ||
- | fi | ||
- | |||
- | if [ $BLOCK_VIRUSES -eq 1 ] | ||
- | then | ||
- | $IPTABLES -N VIRUS | ||
- | fi | ||
- | |||
- | if [ $DO_LOG_SCANS -eq 1 ] | ||
- | then | ||
- | $IPTABLES -N SCANS | ||
- | fi | ||
- | |||
- | $IPTABLES -N ICMP_IN | ||
- | $IPTABLES -N ICMP_OUT | ||
- | $IPTABLES -N TCP_IN | ||
- | $IPTABLES -N TCP_OUT | ||
- | $IPTABLES -N UDP_IN | ||
- | $IPTABLES -N UDP_OUT | ||
- | $IPTABLES -N NO_LOGGING | ||
- | |||
- | if [ $DO_QUOTA -eq 1 ] | ||
- | then | ||
- | $IPTABLES -N QUOTA | ||
- | fi | ||
- | # | ||
- | |||
- | # | ||
- | # Check Quotas | ||
- | # | ||
- | if [ $DO_QUOTA -eq 1 ] | ||
- | then | ||
- | $IPTABLES -A QUOTA -p tcp -m quota --quota $QUOTA_LIMIT_TCP -j RETURN | ||
- | $IPTABLES -A QUOTA -p udp -m quota --quota $QUOTA_LIMIT_UDP -j RETURN | ||
- | $IPTABLES -A QUOTA -p icmp -m quota --quota $QUOTA_LIMIT_ICMP -j RETURN | ||
- | $IPTABLES -A QUOTA -m limit --limit $LIMIT_LOG --limit-burst $LIMIT_LOG_BURST -j LOG --log-level $LOG_LEVEL --log-prefix " | ||
- | $IPTABLES -A QUOTA -j DROP | ||
- | fi | ||
- | # | ||
- | |||
- | # | ||
- | # Filter IANA RESERVED | ||
- | # | ||
- | $IPTABLES -A IANA_RESERVED -s $RANGE_IANA_RESERVED -m limit --limit $LIMIT_LOG --limit-burst $LIMIT_LOG_BURST -j LOG --log-level $LOG_LEVEL --log-prefix " | ||
- | |||
- | $IPTABLES -A IANA_RESERVED -s $RANGE_IANA_RESERVED -j DROP | ||
- | |||
- | #$IPTABLES -A IANA_RESERVED -s 0.0.0.0/7 -j DROP | ||
- | #$IPTABLES -A IANA_RESERVED -s 2.0.0.0/8 -j DROP | ||
- | #$IPTABLES -A IANA_RESERVED -s 5.0.0.0/8 -j DROP | ||
- | #$IPTABLES -A IANA_RESERVED -s 7.0.0.0/8 -j DROP | ||
- | #$IPTABLES -A IANA_RESERVED -s 10.0.0.0/8 -j DROP | ||
- | #$IPTABLES -A IANA_RESERVED -s 23.0.0.0/8 -j DROP | ||
- | #$IPTABLES -A IANA_RESERVED -s 27.0.0.0/8 -j DROP | ||
- | #$IPTABLES -A IANA_RESERVED -s 31.0.0.0/8 -j DROP | ||
- | #$IPTABLES -A IANA_RESERVED -s 36.0.0.0/7 -j DROP | ||
- | #$IPTABLES -A IANA_RESERVED -s 39.0.0.0/8 -j DROP | ||
- | #$IPTABLES -A IANA_RESERVED -s 42.0.0.0/8 -j DROP | ||
- | #$IPTABLES -A IANA_RESERVED -s 49.0.0.0/8 -j DROP | ||
- | #$IPTABLES -A IANA_RESERVED -s 50.0.0.0/8 -j DROP | ||
- | #$IPTABLES -A IANA_RESERVED -s 77.0.0.0/8 -j DROP | ||
- | #$IPTABLES -A IANA_RESERVED -s 78.0.0.0/7 -j DROP | ||
- | #$IPTABLES -A IANA_RESERVED -s 92.0.0.0/6 -j DROP | ||
- | #$IPTABLES -A IANA_RESERVED -s 96.0.0.0/4 -j DROP | ||
- | #$IPTABLES -A IANA_RESERVED -s 112.0.0.0/5 -j DROP | ||
- | #$IPTABLES -A IANA_RESERVED -s 120.0.0.0/8 -j DROP | ||
- | #$IPTABLES -A IANA_RESERVED -s 169.254.0.0/ | ||
- | #$IPTABLES -A IANA_RESERVED -s 172.16.0.0/ | ||
- | #$IPTABLES -A IANA_RESERVED -s 173.0.0.0/8 -j DROP | ||
- | #$IPTABLES -A IANA_RESERVED -s 174.0.0.0/7 -j DROP | ||
- | #$IPTABLES -A IANA_RESERVED -s 176.0.0.0/5 -j DROP | ||
- | #$IPTABLES -A IANA_RESERVED -s 184.0.0.0/6 -j DROP | ||
- | |||
- | </ |
iptables/basic_firewall.1476992730.txt.gz · Last modified: 2020/07/15 09:30 (external edit)