Read teh manual.

1 iptables -F # flush existing rules
2
3 iptables -P INPUT DROP 
4 iptables -P FORWARD DROP 
5 iptables -P OUTPUT DROP 
6 
7 # first service DNS <this is accept DNS packets sent/rec from any host on any network.
8 iptables -A OUTPUT -p udp --dport 53 -d 0.0.0.0/0 -j ACCEPT 
9 iptables -A INPUT -p udp --sport 53 -s 0.0.0.0/0 -j ACCEPT 
10
11 # second service  <this is accept HTTP (web) packets sent/rec  from any host on any network.
12 iptables -A OUTPUT -p tcp --dport 80 -d 0.0.0.0/0 -j ACCEPT
13 iptables -A INPUT -p tcp --sport 80 -s 0.0.0.0/0 -j ACCEPT

Add a code snippet to your website: www.paste.org