大网数据广告活动
服务器运维问答

A port is not open on firewall but it's accessible

· 52CE 我爱测

I'm using centos 7 with firewallD on my server. I have also installed docker on this machine and added it to a trusted zone of my firewall. I have a container that listens on port 9081 but this port is not open on the firewall an…

问题原文

原帖链接 · Amin_it · CC BY-SA 4.0

I'm using centos 7 with firewallD on my server.

I have also installed docker on this machine and added it to a trusted zone of my firewall.

I have a container that listens on port 9081 but this port is not open on the firewall and the strange thing is that port is accessible from my home pc.

This is the output of firewall-cmd --list-all

public (active)
  target: default
  icmp-block-inversion: no
  interfaces: eth0
  sources:
  services: dhcpv6-client ssh
  ports: 443/tcp 80/tcp
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

I have two active zones : trusted and public

here is the output of command firewall-cmd --zone=trusted --list-all

trusted (active)
  target: ACCEPT
  icmp-block-inversion: no
  interfaces: docker0
  sources:
  services:
  ports: 4243/tcp
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

Clearly the port 9081 is not open in any zone, but still, I can access it. why? how to close it?

已采纳解答

原帖链接 · Amin_it · CC BY-SA 4.0

I realized that there are some errors running Docker with firewallD.

A Simple walkaround is to change how you define your ports in docker. in my case I had to change my docker-compose to this:

ports:
- "127.0.0.1:9081:8081"

The important part is using 127.0.0.1 in before defining host port.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-03-14)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。