본문 바로가기
OS/Linux

[CentOS7] firewall 포트 개방하기

by CodeDesigner 2022. 4. 28.

 문제 발생

..(생략)
[2022-04-28T08:01:44,470][INFO ][o.e.d.DiscoveryModule    ] [Test-Server] using discovery type [zen] and host providers [settings]
[2022-04-28T08:01:44,744][INFO ][o.e.n.Node               ] [Test-Server] initialized
[2022-04-28T08:01:44,744][INFO ][o.e.n.Node               ] [Test-Server] starting ...
[2022-04-28T08:01:44,825][INFO ][o.e.t.TransportService   ] [Test-Server] publish_address {localhost:9300}, bound_addresses {localhost:9300}
..(중략)
[2022-04-28T08:01:47,937][INFO ][o.e.h.n.Netty4HttpServerTransport] [Test-Server] publish_address {localhost:9200}, bound_addresses {localhost:9200}
[2022-04-28T08:01:47,937][INFO ][o.e.n.Node               ] [Test-Server] started
[2022-04-28T08:01:47,944][INFO ][o.e.g.GatewayService     ] [Test-Server] recovered [0] indices into cluster_state

 

elasticsearch를 실행시키고 웹에서 테스트를 해보았더니 접속이 되지 않고 로딩이 지속됐다.

 

 문제점 발견

 

해당 포트가 방화벽에서 접근허용이 허락되어있지 않아 발생하는 문제였다.

 

[root@Test-Server bin]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: enp0s25
  sources:
  ports:
  ..(중략)
  icmp-blocks:
  rich rules:

 

firewall-cmd --list-all 명령어를 통해 아무 포트도 개방되어 있지 않음을 확인하고 elasticsearch가 설정되어 있는 포트를 개방시켰다.

 

 해결 방법

[root@Test-Server bin]# firewall-cmd --permanent --zone=public --add-port=9200/tcp
success
[root@Test-Server bin]# firewall-cmd --permanent --zone=public --add-port=9300/tcp
success
[root@Test-Server bin]# firewall-cmd --permanent --zone=public --add-port=5601/tcp
success

 

다음과 같이 elastichost, tcp, kibana 총 3개에 사용될 포트를 개방시켰다.

개방 이후엔 firewall을 reload 시켜줘서 반영을 시켜줘야 한다.

 

[root@Test-Server bin]# sudo firewall-cmd --reload
success

[root@Test-Server bin]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  ..(중략)
  ports: 9200/tcp 9300/tcp 5601/tcp
  protocols:
  ..(중략)
  icmp-blocks:
  rich rules:

 

reload 시킨 이후에 list를 확인해보면 port 등록이 잘 되어있는 것을 확인할 수 있다.

다시 elasticsearch를 접속해보면 성공적으로 접속이 성공한 것을 확인할 수 있다.


{

  • name: "Test-Server"
  • cluster_name: "Test_Cluster",
  • cluster_uuid: "(생략)",
  • version: {
    • number: "6.8.6",
    • build_flavor: "oss",
    • build_type: "tar",
    • build_hash: "(생략)",
    • build_date: "2019-12-13T17:11:52.013738Z",
    • build_snapshot: false,
    • lucene_version: "7.7.2",
    • minimum_wire_compatibility_version: "5.6.0",
    • minimum_index_compatibility_version: "5.0.0"
      },
  • tagline: "You Know, for Search"
    }

 

사용 cmd

firewall-cmd --list-all

firewall-cmd --permanent --zone=public --add-port=9200/tcp

firewall-cmd --permanent --zone=public --add-port=9300/tcp

firewall-cmd --permanent --zone=public --add-port=5601/tcp

firewall-cmd --reload

'OS > Linux' 카테고리의 다른 글

[CentOS7] tomcat7 설치  (0) 2022.05.13
[CentOS7] mysql 설치 중 GPG Key Error  (0) 2022.04.28
[CentOS7] Shasum 설치  (0) 2022.04.27
CentOS7 wget 설치  (0) 2022.04.27
linux 에서 listen중인 port 확인  (0) 2022.04.26

댓글