Showing posts with label IPtables. Show all posts
Showing posts with label IPtables. Show all posts

Monday, January 14, 2013

Block Outbound Port 25 SMTP For Untrusted Users With IPtables

This will only allow port 25 access to users: mail, mailman and root
iptables -A OUTPUT -d 127.0.0.1 -p tcp -m tcp --dport 25 -j ACCEPT
iptables -A OUTPUT -p tcp -m tcp --dport 25 -m owner --gid-owner mail -j ACCEPT
iptables -A OUTPUT -p tcp -m tcp --dport 25 -m owner --gid-owner mailman -j ACCEPT
iptables -A OUTPUT -p tcp -m tcp --dport 25 -m owner --uid-owner root -j ACCEPT
iptables -A OUTPUT -p tcp -m tcp --dport 25 -j REJECT --reject-with icmp-port-unreachable

Wednesday, May 23, 2012

Block Port 25 On SolusVM/Xen With IPtables

SolusVM (at the time of this writing) has no internal method for firewalling customers containers. I find it often necessary to restrict ports on customers (normally port 25) and after trial and error came up with some rules for IPtables to facilitate this at the hardware node level. SolusVM uses the FORWARD chain inside of IPtables so all you need to do is:
iptables -I FORWARD 1 -d $ip -p tcp -m tcp --dport 25 -j DROP
iptables -I FORWARD 1 -s $ip -p tcp -m tcp --dport 25 -j DROP
...where $ip is the IP you are restricting port traffic on. The above rules prevent all IN/OUT port 25 traffic to a particular host.