hi all,
Maybe one of you know which is the correct way to deny access from the Internet to an open port?
I installed my first SME as follows, in Server/gateway mode:
[ PPPoE modem ]
|
|/-------eth1 (ppp0)
[ SME 7.1 ]
|\-------eth0
|
[ internal network ] (1 hub, 2 Windows users)
I know, mail+web services and specially samba file shares should not run on a firewall, but I have no other router and want to use this old PC as a firewall, and to test some features of SME, locally only.
So, mainly to learn how to do it, I've set up a
local mail server on this SME box, which should not be accessible from internet. I was amazed how easy it was to setup! Then checked for open ports with a remote port scanner and ... Ooops - the mail server is listening to the whole internet on port 25...:
Testing port 25: Port open - lets see if we can talk....
220 mydomain.local ESMTP
550 Sorry, I don't believe that you are xxx.180.21.yyy.
Checking for a open Windows share....
Testing port 136: Connection timed out....
Testing port 137: Connection refused....
Testing port 138: Connection refused....
So I want to close ports 25, 137-139 and 465 (=smtps) to the internet (ppp0), or should I DROP all ports and allow only the ident port (tcp 113). (?)
I had some experience with iptables, but not sure which is the correct way to edit/create a custom templates. I suppose I need to create:
mcedit /etc/e-smith/templates-custom/etc/rc.d/init.d/masq/90local_chk01
Then add rules like this:
/sbin/iptables --in-interface $NEW_PPPconn --replace INPUT --destport 25 -j denylog
I found this in the SME FAQ:
config set manta service access public status enabled TCPPort nnn
config setprop manta ~AllowHosts 1.2.3.4,10.11.12.0/24
config setprop manta ~DenyHosts 16.17.18.18
signal-event remoteaccess-update
but could not find any post on how to block an existing open port. Would the following work?
config setprop smtp ~AllowHosts 192.168.1.0/24
config setprop smtp ~DenyHosts 0.0.0.0
signal-event remoteaccess-update
for now, I just entered manually:
/sbin/iptables -I InboundTCP_16348 --proto tcp --dport smtp -j denylog
/sbin/iptables -I InboundTCP_16348 --proto tcp --dport smtps -j denylog
This works -- until next reboot...
Any advice for a better way would be appreciated! I'm also unsure if this post should move to the bug tracker...
Stefan