Iptables allow only localhost and gmail

gmailiptableslocalhost

I use this in iptables: (want to allow 25 port only for localhost)

iptables -A INPUT -p tcp -s localhost --dport 25 -j ACCEPT
iptables -A INPUT -p tcp --dport 25 -j DROP

It works perfect, but I stopped to receive forwarded mail (it was working OK before).

I have a rule in mail config -> email sent to myusername@mydomain.com -> forwarded to my gmail

What should I change/add in my iptables to allow this forwarding but port 25 to be closed for public? Maybe add google IP or something else?

Many thanks!

Best Answer

If this is a standalone host, I suggest you solve this issue within your mailserver, not a firewall. Gmail has every right to change their IP addresses as they see fit at any time and you'll end up having a broken system. Configure your mailserver to accept mails to addresses you allow and possibly from addresses you allow. Alternatively use something like fetchmail to download your mails from Gmail instead of using a forward.

Related Topic