I've recently started blocking port 25 on OpenVZ 7 nodes, using the following rule:
iptables -I FORWARD -p tcp --dport 25 -j DROP
This works fine, but it seems to block both inbound and outbound, but I only want outbound to be blocked. Is this possible?
If it means anything, I use the following commands to open port 25 again for a specific IP address:
iptables -I FORWARD 1 -d 192.168.0.1 -p tcp -m tcp --dport 25 -j ACCEPT
iptables -I FORWARD 1 -s 192.168.0.1 -p tcp -m tcp --dport 25 -j ACCEPT
iptables -A FORWARD -o docker0 -p tcp --dport 25 -j DROP
, wheredocker0
if your interface name. As mentioned the traffic coming from the container goes through the FORWARD chain.