Home
Help
Search
Login
Register
OPNsense Forum
»
Archive
»
21.1 Legacy Series
»
email smtp port 25 and 587 firewall rule/port forward protection
« previous
next »
Print
Pages: [
1
]
2
Author
Topic: email smtp port 25 and 587 firewall rule/port forward protection (Read 8882 times)
RamSense
Hero Member
Posts: 595
Karma: 10
email smtp port 25 and 587 firewall rule/port forward protection
«
on:
July 24, 2021, 09:14:53 am »
Dear community,
I have a mailserver running behind opnsense. The mailserver is working and have the port forward rules for ports used 25, 587, etc
Now I was thinking, Is there a way to configure opnsense so to protect the mailserver that only the local IPrange and vpn range can log in into the mail server and being able to sent email? Using an alias?
but so that the mailserver can receive emails being sent to it from anybody?
Sounds like a solid option, but I don't know if this is possible while the mailserver must being able to communicatie with the world?
Hope my question makes sense and somebody with knowledge of running mailservers and opnsense have a best practise for how to set secure port forwards/alias etc.
Logged
fabian
Hero Member
Posts: 2769
Karma: 200
OPNsense Contributor (Language, VPN, Proxy, etc.)
Re: email smtp port 25 and 587 firewall rule/port forward protection
«
Reply #1 on:
July 24, 2021, 10:32:28 am »
Just open the port 587 only internally. Foreign servers will always send mails to 25.
Logged
RamSense
Hero Member
Posts: 595
Karma: 10
Re: email smtp port 25 and 587 firewall rule/port forward protection
«
Reply #2 on:
July 25, 2021, 09:17:48 am »
Thanks Fabian,
I will change this right away!
Logged
RamSense
Hero Member
Posts: 595
Karma: 10
Re: email smtp port 25 and 587 firewall rule/port forward protection
«
Reply #3 on:
July 25, 2021, 11:45:14 am »
@Fabian
I changed port 587 in the firewall on the mailserver to only allow internally.
In opnsense I still have :
Firewall->NAT->Port Forward-> rule:
Interface (WAN) - protocol (TCP) - Source Adress (*) - Ports (*) - Destination Address (WAN address) - Ports (587) - NAT IP (local IP mailserver) - Ports (587)
and the auto added rule Firewall->Rules->Wan-> rule:
Protocol (IPv4 TCP) - Source (*) Port (*) - Destination (local IP mailserver) - Port (587) - Gateway (*) - Schedule (*)
How to change this for the "open port 587 only internally?
Thanks in advance for your explanation!
«
Last Edit: July 25, 2021, 11:52:56 am by RamSense
»
Logged
fabian
Hero Member
Posts: 2769
Karma: 200
OPNsense Contributor (Language, VPN, Proxy, etc.)
Re: email smtp port 25 and 587 firewall rule/port forward protection
«
Reply #4 on:
July 25, 2021, 12:04:52 pm »
Source IP is just all LAN addresses you want to allow in the firewall rule.
Logged
RamSense
Hero Member
Posts: 595
Karma: 10
Re: email smtp port 25 and 587 firewall rule/port forward protection
«
Reply #5 on:
July 25, 2021, 12:23:07 pm »
@Fabian, thank you for your reply.
So I change this in the NAT portforward so it get changed also in the firewall-rules-wan?
See attached pictures? Or should I Leave the Nat port forward untouched and only change firewall-rules-wan?
«
Last Edit: July 25, 2021, 12:26:14 pm by RamSense
»
Logged
RamSense
Hero Member
Posts: 595
Karma: 10
Re: email smtp port 25 and 587 firewall rule/port forward protection
«
Reply #6 on:
July 25, 2021, 06:48:02 pm »
somehow the LAN addresses used above did not work for my iPhone on 4g (with vpn to opnsense).
Than I thought, when I make an alias with the ip-range from LAN and VPN and use that as source ip....
changed it, and this works!
I do not understand what is different from the LAN address with this alias, but that has to do with my learning of how opnsense / firewall works. Or should Source IP - lan address also have worked? What did I do wrong than?
Logged
fabian
Hero Member
Posts: 2769
Karma: 200
OPNsense Contributor (Language, VPN, Proxy, etc.)
Re: email smtp port 25 and 587 firewall rule/port forward protection
«
Reply #7 on:
July 25, 2021, 09:08:18 pm »
LAN Address - OPNsense IP-Address on the LAN interface
LAN Network - The network which is directly attached to the LAN interface (so this includes the hosts) <- you usually need this one
This Firewall - Any IP address assigned to this firewall
Logged
RamSense
Hero Member
Posts: 595
Karma: 10
Re: email smtp port 25 and 587 firewall rule/port forward protection
«
Reply #8 on:
July 25, 2021, 09:51:40 pm »
Ah great! Now I Understand. Thanks for that. Learned something again today.
And problem solved :-)
Logged
RamSense
Hero Member
Posts: 595
Karma: 10
Re: email smtp port 25 and 587 firewall rule/port forward protection
«
Reply #9 on:
July 29, 2021, 10:07:29 pm »
Humm...
I still must be doing something wrong.
When choosing LAN Network or just the Ip range of VPN 10.8.0.0/24
the port 587 gets blocked by opnsense.
My iPhone 4g connected to opnsense with vpn has a virtual-ip 10.8.0.2 but opnsense blocks it. Have I something wrong in the port forward or is this something I have done wrong in the vpn setup? with Redirect Gateway enabled....
In the firewall log I see the REALIP of the iPhone getting blocked and not the virtual ip 10.8.0.2 getting handled...
p.s. this happened after updating to opnsense 21.7
«
Last Edit: July 30, 2021, 08:17:07 am by RamSense
»
Logged
RamSense
Hero Member
Posts: 595
Karma: 10
Re: email smtp port 25 and 587 firewall rule/port forward protection
«
Reply #10 on:
July 30, 2021, 08:45:04 am »
Testing with Wireguard VPN -> it works and connection to email (587)
Testing with OpenVPN -> gets blocked
I am convinced openvpn was also working before opnsense 21.7. But I can't figure out why it is not working now, if it has to do with the upgrade to 21.7 and Wireguard works like it should.. I am obviously missing something
Logged
chemlud
Hero Member
Posts: 2485
Karma: 112
Re: email smtp port 25 and 587 firewall rule/port forward protection
«
Reply #11 on:
July 30, 2021, 09:24:15 am »
Is your opnvpn tunnel otherwise functional? Correct FW rules?
What is the error message you get?
Do a package capture on openvpn/LAN to see, where the packages are blocked...
Logged
kind regards
chemlud
____
"The price of reliability is the pursuit of the utmost simplicity."
C.A.R. Hoare
felix eichhorns premium katzenfutter mit der extraportion energie
A router is not a switch - A router is not a switch - A router is not a switch - A rou....
RamSense
Hero Member
Posts: 595
Karma: 10
Re: email smtp port 25 and 587 firewall rule/port forward protection
«
Reply #12 on:
July 30, 2021, 09:50:16 am »
Dear Chemlud,
Thank you for your reply.
Yes the OPNvpn is working on all other parts. I can connect, browse the internet and connect to lan available services/devices.
When I look at the firewall live view I see that my iPhone real IP gets blocked while I have an alias nat port forward with alias for 10.8.0.0/24 as for local lan and Wireguard. The last 2 are working, only the vpn/10.8.0.0/24 does not.
The realIP gets blocked instead of the virtualIP/VPNIP gets through
I have attached 2 pictures
Logged
RamSense
Hero Member
Posts: 595
Karma: 10
Re: email smtp port 25 and 587 firewall rule/port forward protection
«
Reply #13 on:
August 01, 2021, 10:04:24 pm »
maybe this is happening?
https://forum.opnsense.org/index.php?topic=24183.0
Logged
RamSense
Hero Member
Posts: 595
Karma: 10
Re: email smtp port 25 and 587 firewall rule/port forward protection
«
Reply #14 on:
August 02, 2021, 09:24:05 am »
Looks like it was an missing NAT outbound rule(?)
When I add a NAT - outbound rule >
Interface (LAN) - source (any) - source port (*) - Destination (*) - Destination port (*) - NAT Address (interface address) - NAT port (*) - Static port (NO)
it works.......
Now I have to figure it out how to narrow it down I think.
(I'm still a fairly new user in opnsense)
Logged
Print
Pages: [
1
]
2
« previous
next »
OPNsense Forum
»
Archive
»
21.1 Legacy Series
»
email smtp port 25 and 587 firewall rule/port forward protection