Iptables Configuration Example
This example will show you for setting up linux iptables such as on the SSH Server, Web Server and exam for some service as follow.
SSH
# Allow ssh
iptables -A INPUT -i $IFACE -p tcp –sport 22 -m state –state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o $IFACE -p tcp –dport 22 -m state –state NEW,ESTABLISHED -j ACCEPT
WWW
# Allow www to 80.
iptables -A INPUT -i $IFACE -p tcp –sport 80 -m state –state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o $IFACE -p tcp –dport 80 -m state –state NEW,ESTABLISHED -j ACCEPT
# Allow www to 443.
iptables -A INPUT -i $IFACE -p tcp –sport 443 -m state –state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o $IFACE -p tcp –dport 443 -m state –state NEW,ESTABLISHED -j ACCEPT
TELNET
# Allow telnet outbound.
iptables -A INPUT -i $IFACE -p tcp –sport 23 -m state –state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o $IFACE -p tcp –dport 23 -m state –state NEW,ESTABLISHED -j ACCEPT
Note: To disallow everthing else we need to set the default policy to DROP.

















