CentOS iptables配置笔记

2011-01-14 at 09:55 下午 宽宽

针对网站近期被入侵的现状,对iptables做以下设置,提升服务器安全性能

(1)屏蔽所有端口
(2)把SSH的缺省端口设置为56565
(3)把56565、80、3306端口打开
(4)把3306端口设置为只允许本机访问

如果没有安装iptables的话,运行命令yum install iptables完成iptables安装

初始化安装以后,显示为以下信息:

  1. [root@tp ~]# iptables -L -n
  2.  
  3. Chain INPUT (policy ACCEPT)
  4.  
  5. target prot opt source destination
  6.  
  7. Chain FORWARD (policy ACCEPT)
  8.  
  9. target prot opt source destination
  10.  
  11. Chain OUTPUT (policy ACCEPT)
  12.  
  13. target prot opt source destination

(1)屏蔽所有端口

  1. [root@tp ~]# iptables -F
  2. [root@tp ~]# iptables -X
  3. [root@tp ~]# iptables -P INPUT DROP
  4. [root@tp ~]# iptables -P OUTPUT DROP
  5. [root@tp ~]# iptables -P FORWARD DROP

当超出了IPTABLES里filter表里的两个链规则 (INPUT,FORWARD)时,不在这两个规则里的数据包怎么处理呢,那就是DROP(放弃),有同学喜欢配置OUTPUT为accpet,因为如果被入侵,对方可以使用服务器做为中转,发起攻击,也会产生大量的数据包,所以这里配置为DROP

(2)把SSH的缺省端口设置为56565

在修改ssh端口时,应先把要修改的端口号56565加入白名单

  1. [root@tp ~]# iptables -A INPUT -p tcp --dport 56565 -j ACCEPT
  2. [root@tp ~]# iptables -A OUTPUT -p tcp --sport 56565 -j ACCEPT
  3. [root@tp ~]# /etc/rc.d/init.d/iptables save
  4. [root@tp ~]# service iptables restart

再修改端口号

  1. [root@linux ~]# vi /etc/ssh/sshd_config

将"#Port 22"修改为"Port 56565"

重启ssh服务

  1. [root@linux ~]# /etc/init.d/sshd restart
  2. Stopping sshd: [ OK ]
  3. Starting sshd: [ OK ]

如果想看看sshd端口号是否修改成功的话,可以使用 netstat -an 命令查看一下或退出ssh使用新端口号登陆尝试。

(3)把80端口打开

  1. [root@tp ~]# iptables -A INPUT -p tcp --dport 80 -j ACCEPT
  2. [root@tp ~]# iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT
  3. [root@tp ~]# /etc/rc.d/init.d/iptables save
  4. [root@tp ~]# service iptables restart

(4)把3306端口设置为只允许本机访问

  1. [root@tp ~]#/sbin/iptables -A INPUT -p tcp -s 127.0.0.1 --dport 3306 -j ACCEPT
  2. [root@tp ~]#/sbin/iptables -A OUTPUT -p tcp -s 127.0.0.1 --dport 3306 -j ACCEPT

至此,完成CentOS iptables配置,此配置可提升服务器安全性能,过滤掉一些常见的linux攻击,对于少量爆超管系统权限的linux 0day攻击,也只能算走运了。
 

------------------------------------------------------------------------------------------
作者:
宽宽@网站策划运营
本站所有文章均为宽宽原创。
版权所有。转载时必须以链接形式注明作者和原始出处及本声明。

