VPS侦探论坛

 找回密码
 注册
查看: 3152|回复: 1

iptables 配置问题。军哥帮忙!

[复制链接]
发表于 2017-5-10 16:48:56 | 显示全部楼层 |阅读模式

80端等端口不能访问


  1. [root@localhost ~]# iptables -L -n
  2. Chain INPUT (policy ACCEPT)
  3. target     prot opt source               destination         
  4. ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            ctstate RELATED,ESTABLISHED
  5. ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
  6. INPUT_direct  all  --  0.0.0.0/0            0.0.0.0/0           
  7. INPUT_ZONES_SOURCE  all  --  0.0.0.0/0            0.0.0.0/0           
  8. INPUT_ZONES  all  --  0.0.0.0/0            0.0.0.0/0           
  9. DROP       all  --  0.0.0.0/0            0.0.0.0/0            ctstate INVALID
  10. REJECT     all  --  0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited

  11. Chain FORWARD (policy ACCEPT)
  12. target     prot opt source               destination         
  13. ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            ctstate RELATED,ESTABLISHED
  14. ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
  15. FORWARD_direct  all  --  0.0.0.0/0            0.0.0.0/0           
  16. FORWARD_IN_ZONES_SOURCE  all  --  0.0.0.0/0            0.0.0.0/0           
  17. FORWARD_IN_ZONES  all  --  0.0.0.0/0            0.0.0.0/0           
  18. FORWARD_OUT_ZONES_SOURCE  all  --  0.0.0.0/0            0.0.0.0/0           
  19. FORWARD_OUT_ZONES  all  --  0.0.0.0/0            0.0.0.0/0           
  20. DROP       all  --  0.0.0.0/0            0.0.0.0/0            ctstate INVALID
  21. REJECT     all  --  0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited

  22. Chain OUTPUT (policy ACCEPT)
  23. target     prot opt source               destination         
  24. OUTPUT_direct  all  --  0.0.0.0/0            0.0.0.0/0           

  25. Chain FORWARD_IN_ZONES (1 references)
  26. target     prot opt source               destination         
  27. FWDI_public  all  --  0.0.0.0/0            0.0.0.0/0           [goto]
  28. FWDI_public  all  --  0.0.0.0/0            0.0.0.0/0           [goto]

  29. Chain FORWARD_IN_ZONES_SOURCE (1 references)
  30. target     prot opt source               destination         

  31. Chain FORWARD_OUT_ZONES (1 references)
  32. target     prot opt source               destination         
  33. FWDO_public  all  --  0.0.0.0/0            0.0.0.0/0           [goto]
  34. FWDO_public  all  --  0.0.0.0/0            0.0.0.0/0           [goto]

  35. Chain FORWARD_OUT_ZONES_SOURCE (1 references)
  36. target     prot opt source               destination         

  37. Chain FORWARD_direct (1 references)
  38. target     prot opt source               destination         

  39. Chain FWDI_public (2 references)
  40. target     prot opt source               destination         
  41. FWDI_public_log  all  --  0.0.0.0/0            0.0.0.0/0           
  42. FWDI_public_deny  all  --  0.0.0.0/0            0.0.0.0/0           
  43. FWDI_public_allow  all  --  0.0.0.0/0            0.0.0.0/0           
  44. ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           

  45. Chain FWDI_public_allow (1 references)
  46. target     prot opt source               destination         

  47. Chain FWDI_public_deny (1 references)
  48. target     prot opt source               destination         

  49. Chain FWDI_public_log (1 references)
  50. target     prot opt source               destination         

  51. Chain FWDO_public (2 references)
  52. target     prot opt source               destination         
  53. FWDO_public_log  all  --  0.0.0.0/0            0.0.0.0/0           
  54. FWDO_public_deny  all  --  0.0.0.0/0            0.0.0.0/0           
  55. FWDO_public_allow  all  --  0.0.0.0/0            0.0.0.0/0           

  56. Chain FWDO_public_allow (1 references)
  57. target     prot opt source               destination         
  58. ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           

  59. Chain FWDO_public_deny (1 references)
  60. target     prot opt source               destination         

  61. Chain FWDO_public_log (1 references)
  62. target     prot opt source               destination         

  63. Chain INPUT_ZONES (1 references)
  64. target     prot opt source               destination         
  65. IN_public  all  --  0.0.0.0/0            0.0.0.0/0           [goto]
  66. IN_public  all  --  0.0.0.0/0            0.0.0.0/0           [goto]

  67. Chain INPUT_ZONES_SOURCE (1 references)
  68. target     prot opt source               destination         

  69. Chain INPUT_direct (1 references)
  70. target     prot opt source               destination         

  71. Chain IN_public (2 references)
  72. target     prot opt source               destination         
  73. IN_public_log  all  --  0.0.0.0/0            0.0.0.0/0           
  74. IN_public_deny  all  --  0.0.0.0/0            0.0.0.0/0           
  75. IN_public_allow  all  --  0.0.0.0/0            0.0.0.0/0           
  76. ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           

  77. Chain IN_public_allow (1 references)
  78. target     prot opt source               destination         
  79. ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0            udp dpt:4500 ctstate NEW
  80. ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0            udp dpt:1701 ctstate NEW
  81. ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:22 ctstate NEW
  82. ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0            udp dpt:500 ctstate NEW
  83. ACCEPT     ah   --  0.0.0.0/0            0.0.0.0/0            ctstate NEW
  84. ACCEPT     esp  --  0.0.0.0/0            0.0.0.0/0            ctstate NEW

  85. Chain IN_public_deny (1 references)
  86. target     prot opt source               destination         

  87. Chain IN_public_log (1 references)
  88. target     prot opt source               destination         

  89. Chain OUTPUT_direct (1 references)
  90. target     prot opt source               destination         
  91. [root@localhost ~]#
