This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
networking:router:mikrotik_fw [2014/06/03 11:33] gcooper |
networking:router:mikrotik_fw [2022/07/22 10:06] (current) gcooper |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Mikrotik RouterOS Firewall ====== | ====== Mikrotik RouterOS Firewall ====== | ||
- | |||
- | http:// | ||
===== Denial of Service ===== | ===== Denial of Service ===== | ||
Line 27: | Line 25: | ||
===== Destination NAT (Port Forwarding) Examples ===== | ===== Destination NAT (Port Forwarding) Examples ===== | ||
- | :!: "Destination NAT" | + | :!: '' |
- | :!: With Mikrotik RouterOS, you don't have to add a separate | + | :!: With Mikrotik RouterOS, you do not add an explicit '' |
< | < | ||
Line 48: | Line 46: | ||
http:// | http:// | ||
- | Normal ' | + | Normal |
< | < | ||
/ip firewall nat | /ip firewall nat | ||
- | + | add action=masquerade chain=srcnat comment=" | |
- | add action=masquerade chain=srcnat comment=" | + | |
</ | </ | ||
Line 77: | Line 74: | ||
===== Basic Firewall ===== | ===== Basic Firewall ===== | ||
+ | |||
+ | FIXME This basic firewall script needs modernization, | ||
Firewall/ | Firewall/ | ||
Line 144: | Line 143: | ||
http:// | http:// | ||
+ | |||
+ | ==== Country Code ==== | ||
+ | |||
+ | :!: This is probably **for more powerful routers with lots of RAM** as it could add many rules. | ||
+ | |||
+ | :!: You probably want to put the rules **near the top** of the list. | ||
+ | |||
+ | **Country Code List**: https:// | ||
+ | |||
+ | - **Create the script/ | ||
+ | - **Copy the '' | ||
+ | - **Import the script** | ||
+ | - **Create a firewall rule** referencing the new address list | ||
+ | |||
+ | < | ||
+ | /import IP-Firewall-Address-List.rsc | ||
+ | /ip firewall filter | ||
+ | add action=drop chain=input comment=" | ||
+ | log-prefix=" | ||
+ | add action=drop chain=forward comment=" | ||
+ | log-prefix=" | ||
+ | </ | ||
==== FTP ==== | ==== FTP ==== | ||
- | :!: The block rule must be before rules allowing established connections or it will not function. | + | :!: The block rule must be **before rules allowing established connections** or it will not function. |
:!: This FTP configuration actually looks into the FTP data to see the 530 code. | :!: This FTP configuration actually looks into the FTP data to see the 530 code. | ||
- | :!: This appears to be specific to the Mikrotik FTP service (content) and requires the FTP service be enabled to function. | + | :!: This appears to be specific to the response of the Mikrotik FTP service ('' |
- | :!: To have the attacker blocked completely, you can probably just remove the '' | + | :!: **To have the attacker blocked completely**, you can probably just **remove** the '' |
This example allows only 10 FTP login incorrect answers per minute, then bans the attacker (from FTP) for 10 days: | This example allows only 10 FTP login incorrect answers per minute, then bans the attacker (from FTP) for 10 days: | ||
Line 169: | Line 190: | ||
</ | </ | ||
- | If you want to block downstream access as well, you need to block the with the forward chain: | + | If you want to block downstream access as well, you need to also block in the forward chain: |
< | < | ||
add chain=forward protocol=tcp dst-port=21 src-address-list=ftp_blacklist action=drop \ | add chain=forward protocol=tcp dst-port=21 src-address-list=ftp_blacklist action=drop \ | ||
- | comment=" | + | comment=" |
</ | </ | ||
- | Then accept FTP traffic | + | Then accept |
< | < | ||
Line 371: | Line 392: | ||
connection-state=new dst-port=8291 protocol=tcp src-address-list=!local | connection-state=new dst-port=8291 protocol=tcp src-address-list=!local | ||
</ | </ | ||
+ | |||
+ | ===== IPSec ===== | ||
+ | |||
+ | http:// | ||
+ | |||
+ | http:// | ||
+ | |||
+ | :!: IPSec traffic is not identifiable in FW rules. | ||
+ | |||
+ | **L2TP/ | ||
+ | |||
+ | * TCP port 1701 | ||
+ | * L2TP | ||
+ | * UDP port 500 | ||
+ | * Internet Security Association and Key Management Protocol (ISAKMP) | ||
+ | * To negotiate security method (password, certificate, | ||
+ | * AH (Protocol ID 50) | ||
+ | * Authentication Header | ||
+ | * ESP (Protocol ID 51) | ||
+ | * Encapsulated Secure Payload | ||
+ | * UDP Port 4500 | ||
+ | * NAT Traversal (NAT-T) | ||
+ | |||
+ | Accept L2TP/IPSec connection traffic: | ||
+ | |||
+ | :!: These rules could be further limited by interface and/or source address. | ||
+ | |||
+ | < | ||
+ | /ip firewall filter | ||
+ | add chain=input action=accept in-interface=ether1 protocol=tcp dst-port=1701 \ | ||
+ | place-before=0 comment=" | ||
+ | add chain=input action=accept in-interface=ether1 protocol=udp dst-port=500 \ | ||
+ | place-before=0 comment=" | ||
+ | add chain=input action=accept in-interface=ether1 protocol=ipsec-esp \ | ||
+ | place-before=0 comment=" | ||
+ | add chain=input action=accept in-interface=ether1 protocol=ipsec-ah \ | ||
+ | place-before=0 comment=" | ||
+ | </ | ||
+ |