sa_drug

[MT]: IP filter vendor default with port knocking

Oct 20th, 2021
1,196
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /ip firewall filter add action=accept chain=input comment="defconf: accept established,related,untracked" connection-state=established,related,untracked
  2. /ip firewall filter add action=drop chain=input comment="defconf: drop invalid" connection-state=invalid
  3. /ip firewall filter add action=jump chain=input comment="userconf: port knocking" connection-state=new dst-port=113322,331122,223311 jump-target=pknock protocol=tcp
  4. /ip firewall filter add action=accept chain=input comment="userconf: accept ssh connection after port knocking" connection-state=new dst-port=22 in-interface-list=WAN log=yes log-prefix=mngmt-ssh protocol=tcp src-address-list=alst-PKNOCK-MNGMT
  5. /ip firewall filter add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
  6. /ip firewall filter add action=accept chain=input comment="defconf: accept to local loopback (for CAPsMAN)" dst-address=127.0.0.1
  7. /ip firewall filter add action=drop chain=input comment="defconf: drop all not coming from LAN" in-interface-list=!LAN
  8. /ip firewall filter add action=accept chain=forward comment="defconf: accept in ipsec policy" ipsec-policy=in,ipsec
  9. /ip firewall filter add action=accept chain=forward comment="defconf: accept out ipsec policy" ipsec-policy=out,ipsec
  10. /ip firewall filter add action=fasttrack-connection chain=forward comment="userconf: disable fasttrack" connection-state=established,related disabled=yes
  11. /ip firewall filter add action=accept chain=forward comment="defconf: accept established,related, untracked" connection-state=established,related,untracked
  12. /ip firewall filter add action=drop chain=forward comment="defconf: drop invalid" connection-state=invalid
  13. /ip firewall filter add action=drop chain=forward comment="defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat connection-state=new in-interface-list=WAN
  14. /ip firewall filter add action=log chain=pknock comment="userconf: port knocking" disabled=yes
  15. /ip firewall filter add action=add-src-to-address-list address-list=alst-PKNOCK-MNGMT address-list-timeout=1d chain=pknock comment="userconf: stage #3 - allow action" dst-port=223311 log=yes log-prefix=allow-mngmt protocol=tcp src-address-list=alst-PKNOCK-ST2
  16. /ip firewall filter add action=add-src-to-address-list address-list=alst-PKNOCK-ST2 address-list-timeout=1m chain=pknock comment="userconf: stage #2 - second port match" dst-port=331122 protocol=tcp src-address-list=alst-PKNOCK-ST1
  17. /ip firewall filter add action=add-src-to-address-list address-list=alst-PKNOCK-ST1 address-list-timeout=1m20s chain=pknock comment="userconf: stage #1 - first port match" dst-port=113322 protocol=tcp
  18. /ip firewall filter add action=drop chain=pknock comment="userconf: chain default rule"
RAW Paste Data