标签:iptables 安装 Centos7 访问 shendu Docker root
Docker中安装Centos7后访问该Centos7中的服务
文章目录
说明
该环境是这样的:
如果还没在Docker中安装过Centos7的话,请移步到:Docker中安装Centos7操作系统
一、安装Iptables
1、检查是否安装
[root@shendu ~]# iptables --version
iptables v1.4.21
[root@shendu ~]#
2、如果没有安装请自行使用命令:[root@shendu ~]# yum -y install iptables.services
进行安装
3、启动iptables
[root@shendu ~]#
[root@shendu ~]# systemctl start iptables
[root@shendu ~]#
4、清空现有的规则,保存规则,查看规则
[root@shendu ~]#
[root@shendu ~]# iptables -F
[root@shendu ~]#
[root@shendu ~]#
[root@shendu ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
[root@shendu ~]#
[root@shendu ~]#
[root@shendu ~]#
[root@shendu ~]# iptables -nL
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy DROP)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain DOCKER (0 references)
target prot opt source destination
Chain DOCKER-ISOLATION (0 references)
target prot opt source destination
[root@shendu ~]#
5、重新启动iptables
[root@shendu ~]#
[root@shendu ~]# systemctl restart iptables
[root@shendu ~]#
[root@shendu ~]#
发现现在客户端已经连接不上Docker安装的Centos7服务器了,但是安装Docker的系统还可以连接
果断把防火墙关闭了一下,又重新连接了一下,又可以了。
使用命令:systemcl stop iptables
关闭iptables
二、配置Iptables
- 进入iptables的配置文件
[root@shendu ~]# vi /etc/sysconfig/iptables
- 加上下面这一条,是我映射的docker的端口
-A INPUT -p tcp -m state --state NEW -m tcp --dport 10000 -j ACCEPT
郑晖同学
发布了92 篇原创文章 · 获赞 72 · 访问量 2万+
私信
关注
标签:iptables,安装,Centos7,访问,shendu,Docker,root 来源: https://blog.csdn.net/qq_17623363/article/details/103254831
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。