Community discussions

MikroTik App
 
EuropowerGenerators
just joined
Topic Author
Posts: 1
Joined: Fri Oct 09, 2015 9:30 am

Question regarding firewall rules and NAT

Fri Oct 09, 2015 9:46 am

Hello,

We seem to have a misconfiguration for blocking chinese IPs.
General blocking of chinese IP's seem to work (we no longer get connection attempts from china in our PPTP VPN log.), but we're still seeing intrusion attempts from IP's on our China blacklist on our NAT'ted mail server.

From what I can read in other posts NAT is applied before the firewall rules, but wouldn't a rule that blocks all China source addresses still work after NAT? Or does the SRC address change at that point.

Here are our rules:
0    chain=input action=drop src-address-list=China log=yes log-prefix="" 
1    chain=input action=drop src-address-list=America log=no log-prefix="" 
2    chain=forward action=drop src-address=10.0.0.0/24 dst-address=10.0.255.0/24 log=no log-prefix="" 
3    chain=forward action=drop src-address=10.0.255.0/24 dst-address=10.0.0.0/24 log=no log-prefix="" 
4    chain=input action=accept protocol=tcp src-address=10.0.0.0/24 log=no log-prefix="" 
5    chain=input action=accept protocol=gre log=no log-prefix="" 
6    chain=input action=accept protocol=tcp dst-port=1723 log=no log-prefix="" 
7    chain=input action=reject reject-with=tcp-reset protocol=tcp log=no log-prefix="" 
And our NAT rules:
0    chain=srcnat action=masquerade out-interface=ether5 log=no log-prefix="" 
1    chain=dstnat action=dst-nat to-addresses=10.0.0.239 to-ports=20 protocol=tcp in-interface=ether5 dst-port=20 log=no log-prefix="" 
2    chain=dstnat action=dst-nat to-addresses=10.0.0.239 to-ports=21 protocol=tcp in-interface=ether5 dst-port=21 log=no log-prefix="" 
3    chain=dstnat action=dst-nat to-addresses=10.0.0.104 to-ports=25 protocol=tcp in-interface=ether5 dst-port=25 log=no log-prefix="" 
My idea would be to add following rule but I'd like to double check it here before I screw up seeing as I'm quite new to this.
chain=forward action=drop src-address-list=China log=yes log-prefix="" 

My idea being that the chain is no longer input but forward after the NAT rules are applied. Is this correct?

Kind Regards

Europower Generators
 
User avatar
karlisi
Member
Member
Posts: 439
Joined: Mon May 31, 2004 8:09 am
Location: Latvia

Re: Question regarding firewall rules and NAT

Fri Oct 09, 2015 10:41 am

3    chain=dstnat action=dst-nat to-addresses=10.0.0.104 to-ports=25 protocol=tcp in-interface=ether5 dst-port=25 log=no log-prefix="" 
What if You modify NAT rule?
chain=dstnat action=dst-nat to-addresses=10.0.0.104 to-ports=25 protocol=tcp in-interface=ether5 dst-port=25 log=no log-prefix="" src-address-list=!China
 
skuykend
Member Candidate
Member Candidate
Posts: 274
Joined: Tue Oct 06, 2015 7:28 am

Re: Question regarding firewall rules and NAT

Sat Oct 10, 2015 12:30 am

I believe the DST-NAT is done in pre-routing, at which time the packet will become part of the forward chain and not the input chain.

Add the drops to the forward chain as well and it should work.

Who is online

Users browsing this forum: frengo, InfraErik, ivankrosl and 58 guests