#6149 aqui tienes un ejemplo en el que he quitado algunos servicios "extra"
spoiler
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
iptables -F
iptables -X
#Loopback
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
#Allow ESTABLISHED incoming traffic
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
#Allow all outgoing traffic for root
iptables -A OUTPUT -m owner --uid-owner root -j ACCEPT
##################### Basic Services #####################
#DNS
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
#FTP
iptables -A OUTPUT -p tcp --dport 21 -j ACCEPT
#HTTP/HTTPS
iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT
#ICMP
iptables -A OUTPUT -p icmp -j ACCEPT
#NTP
iptables -A OUTPUT -p udp --dport 123 -j ACCEPT
#Samba
iptables -A INPUT -p udp --sport 137:138 -m conntrack --ctstate NEW -j ACCEPT
iptables -A INPUT -p tcp --sport 139 -m conntrack --ctstate NEW -j ACCEPT
iptables -A INPUT -p tcp --sport 445 -m conntrack --ctstate NEW -j ACCEPT
iptables -A OUTPUT -p udp --dport 137:138 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 139 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 445 -j ACCEPT
#SSH Default Port
iptables -A OUTPUT -p tcp --dport 22 -j ACCEPT
#SSH Custom Port
iptables -A INPUT -p tcp --dport PON_AQUI_TU_PUERTO -m conntrack --ctstate NEW -j ACCEPT
iptables -A OUTPUT -p tcp --sport PON_AQUI_TU_PUERTO -j ACCEPT
#Whois
iptables -A OUTPUT -p tcp --dport 43 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 4321 -j ACCEPT
##################### Application-based Services #####################
#Android Wifi File Transfer
iptables -A OUTPUT -d 192.168.90.0/24 -p tcp -m tcp --dport 8888 -j ACCEPT
#IRC RootedCON
iptables -A OUTPUT -p tcp --dport 9999 -j ACCEPT
#IRC Freenode
iptables -A OUTPUT -p tcp --dport 6697 -j ACCEPT
#Steam
iptables -A OUTPUT -p tcp --dport 27030:27040 -j ACCEPT
iptables -A OUTPUT -p udp --dport 27017:27020 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 27014:27020 -j ACCEPT
#DotA 2
iptables -A OUTPUT -p udp --sport 27005 -j ACCEPT
iptables -A OUTPUT -p udp --dport 27015:28999 -j ACCEPT
#Torrent
iptables -A INPUT -p tcp --dport PON_AQUI_TU_PUERTO -m conntrack --ctstate NEW -j ACCEPT
iptables -A OUTPUT -p tcp --sport PON_AQUI_TU_PUERTO -j ACCEPT
iptables -A OUTPUT -p udp --sport PON_AQUI_TU_PUERTO -j ACCEPT
##################### LOGGING #####################
iptables -N LOGGING
iptables -A INPUT -j LOGGING
iptables -A OUTPUT -j LOGGING
iptables -A LOGGING -j LOG --log-prefix "IPTables-DROP: "
iptables -A LOGGING -j DROP