113 Responses to “CentOS iptables配置笔记”

  1. buy@generic.VIAGRA” rel=”nofollow”>…

    Need cheap generic VIAGRA?…

  2. Order@Coral.Calcium.Online” rel=”nofollow”>..

    Buygeneric pills…

  3. Cheap@Abilify.Online” rel=”nofollow”>..

    Buygeneric meds…

  4. Cheap@Generic.Abilify” rel=”nofollow”>..

    Buygeneric drugs…

  5. Cheap@Abilify.5mg.10mg.15mg.20mg.30mg” rel=”nofollow”>..

    Buygeneric pills…

  6. Buy@Abilify.5mg.10mg.15mg.20mg.30mg” rel=”nofollow”>..

    Buyno prescription…

  7. Purchase@Cheap.Acai” rel=”nofollow”>…

    Buygeneric drugs…

  8. Cheap@Acai.Online” rel=”nofollow”>…

    Buynow…

  9. Purchase@Acai.Without.Prescription” rel=”nofollow”>..…

    Buynow it…

  10. Buy@Acai.500mg” rel=”nofollow”>.…

    Buynow it…

  11. Buy@Discount.Coral.Calcium” rel=”nofollow”>..

    Buygeneric meds…

  12. Buy@Generic.Abilify” rel=”nofollow”>…

    Buywithout prescription…

  13. Order@Cheap.Coral.Calcium” rel=”nofollow”>.

    Buygeneric drugs…

  14. Buy@Cheap.Acai” rel=”nofollow”>…

    Buygeneric drugs…

  15. Buy@Cheap.Acai” rel=”nofollow”>…

    Buygeneric drugs…

  16. Order@Acai.Online” rel=”nofollow”>…

    Buyit now…

  17. Purchase@Generic.Acai” rel=”nofollow”>..

    Buygeneric drugs…

  18. Purchase@Acai.Without.Prescription” rel=”nofollow”>..…

    Buyno prescription…

  19. Order@Discount.Energy.Boost” rel=”nofollow”>.…

    Buynow it…

  20. Buy@Discount.Accupril” rel=”nofollow”>.…

    Buyno prescription…

  21. Order@Cheap.Accupril” rel=”nofollow”>.…

    Buygeneric drugs…

  22. Order@Cheap.Accutane” rel=”nofollow”>.…

    Buygeneric drugs…

  23. Cheap@Aciphex.Without.Prescription” rel=”nofollow”>.…

    Buynow it…

  24. Cheap@Aciphex.20mg” rel=”nofollow”>.…

    Buygeneric meds…

  25. Buy@Cheap.Acomplia” rel=”nofollow”>.…

    Buygeneric pills…

  26. Actonel@35mg.Without.Prescription” rel=”nofollow”>.

    Buygeneric drugs zfk…

  27. Get@Actoplus.Met.Online” rel=”nofollow”>..

    Buygeneric pills zdg…

  28. Buy@Actos.Without.Prescription” rel=”nofollow”>.

    Buyno prescription luw…

  29. Order@Discount.Adalat” rel=”nofollow”>.

    Buygeneric meds unm…

  30. Order@Discount.Abana” rel=”nofollow”>..

    Buynow it vhx…

  31. Buy@Abilify.Online” rel=”nofollow”>..

    Buywithout prescription dyo…

  32. Order@Cheap.Acai” rel=”nofollow”>..

    Buyno prescription gdt…

  33. Purchase@Acai.Without.Prescription” rel=”nofollow”>.

    Buyit now ojb…

  34. Generic@Acai.500mg.Without.Prescription” rel=”nofollow”>..

    Buyno prescription wkp…

  35. Buy@Cheap.Energy.Boost” rel=”nofollow”>…

    Buygeneric meds svb…

  36. Order@Cheap.Accupril” rel=”nofollow”>.

    Buynow it fnp…

  37. Order@Accutane.Online” rel=”nofollow”>…

    Buyit now sge…

  38. Order@Discount.Accutane” rel=”nofollow”>.

    Buygeneric drugs mby…

  39. Purchase@Cheap.Accutane” rel=”nofollow”>…

    Buywithout prescription ccw…

  40. Buy@Aciphex.Online” rel=”nofollow”>.

    Buygeneric drugs itj…

  41. Cheap@Generic.Aciphex” rel=”nofollow”>..

    Buyno prescription lka…

  42. Order@Acomplia.Online” rel=”nofollow”>.

    Buygeneric drugs axm…

  43. Purchase@Acomplia.Online” rel=”nofollow”>..

    Buyno prescription jui…

  44. Purchase@Discount.Acomplia” rel=”nofollow”>..

    Buynow it sgk…

  45. Order@Actonel.Without.Prescription” rel=”nofollow”>…

    Buydrugs without prescription jlg…

  46. Order@Advair.Online” rel=”nofollow”>..

    Buyit now irl…

  47. < a href=”http://trig.com/advair5771/biography/?ml=Advair-25mcg/50mcg-25mcg/125mcg-25mcg/250mcg-50mcg/500mcg-50mcg/100mcg-50mcg/250mcg-Without-Prescription Advair@25mcg50mcg.25mcg125mcg.25mcg250mcg.50mcg500mcg.50mcg100mcg.50mcg250mcg.Without.Pr

    Buydrugs without prescription ygy…

  48. Buy@Aggrenox.Online” rel=”nofollow”>..

    Buygeneric drugs ajd…

  49. Purchase@Discount.Aggrenox” rel=”nofollow”>.

    Buynow it lmg…

  50. buy@acai.berry.juice” rel=”nofollow”>..

    Buygeneric drugs…

  51. accutane@krupnick.class.action” rel=”nofollow”>..

    Buynow…

  52. advair@copd.advertising.campaign” rel=”nofollow”>..

    Buynow…

  53. buy@amoxicillin.500mg” rel=”nofollow”>.

    Buynow it…

  54. abilify@company.buy” rel=”nofollow”>.

    Buywithout prescription…

  55. blue@sky.energy.solar.boost.3048” rel=”nofollow”>…

    Buynow it…

  56. amoxicillin@online.buy” rel=”nofollow”>.

    Buygeneric drugs…

  57. arimidex@or.nolvadex.steriods” rel=”nofollow”>..

    Buywithout prescription…

  58. artane@bending.over” rel=”nofollow”>.

    Buynow…

  59. good and bad drugs

    Buy_without prescription…

  60. what is plavix

    Buy_drugs without prescription…

  61. iv zofran

    Buy_drugs without prescription…

  62. hypertension police ma

    Buy_drugs without prescription…

  63. acute angle-closure glaucoma

    Buy_drugs without prescription…

  64. regulations for dementia units

    Buy_drugs without prescription…

  65. depo@provera.bone.loss” rel=”nofollow”>…

    Buygeneric drugs…

Leave a Reply