Advertisement
Guest User

iptables ipset port blocking

a guest
Dec 18th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.75 KB | None | 0 0
  1. ipset create blacklist -exist hash:net family inet hashsize 16384 maxelem 131072
  2. ipset create bl-tcp-ports bitmap:port range 0-65535
  3. ipset create bl-udp-ports bitmap:port range 0-65535
  4. ipset add bl-tcp-ports 21 ## File Transfer Protocol (FTP)
  5. ipset add bl-tcp-ports 22 ## Secure Shell (SSH), secure logins, file transfers (scp, sftp) and port forwarding
  6. ipset add bl-tcp-ports 23 ## Telnet protocol—unencrypted text communications
  7. ipset add bl-tcp-ports 88 ## Kerberos authentication system
  8. ipset add bl-tcp-ports 445 ## SMB Windows Shares
  9. ipset add bl-tcp-ports 1080 ## Socks Proxy
  10. ipset add bl-tcp-ports 1433 ## Microsoft SQL Server database management system (MSSQL) server
  11. ipset add bl-tcp-ports 2323 ## TELNET-ALT
  12. ipset add bl-tcp-ports 3306 ## MySQL database system
  13. ipset add bl-tcp-ports 3389 ## Microsoft Terminal Server (RDP)
  14. ipset add bl-tcp-ports 5060 ## Session Initiation Protocol (SIP)
  15. ipset add bl-tcp-ports 5061 ## Session Initiation Protocol (SIP) over TLS
  16. ipset add bl-tcp-ports 5900 ## Virtual Network Computing (VNC) Remote Frame Buffer RFB protocol
  17. ipset add bl-udp-ports 69 ## Trivial File Transfer Protocol (TFTP)
  18. ipset add bl-udp-ports 123 ## Network Time Protocol (NTP)
  19. ipset add bl-udp-ports 135 ##
  20. ipset add bl-udp-ports 137 ##
  21. ipset add bl-udp-ports 138 ##
  22. ipset add bl-udp-ports 139 ##
  23. ipset add bl-udp-ports 445 ## SMB Windows Shares
  24. ipset add bl-udp-ports 5060 ## Session Initiation Protocol (SIP)
  25. iptables -I FORWARD 1 -p tcp -m tcp -m set --match-set bl-tcp-ports dst -j SET --add-set blacklist src
  26. iptables -I FORWARD 2 -p udp -m udp -m set --match-set bl-udp-ports dst -j SET --add-set blacklist src
  27. iptables -I FORWARD 3 -m set --match-set blacklist src -j LOG
  28. iptables -I FORWARD 4 -m set --match-set blacklist src -j DROP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement