password
URL
type
status
date
slug
summary
tags
category
icon
标签
是否汉化
最近在腾讯云中的doker中上搭建各种服务,防火墙和服务什么的都排查了,公网就是无法访问到,内网可以访问,在此记录下排查方案(问题出现在了第三步)
环境:腾讯云Centos 服务器
问题:当启动一个容器向外部暴露端口时,服务器公网IP:端口号
无法访问
一、未打开安全组策略
暴露给外部的端口需要打开对应的安全组设置,全部打开 😁,就需要添加如下的安全组配置
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F68202bb5-9faf-4bfe-9cc4-aaf29bc1fbcc%2F95320060-6d6f-4613-bf65-02741c6acd82%2FUntitled.png?table=block&id=940bc016-eed1-48fd-bf92-dcdec6dd73cd&t=940bc016-eed1-48fd-bf92-dcdec6dd73cd&width=708&cache=v2)
二、防火墙开放端口未设置
首先查看防火墙是否开启,结果为not running表示未开启,则不是防火墙的问题,跳过
查看防火墙是否开启
查看防火墙所开放的端口
也可以用firewall-cmd --list-all查看防火墙的详细信息
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F68202bb5-9faf-4bfe-9cc4-aaf29bc1fbcc%2F2b4cf230-d2ca-44b8-8141-bf4ab6030be1%2FUntitled.png?table=block&id=f5e5ad1f-5a93-460b-87bf-3c38d46a1b07&t=f5e5ad1f-5a93-460b-87bf-3c38d46a1b07&width=1391&cache=v2)
开放防火墙的对外暴露的端口
如: 开放90端口(--premanent表示永久添加)
重启防火墙(修改配置后要重启防火墙)
添加完成后再次查看就可以看到90端口被开放
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F68202bb5-9faf-4bfe-9cc4-aaf29bc1fbcc%2F3512dc28-c057-4bd6-89bc-bdb4e1a839e5%2FUntitled.png?table=block&id=7fca32d4-7f78-4be7-b470-df0cb6b6b00b&t=7fca32d4-7f78-4be7-b470-df0cb6b6b00b&width=708&cache=v2)
三、没有启用IP_FORWARD
这个问题一般不会出现,默认都是打开的,我们用如下命令查看
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F68202bb5-9faf-4bfe-9cc4-aaf29bc1fbcc%2Faeeb7e02-5e10-4df5-afe7-0cf56edabfb4%2FUntitled.png?table=block&id=4c6da6be-3ecd-44bc-bd88-3b84ed661d85&t=4c6da6be-3ecd-44bc-bd88-3b84ed661d85&width=708&cache=v2)
结果为
1
则表示启动,为0
则未启动,用如下命令启动执行完成后,重启服务器或使用下面的命令从文件中加载配置:
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F68202bb5-9faf-4bfe-9cc4-aaf29bc1fbcc%2F8f5ffb7f-df5b-454d-819e-f48a48e724e5%2FUntitled.png?table=block&id=d24b2040-3ceb-4e8e-8ff0-de65c07805c4&t=d24b2040-3ceb-4e8e-8ff0-de65c07805c4&width=708&cache=v2)
离开乏味的皮囊,自由的灵魂在路上
- Name: Alan Hsu
- Tag: 随感、技术、经验、旅行、推荐、生活、音乐、电影 etc.
- Email:xulanzhong521gmail.com
- Twitter:@AlanHsu521
- Telegram:@AlanHsu521
- WeChat: Alan_Hsu_521
- Github: https://github.com/xsoway/
![notion image](https://cdn.jsdelivr.net/gh/xsoway/xmylog_imgs@main/wechat.jpeg?t=d8af3b05-04a2-4723-a969-b9147780f006)
![notion image](https://cdn.jsdelivr.net/gh/xsoway/xmylog_imgs@main/%E5%85%AC%E4%BC%97%E5%8F%B7.jpeg?t=19b1150b-dd15-48f2-860a-dec096259902)
- Author:Alan_Hsu
- URL:https://xmylog.com/article/articles_docker_port
- Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!
Relate Posts