gaat het uitvoeren via:
sudo chmod 755 iptables.sh
sudo ./iptables.sh
is dit correct?
na reboot actief laten blijven via:
sudo nano /etc/network/interfaces
pre-up iptables-restore < /etc/iptables.rules (toevoegen)
het script:
#!/bin/bash
#Simple Firewall Script.
#Setting up default kernel tunings here (don't worry too much about these right now, they are acceptable defaults)
#DROP ICMP echo-requests sent to broadcast/multi-cast addresses.
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
#DROP source routed packets
echo 0 > /proc/sys/net/ipv4/conf/all/accept_source_route
#Enable TCP SYN cookies
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
#Do not ACCEPT ICMP redirect
echo 0 > /proc/sys/net/ipv4/conf/all/accept_redirects
#Don't send ICMP redirect
echo 0 >/proc/sys/net/ipv4/conf/all/send_redirects
#Enable source spoofing protection
echo 1 > /proc/sys/net/ipv4/conf/all/rp_filter
#Log impossible (martian) packets
echo 1 > /proc/sys/net/ipv4/conf/all/log_martians
#Flush all existing chains
iptables --flush
#Allow traffic on loopback
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
#Creating default policies
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP #If we're not a router
#Allow previously established connections to continue uninterupted
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
#Allow outbound connections on the ports we previously decided.
iptables -A OUTPUT -p tcp --dport 25 -j ACCEPT #SMTP
iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT #DNS
iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT #HTTP
iptables -A OUTPUT -p tcp --dport 110 -j ACCEPT #POP
iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT #HTTPS
iptables -A OUTPUT -p tcp --dport 465 -j ACCEPT #HTTPS
iptables -A OUTPUT -p tcp --dport 843 -j ACCEPT #HTTPS
iptables -A OUTPUT -p tcp --dport 993 -j ACCEPT #HTTPS
iptables -A OUTPUT -p tcp --dport 995 -j ACCEPT #HTTPS
iptables -A OUTPUT -p tcp --dport 1023 -j ACCEPT #HTTPS
iptables -A OUTPUT -p tcp --dport 1863 -j ACCEPT #HTTPS
iptables -A OUTPUT -p tcp --dport 4001 -j ACCEPT #HTTPS
iptables -A OUTPUT -p tcp --dport 5222 -j ACCEPT #HTTPS
iptables -A OUTPUT -p tcp --dport 6667 -j ACCEPT #HTTPS
iptables -A OUTPUT -p tcp --dport 7000 -j ACCEPT #HTTPS
iptables -A OUTPUT -p tcp --dport 7070 -j ACCEPT #HTTPS
iptables -A OUTPUT -p tcp --dport 11371 -j ACCEPT #HTTPS
iptables -A OUTPUT -p UDP --dport 67:68 -j ACCEPT #DHCP
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT #DNS
iptables -A OUTPUT -p udp --dport 123 -j ACCEPT #DNS
iptables -A OUTPUT -p udp --dport 1023 -j ACCEPT #DNS
iptables -A OUTPUT -p udp --dport 11371 -j ACCEPT #DNS
#Set up logging for incoming traffic.
iptables -N LOGNDROP
iptables -A INPUT -j LOGNDROP
iptables -A LOGNDROP -j LOG
iptables -A LOGNDROP -j DROP
#Save our firewall rules
iptables-save > /etc/iptables.rules