Iptables Configuration Example

May 2, 2008 Linux Security | admin @ 9:06 am

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.Iptables

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.

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Sorry, the comment form is closed at this time.