#!/bin/bash
#input rules
iptables -A OUTPUT -p tcp -m multiport --dports 24,25,26,50,57,105,106,109,110,143,158,209,218,220,465 -j REJECT --reject-with tcp-reset
iptables -A OUTPUT -p tcp -m multiport --dports 587,993,995,1109,24554,60177,60179 -j REJECT --reject-with tcp-reset
iptables -A OUTPUT -p udp -m multiport --dports 24,25,26,50,57,105,106,109,110,143,158,209,218,220,465 -j DROP
iptables -A OUTPUT -p udp -m multiport --dports 587,993,995,1109,24554,60177,60179 -j DROP
#save
iptables-save > /etc/iptables
touch /etc/network/if-pre-up.d/iptables
chmod +x /etc/network/if-pre-up.d/iptables
echo "#!/bin/sh" >> /etc/network/if-pre-up.d/iptables
echo "/sbin/iptables-restore < /etc/iptables" >> /etc/network/if-pre-up.d/iptables
iptables -L