LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 814|回复: 5

最近捣鼓iptables,抄个脚本回来,大家帮忙看看有什么不合理的地方没~~~

[复制链接]
发表于 2009-3-13 01:31:16 | 显示全部楼层 |阅读模式
  1. FW_IP="163.26.197.8"
  2. ###-----------------------------------------------------###
  3. # filter table
  4. ###-----------------------------------------------------###
  5. iptables -P INPUT DROP
  6. iptables -P OUTPUT DROP
  7. iptables -P FORWARD DROP
  8. iptables -A INPUT -i lo -j ACCEPT
  9. iptables -A OUTPUT -o lo -j ACCEPT
  10. iptables -A INPUT -i eth1 -j ACCEPT
  11. iptables -A OUTPUT -o eth1 -j ACCEPT
  12. iptables -A FORWARD -i eth1 -j ACCEPT
  13. iptables -A FORWARD -o eth1 -j ACCEPT
  14. ###-----------------------------------------------------###
  15. # snat
  16. ###-----------------------------------------------------###
  17. iptables -t nat -A POSTROUTING -o eth0 -s 172.16.0.0/16 -j SNAT --to-source $FW_IP
  18. ###-----------------------------------------------------###
  19. # telnet
  20. ###-----------------------------------------------------###
  21. iptables -A OUTPUT -o eth0 -p tcp -s $FW_IP --sport 1024:65535 -d any/0 --dport 23 -j ACCEPT
  22. iptables -A INPUT -i eth0 -p tcp ! --syn -s any/0 --sport 23 -d $FW_IP --dport 1024:65535 -j ACCEPT
  23. ###-----------------------------------------------------###
  24. # smtp
  25. ###-----------------------------------------------------###
  26. iptables -A OUTPUT -o eth0 -p tcp -s $FW_IP --sport 1024:65535 -d any/0 --dport 25 -j ACCEPT
  27. iptables -A INPUT -i eth0 -p tcp ! --syn -s any/0 --sport 25 -d $FW_IP --dport 1024:65525 -j ACCEPT
  28. ###-----------------------------------------------------###
  29. # pop3
  30. ###-----------------------------------------------------###
  31. iptables -A OUTPUT -o eth0 -p tcp -s $FW_IP --sport 1024:65535 -d any/0 --dport 110 -j ACCEPT
  32. iptables -A INPUT -i eth0 -p tcp ! --syn -s any/0 --sport 110 -d $FW_IP --dport 1024:65535 -j ACCEPT
  33. ###-----------------------------------------------------###
  34. # http
  35. ###-----------------------------------------------------###
  36. iptables -A OUTPUT -o eth0 -p tcp -s $FW_IP --sport 1024:65535 -d any/0 --dport 80 -j ACCEPT
  37. iptables -A INPUT -i eth0 -p tcp ! --syn -s any/0 --sport 80 -d $FW_IP --dport 1024:65535 -j ACCEPT
  38. ###-----------------------------------------------------###
  39. # https
  40. ###-----------------------------------------------------###
  41. iptables -A OUTPUT -o eth0 -p udp -s $FW_IP --sport 1024:65535 -d any/0 --dport 443 -j ACCEPT
  42. iptables -A INPUT -i eth0 -p udp -s any/0 --sport 443 -d $FW_IP --dport 1024:65535 -j ACCEPT
  43. iptables -A OUTPUT -o eth0 -p tcp -s $FW_IP --sport 1024:65535 -d any/0 --dport 443 -j ACCEPT
  44. iptables -A INPUT -i eth0 -p tcp ! --syn -s any/0 --sport 443 -d $FW_IP --dport 1024:65535 -j ACCEPT
  45. ###-----------------------------------------------------###
  46. # dns
  47. ###-----------------------------------------------------###
  48. iptables -A OUTPUT -o eth0 -p udp -s $FW_IP --sport 1024:65535 -d any/0 --dport 53 -j ACCEPT
  49. iptables -A INPUT -i eth0 -p udp -s any/0 --sport 53 -d $FW_IP --dport 1024:65535 -j ACCEPT
  50. iptables -A OUTPUT -o eth0 -p tcp -s $FW_IP --sport 1024:65535 -d any/0 --dport 53 -j ACCEPT
  51. iptables -A INPUT -i eth0 -p tcp ! --syn -s any/0 --sport 53 -d $FW_IP --dport 1024:65535 -j ACCEPT
  52. ###-----------------------------------------------------###
  53. # ssh
  54. ###-----------------------------------------------------###
  55. iptables -A OUTPUT -o eth0 -p tcp -s $FW_IP --sport 1024:65535 -d any/0 --dport 22 -j ACCEPT
  56. iptables -A INPUT -i eth0 -p tcp ! --syn -s any/0 --sport 22 -d $FW_IP --dport 1024:65535 -j ACCEPT
  57. iptables -A OUTPUT -o eth0 -p tcp -s $FW_IP --sport 1020:1023 -d any/0 --dport 22 -j ACCEPT
  58. iptables -A INPUT -i eth0 -p tcp ! --syn -s any/0 --sport 22 -d $FW_IP --dport 1020:1023 -j ACCEPT
  59. ###-----------------------------------------------------###
  60. # ftp
  61. ###-----------------------------------------------------###
  62. iptables -A OUTPUT -o eth0 -p tcp -s $FW_IP --sport 1024:65535 -d any/0 --dport 21 -j ACCEPT
  63. iptables -A INPUT -i eth0 -p tcp ! --syn -s any/0 --sport 21 -d $FW_IP --dport 1024:65535 -j ACCEPT
  64. iptables -A INPUT -i eth0 -p tcp -s any/0 --sport 20 -d $FW_IP --dport 1024:65535 -j ACCEPT
  65. iptables -A OUTPUT -o eth0 -p tcp ! --syn -s $FW_IP --sport 1024:65535 -d any/0 --dport 20 -j ACCEPT
  66. iptables -A OUTPUT -o eth0 -p tcp -s $FW_IP --sport 1024:65535 -d any/0 --dport 1024:65535 -j ACCEPT
  67. iptables -A INPUT -i eth0 -p tcp ! --syn -s any/0 --sport 1024:65535 -d $FW_IP --dport 1024:65535 -j ACCEPT
  68. ###-----------------------------------------------------###
  69. # ping
  70. ###-----------------------------------------------------###
  71. iptables -A OUTPUT -o eth0 -p icmp -s $FW_IP --icmp-type 8 -d any/0 -j ACCEPT
  72. iptables -A INPUT -i eth0 -p icmp -s any/0 --icmp-type 0 -d $FW_IP -j ACCEPT
复制代码
发表于 2009-3-13 11:08:02 | 显示全部楼层
连output链也限制,真够狠的。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-3-13 11:47:39 | 显示全部楼层
Post by ebok;1960275
连output链也限制,真够狠的。

没办法,外贼家贼都要防~~~
回复 支持 反对

使用道具 举报

发表于 2009-3-13 18:14:15 | 显示全部楼层
建议在 mangle 里面加上

-A FORWARD -o ppp0 -p tcp -m tcp --tcp-flags SYN,RST SYN -m tcpmss --mss 1400:1536 -j TCPMSS --clamp-mss-to-pmtu
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-3-13 18:21:06 | 显示全部楼层
Post by latteye;1960433
建议在 mangle 里面加上

-A FORWARD -o ppp0 -p tcp -m tcp --tcp-flags SYN,RST SYN -m tcpmss --mss 1400:1536 -j TCPMSS --clamp-mss-to-pmtu

能给讲讲是什么意思吗?
回复 支持 反对

使用道具 举报

发表于 2009-3-13 19:41:36 | 显示全部楼层
看不懂,学习~
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表