#Router and internal network protection, no internal servers, LAN is friendly /ip firewall filter add chain=input action=drop connection-state=invalid comment="Disallow weird packets" add chain=input action=accept connection-state=new in-interface=LAN comment="Allow LAN access to router and Internet" add chain=input action=accept connection-state=established comment="Allow connections that originated from LAN" add chain=input action=accept connection-state=related comment="Allow connections that originated from LAN" add chain=input action=accept protocol=icmp comment="Allow ping ICMP from anywhere" add chain=input action=drop comment="Disallow anything from anywhere on any interface" add chain=forward action=drop connection-state=invalid comment="Disallow weird packets" add chain=forward action=accept connection-state=new in-interface=LAN comment="Allow LAN access to router and Internet" add chain=forward action=accept connection-state=established comment="Allow connections that originated from LAN" add chain=forward action=accept connection-state=related comment="Allow connections that originated from LAN" add chain=forward action=drop
You did copy the rules, but the order is not really ok.hello,
thank you very much for reply.
I have just copied and pasted the rules you wrote, and please see the screen-shot I took from WinBox GUI
What I do not understand here in Mikrotik is why we need allow the traffic from LAN as everything works without any rule ?
I was able to access the internet from the server without any rule in the firewall list, and I am also able to access the server FROM the
internet without any rule because server have the official ip address and do not need a NAT..
I wish that Mikrotik could CLOSE all the traffic default so we can just open what we need instead of opening everything as default, kind of wired if you ask me..
I am aware that mikrotik routerOS is not a firewall but router only, of course it can do many of the firewall features by the way ....
Is this I did correct or ?
Thank you !!
Please delete the rules and then readd them (change WAN and LAN to match your interface names). Do not change the order. They are processed in order (top to bottom) such that they only drop when needed. If MikroTik blocked traffic by default these forums would run over with questions.I have just copied and pasted the rules you wrote, and please see the screen-shot I took from WinBox GUI
I wish that Mikrotik could CLOSE all the traffic default so we can just open what we need instead of opening everything as default, kind of wired if you ask me..
See here. Note that the router itself listens on port 80, thus you'll need to change that.I need an example rule for opening a port to Web server (80) from certain ip address only at the begining so I can modify it later ...
Okay, that changes things ... someone else will have to help you then. I don't know how to route that kind of traffic. Get terminal command prompt and run the command: /export compact file=a_setup_file. Get that file from the Files menu, remove any personal information, and post it here. Make sure it contains the following information for someone to help you:I am not using NAT, because there is a public IP on both WAN and LAN interfaces so the server uses the LAN interface ip as its gateway to internet ...
# sep/06/2013 19:50:52 by RouterOS 6.2 # software id = xxxx-xxxx # /interface ethernet set 0 name=LAN set 1 name=WAN /ip hotspot user profile set [ find default=yes ] idle-timeout=none keepalive-timeout=2m \ mac-cookie-timeout=3d /port set 0 name=serial0 set 1 name=serial1 /tool user-manager customer add backup-allowed=yes disabled=no login=admin password="" \ paypal-accept-pending=no paypal-allowed=no paypal-secure-response=no \ permissions=owner signup-allowed=no time-zone=-00:00 /ip address add address=172.12.34.53/29 interface=WAN network=172.12.34.48 add address=172.12.34.54/32 interface=LAN network=172.12.34.48 /ip firewall address-list add address=47.2x.xx.xx list=my_ip_address /ip firewall filter add chain=input comment="Allow access to router from known network" \ src-address-list=my_ip_address add action=drop chain=input comment="Disallow weird packets" \ connection-state=invalid add chain=input comment="Allow LAN access to router and Internet" \ connection-state=new in-interface=LAN add chain=input comment="Allow connections that originated from LAN" \ connection-state=established add chain=input comment="Allow connections that originated from LAN" \ connection-state=related add chain=input comment="Allow ping ICMP from anywhere" protocol=icmp add action=drop chain=input comment=\ "Disallow anything from anywhere on any interface" add action=drop chain=forward comment="Disallow weird packets" \ connection-state=invalid add chain=forward comment="Allow LAN access to router and Internet" \ connection-state=new in-interface=LAN add chain=forward comment="Allow connections that originated from LAN" \ connection-state=established add chain=forward comment="Allow connections that originated from LAN" \ connection-state=related add chain=forward comment="Open port 80 for Web Server" \ dst-address=172.12.34.50 dst-port=80 protocol=tcp add action=drop chain=forward /ip firewall service-port set ftp disabled=yes set tftp disabled=yes set irc disabled=yes set h323 disabled=yes set sip disabled=yes set pptp disabled=yes /ip route add distance=1 gateway=172.12.34.49 /ip service set telnet disabled=yes set ftp disabled=yes set www address=47.2x.xx.xx/32 disabled=yes set ssh address=47.2x.xx.xx/32 set api disabled=yes set winbox address=47.2x.xx.xx/32 set api-ssl disabled=yes /system lcd set contrast=0 enabled=no port=parallel type=24x4 /system lcd page set time disabled=yes display-time=5s set resources disabled=yes display-time=5s set uptime disabled=yes display-time=5s set packets disabled=yes display-time=5s set bits disabled=yes display-time=5s set version disabled=yes display-time=5s set identity disabled=yes display-time=5s set WAN disabled=yes display-time=5s set LAN disabled=yes display-time=5s /tool bandwidth-server set enabled=noThank You all for helping !!!
can someone from Mikrotik support help me on this one ?
add chain=forward comment="Open port 80 for Web Server" \ dst-address=8.8.8.8 dst-port=80 protocol=tcpWhy is your dst-address=8.8.8.8? ... unless your Googles DNS server that line is most likely wrong. dst-address should be whatever the server you are running on port 80 is... In your case likely something in 172.12.34.53/29
add chain=forward comment="Open port 80 for Web Server" \ dst-address=172.12.34.50 dst-port=80 protocol=tcp
# sep/06/2013 19:50:52 by RouterOS 6.2 # software id = xxxx-xxxx # /interface ethernet set 0 name=LAN set 1 name=WAN /interface bridge add name=bridge-wan /interface bridge port add interface=WAN bridge=bridge-wan add interface=LAN bridge=bridge-lan /interface bridge settings set allow-fast-path=no use-ip-firewall=yes use-ip-firewall-for-pppoe=yes use-ip-firewall-for-vlan=yes /ip hotspot user profile set [ find default=yes ] idle-timeout=none keepalive-timeout=2m \ mac-cookie-timeout=3d /port set 0 name=serial0 set 1 name=serial1 /tool user-manager customer add backup-allowed=yes disabled=no login=admin password="" \ paypal-accept-pending=no paypal-allowed=no paypal-secure-response=no \ permissions=owner signup-allowed=no time-zone=-00:00 /ip address add address=172.12.34.53/29 interface=bridge-wan network=172.12.34.48 /ip firewall address-list add address=47.2x.xx.xx list=my_ip_address /ip firewall filter add chain=input comment="Allow access to router from known network" \ src-address-list=my_ip_address add action=drop chain=input comment="Disallow weird packets" \ connection-state=invalid add chain=input comment="Allow LAN access to router and Internet" \ connection-state=new in-interface=LAN add chain=input comment="Allow connections that originated from LAN" \ connection-state=established add chain=input comment="Allow connections that originated from LAN" \ connection-state=related add chain=input comment="Allow ping ICMP from anywhere" protocol=icmp add action=drop chain=input comment=\ "Disallow anything from anywhere on any interface" add action=drop chain=forward comment="Disallow weird packets" \ connection-state=invalid add chain=forward comment="Allow LAN access to router and Internet" \ connection-state=new in-bridge-port=LAN add chain=forward comment="Allow connections that originated from LAN" \ connection-state=established add chain=forward comment="Allow connections that originated from LAN" \ connection-state=related add chain=forward comment="Open port 80 for Web Server" \ dst-address=172.12.34.50 dst-port=80 protocol=tcp add action=drop chain=forward /ip firewall service-port set ftp disabled=yes set tftp disabled=yes set irc disabled=yes set h323 disabled=yes set sip disabled=yes set pptp disabled=yes /ip route add distance=1 gateway=172.12.34.49 /ip service set telnet disabled=yes set ftp disabled=yes set www address=47.2x.xx.xx/32 disabled=yes set ssh address=47.2x.xx.xx/32 set api disabled=yes set winbox address=47.2x.xx.xx/32 set api-ssl disabled=yes /system lcd set contrast=0 enabled=no port=parallel type=24x4 /system lcd page set time disabled=yes display-time=5s set resources disabled=yes display-time=5s set uptime disabled=yes display-time=5s set packets disabled=yes display-time=5s set bits disabled=yes display-time=5s set version disabled=yes display-time=5s set identity disabled=yes display-time=5s set WAN disabled=yes display-time=5s set LAN disabled=yes display-time=5s /tool bandwidth-server set enabled=no
thank you very much for configuration and suggestion !
think I understand the problem now.
Will test both options and will let you know..
and yes I understood the part regarding the default gateway for the servers...
have just tested the bridged mode, and it works just fine
Will run it in bridge mode until I remove the pfSense, then I will run a routing on MikroTik just as I do now on the pfSense.
THANK YOU very much again for helping and very good suggestions, I hope that other will learn about this now.
Karma will of course be given, no doubt about that
#Router and internal network protection, no internal servers, LAN is friendly /ip firewall filter add chain=input action=drop connection-state=invalid comment="Disallow weird packets" add chain=input action=accept connection-state=new in-interface=LAN comment="Allow LAN access to router and Internet" add chain=input action=accept connection-state=established comment="Allow connections that originated from LAN" add chain=input action=accept connection-state=related comment="Allow connections that originated from LAN" add chain=input action=accept protocol=icmp comment="Allow ping ICMP from anywhere" add chain=input action=drop comment="Disallow anything from anywhere on any interface" add chain=forward action=drop connection-state=invalid comment="Disallow weird packets" add chain=forward action=accept connection-state=new in-interface=LAN comment="Allow LAN access to router and Internet" add chain=forward action=accept connection-state=established comment="Allow connections that originated from LAN" add chain=forward action=accept connection-state=related comment="Allow connections that originated from LAN" add chain=forward action=drop
Not really. That's basically what I do also. I have allow related/established, drop invalid, allow stuff I want, then default drop. The only thing you may want to add is some limits on what ICMPs you allow, throttle connections to also limit DOS attacks, drop bogons (private/invalid addresses), etc.My point is to BLOCK just EVERYTHING except the web server ports or other ports that I will use later...
add chain=forward action=drop
In theory you want to place things like DOS at the top to drop them with as little processing as possible. Same with bogons etc... that said you could make the argument that placing related and established should be at the top because that allows your traffic you already have seen (e.g. established connections) to bypass the rest of the firewall. I'm not entirely sure there is a "right" answer to that question. Personally I have my DOS, Bogons, and ICMP above my related and established.ok I understand Your point, and yes I was also thinking about dos, bogon and ICMP limit protections as well..
But tell me one thing about the bogon and ICMP limitation rules, what about their sequences in my case ?
can I add all additional rules below all my rules I have now as long as all of the rules are above this one ?
of course some rules are special and has to be placed in the right sequence.. and I am aware that all the rules
are read from top to bottom in MikroTik
ros code
add chain=forward action=drop
This is true for each chain. Top to bottom for the input chain, and top to bottom for anything that gets into the forward chain. So where you place your rules depends on which chain you suspect your traffic will appear.I am aware that all the rules are read from top to bottom in MikroTik
Yeah. That is true. Just depends where you operate your router.actually regarding the bogon rules in the firewall rule, I am not sure if this rule is needed because
I think that only Border Routers that runs the BGP protocol should filter these networks so they are not
distributed out and filter incoming BGP so we cannot accept them if someone distributes them out..
In this case it`s ISP who stops these networks on their Border Routers that runs the BGP...
Then you are correct. Glad we got it all working.in my case I am not running any BGP sessions so this rule is not needed..
# mar/03/2016 14:01:20 by RouterOS 6.34.2
# software id = XXXX-XXXX
#
/interface ethernet
set [ find default-name=ether2 ] name=LAN
set [ find default-name=ether1 ] name=WAN
/ip hotspot profile
set [ find default=yes ] html-directory=flash/hotspot
/ip pool
add name=pool1 ranges=192.168.1.10-192.168.1.250
/ip dhcp-server
add address-pool=pool1 disabled=no interface=LAN lease-time=1d name=server1
/ip address
add address=192.168.1.1/24 interface=LAN network=192.168.1.0
/ip dhcp-client
add default-route-distance=0 dhcp-options=hostname,clientid disabled=no \
interface=WAN
/ip dhcp-server network
add address=192.168.1.0/24 dns-server=8.8.8.8 gateway=192.168.1.1
/ip firewall filter
add action=drop chain=input comment="Disallow weird packets" \
connection-state=invalid
add chain=input comment="Allow LAN access to router and Internet" \
connection-state=new in-interface=LAN
add chain=input comment="Allow connections that originated from LAN" \
connection-state=established
add chain=input comment="Allow connections that originated from LAN" \
connection-state=related
add chain=input comment="Allow ping ICMP from anywhere" protocol=icmp
add action=drop chain=input comment=\
"Disallow anything from anywhere on any interface"
add action=drop chain=forward comment="Disallow weird packets" \
connection-state=invalid
add chain=forward comment="Allow LAN access to router and Internet" \
connection-state=new in-interface=LAN
add chain=forward comment="Allow connections that originated from LAN" \
connection-state=established
add chain=forward comment="Allow connections that originated from LAN" \
connection-state=related
add action=drop chain=forward comment=\
"Disallow anything from anywhere on any interface"
/ip firewall nat
add action=masquerade chain=srcnat
/ip service
set telnet disabled=yes
set www disabled=yes
set api disabled=yes
set api-ssl disabled=yes
/system clock
set time-zone-name=Europe/Riga
/system ntp client
set enabled=yes primary-ntp=85.254.217.235 secondary-ntp=81.63.144.23
/system routerboard settings
set cpu-frequency=650MHz protected-routerboot=disabled
1 chain=dstnat action=netmap to-addresses=10.1.1.2 dst-address=X.X.X.131>
log=no log-prefix=""
2 chain=srcnat action=netmap to-addresses=X.X.X.131 src-address=10.1.1.2.>
log=yes log-prefix=""
1 chain=input action=drop protocol=icmp dst-address=X.X.X.131 log=no log-prefix=""