复制代码
我在服务器上安装了
  1. wget --no-check-certificate https://raw.githubusercontent.com/teddysun/across/master/l2tp.sh
复制代码
导致无法访问80 等端口。按照
  1. https://www.vpser.net/security/linux-iptables.html
复制代码
  1. #允许本地回环接口(即运行本机访问本机)
  2. iptables -A INPUT -i lo -j ACCEPT
  3. # 允许已建立的或相关连的通行
  4. iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  5. #允许所有本机向外的访问
  6. iptables -A OUTPUT -j ACCEPT
  7. # 允许访问22端口
  8. iptables -A INPUT -p tcp --dport 22 -j ACCEPT
  9. #允许访问80端口
  10. iptables -A INPUT -p tcp --dport 80 -j ACCEPT
  11. #允许访问443端口
  12. iptables -A INPUT -p tcp --dport 443 -j ACCEPT
  13. #允许FTP服务的21和20端口
  14. iptables -A INPUT -p tcp --dport 21 -j ACCEPT
  15. iptables -A INPUT -p tcp --dport 20 -j ACCEPT
  16. #如果有其他端口的话,规则也类似,稍微修改上述语句就行
  17. #允许ping
  18. iptables -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
  19. #禁止其他未允许的规则访问
  20. iptables -A INPUT -j REJECT  #(注意:如果22端口未加入允许规则,SSH链接会直接断开。)
  21. iptables -A FORWARD -j REJECT
复制代码
添加了端口还是无法访问。。
但是我将规则全部清空以后 可以正常访问。
  1. iptables -F
  2. iptables -X
  3. iptables -Z
复制代码
求助军哥帮助。。。看看iptables 配置 是哪里出错了。

[ 本帖最后由 yurec 于 2017-5-10 16:53 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2017-5-10 20:30:17 | 显示全部楼层


80端口允许规则-A 用 -I 添加后看一下
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-26 05:22 , Processed in 0.025153 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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