I have sendmail installed on Ubuntu 10.04 solely for the use of the php mail() function. This works fine unless iptables is running (I've been using sendmail
[email protected] to test this).
I think that I have allowed SMTP and DNS (the script I am using to test iptables rules is below, in my version are the actual IPs of my hosts nameservers), but to no avail!
iptables --flush
iptables -A
INPUT -p tcp --dport 22 -j ACCEPT
iptables -A
INPUT -p tcp --dport 80 -j ACCEPT
iptables -A
INPUT -p tcp --dport 443 -j ACCEPT
# Postgres
iptables -A
INPUT -p tcp --dport 5432 -j ACCEPT
# Webmin
iptables -A
INPUT -p tcp --dport 10000 -j ACCEPT
# Ping
iptables -A
INPUT -p icmp --icmp-type echo-request -j ACCEPT
iptables -A OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT
# sendmail
iptables -A
INPUT -p tcp --dport 25 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 25 -m state --state ESTABLISHED -j ACCEPT
# DNS
iptables -A
INPUT -p udp --sport 53 -s <nameserver1> -j ACCEPT
iptables -A
INPUT -p udp --sport 53 -s <nameserver2> -j ACCEPT
iptables -A
INPUT -p tcp --sport 53 -s <nameserver1> -j ACCEPT
iptables -A
INPUT -p tcp --sport 53 -s <nameserver2> -j ACCEPT
iptables -A OUTPUT -p udp --dport 53 -d <nameserver1> -j ACCEPT
iptables -A OUTPUT -p udp --dport 53 -d <nameserver2> -j ACCEPT
iptables -A OUTPUT -p tcp --dport 53 -d <nameserver1> -j ACCEPT
iptables -A OUTPUT -p tcp --dport 53 -d <nameserver2> -j ACCEPT
iptables -A
INPUT -j DROP
# Add loopback
iptables -I
INPUT 1 -i lo -j ACCEPT