阿里雲服務器——添加的安全組端口以及添加后無法訪問問題排查


目的:

1、為了通過阿里雲服務器做服務器的外網映射而需要在阿里雲服務器添加安全組端口外網訪問

2、解決偶然發現添加安全組端口后,還是無法訪問的解決方案

 

前置條件:
1、設置阿里雲安全組端口
2、在本機cmd下,telnet IP+端口 (注:ip 后面是空格 + 端口號),如果通則萬事大吉,如果不通,則進行排查方案

 

 

 

排查方案(如有新的排查方向,后續補上):
1.發現telnet不通的話,則考慮是否服務器防火牆的問題

1)查看所有信息,看添加的端口是否存在(注:ports后面的就是開放的對應端口)

# firewall-cmd --list-all    #注意權限問題

public (active)
  target: default
  icmp-block-inversion: no
  interfaces: eth0
  sources: 
  services: dhcpv6-client
  ports: 1130/tcp 80/tcp 10051/tcp 5672/tcp 

2)沒有的話添加,例如添加18002端口

#firewall-cmd --zone=public --add-port=18002/tcp --permanent
說明:
–zone #作用域
–add-port=80/tcp #添加端口,格式為:端口/通訊協議
–permanent 永久生效,沒有此參數重啟后失效
其它操作:
添加多個端口:
firewall-cmd --zone=public --add-port=80-90/tcp --permanent
#刪除
firewall-cmd --zone=public --remove-port=80/tcp --permanent

3)重啟防火牆

#firewall-cmd --reload

4)再次查看端口是否打開(如打開后,則完美解決)

# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: eth0
  sources: 
  services: dhcpv6-client
  ports: 1130/tcp 80/tcp 10051/tcp 18002/tcp 7660/tcp
  protocols: 
  masquerade: yes

防火牆的一些基本命令:

1:查看防火狀態
systemctl status firewalld

service  iptables status

2:暫時關閉防火牆

systemctl stop firewalld

service  iptables stop

3:永久關閉防火牆

systemctl disable firewalld

chkconfig iptables off

4:重啟防火牆

systemctl enable firewalld

service iptables restart

5:啟動防火牆
sudo systemctl start firewalld

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM