# Blocking Unwanted SMTP

```
iptables -A INPUT -i eth0 -p tcp --destination-port 25 -s 127.0.0.1 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --destination-port 25 -s 147.28.0.62 -j ACCEPT
iptables -A INPUT -i eth0 -s 198.180.150.1 -j ACCEPT
ip6tables -A INPUT -i eth0 -p tcp --destination-port 25 -s ::1 -j ACCEPT
ip6tables -A INPUT -i eth0 -p tcp --destination-port 25 -s 2001:418:1::62 -j ACCEPT
ip6tables -A INPUT -i eth0 -s 2001:418:8006::1 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --destination-port 25 -j DROP
ip6tables -A INPUT -i eth0 -p tcp --destination-port 25 -j DROP
iptables-save -c > /etc/iptables.rules
ip6tables-save -c > /etc/ip6tables.rules
cat > /etc/network/if-pre-up.d/iptables << EOF
#!/bin/sh

iptables-restore  < /etc/iptables.rules
ip6tables-restore < /etc/ip6tables.rules

exit 0
EOF
cat > /etc/network/if-post-down.d/iptables << EOF
#!/bin/sh

iptables-save  -c > /etc/iptables.rules
ip6tables-save -c > /etc/ip6tables.rules

if [ -f /etc/iptables.rules ]; then
   iptables-restore < /etc/iptables.rules
   fi

if [ -f /etc/ip6tables.rules ]; then
   ip6tables-restore < /etc/ip6tables.rules
   fi

exit 0
EOF
chmod 755 /etc/network/if-pre-up.d/iptables /etc/network/if-post-down.d/iptables
```

