随笔 - 507  文章 - 0  评论 - 0  阅读 - 83万

解决CentOS7 docker容器映射端口只监听ipv6的问题

问题现象

docker容器起来以后,查看9100端口监听情况,如下图:

$ ss -lntp
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:* users:(("sshd",pid=1151,fd=3))
LISTEN 0 4096 [::]:9100 [::]:* users:(("node_exporter",pid=2147,fd=3))
LISTEN 0 128 [::]:22 [::]:* users:(("sshd",pid=1151,fd=4))

9100只监听在ipv6上,使用ipv4无法访问。

解决办法如下:

编辑/etc/default/grub,在第六行前面加入ipv6.disable=1

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=0
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="ipv6.disable=1 crashkernel=auto spectre_v2=retpoline rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"

 保存后重新配置grub并重启服务器

$ grub2-mkconfig -o /boot/grub2/grub.cfg
$ reboot

重启后结果:

State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:* users:(("sshd",pid=1133,fd=3))
LISTEN 0 100 127.0.0.1:25 *:* users:(("master",pid=1295,fd=13))
LISTEN 0 4096 *:9100 *:* users:(("node_exporter",pid=1732,fd=3))
posted on   让编程成为一种习惯  阅读(1286)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 字符编码:从基础到乱码解决
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示