Linux 下指定端口开放访问权限 - Grey Zeng
source link: https://www.cnblogs.com/greyzeng/p/16796899.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Linux 下指定端口开放访问权限
作者:Grey
原文地址:
环境#
CentOS 系和 Debian 系的防火墙开放的命令有一些差异,关于Linux 的安装可以参考:Linux 安装,快照,克隆
CentOS 开放指定端口#
例如要开放 8808 端口,执行
firewall-cmd --zone=public --add-port=8888/tcp --permanent
其中--zone
表示作用域;
--add-port=8808/tcp
表示指定开放的端口,其格式为【端口/通讯协议】
--permanent
表示永久生效,如果没有配置此参数,重启后配置会失效。
然后重启防火墙
firewall-cmd --reload
查看防火墙规则,用如下命令
iptables -L
Debian 系开放指定端口#
首先,需要安装 iptables,执行
apt-get update
apt-get install iptables
假设要开放 8088 端口,执行
iptables -I INPUT -p tcp --dport 8888 -j ACCEPT
然后保存规则
iptables-save
设置完就已经开放了指定的端口,但重启后会失效,下面设置持续生效规则;
安装 iptables-persistent
apt-get install iptables-persistent
然后执行如下两个命令
netfilter-persistent save
netfilter-persistent reload
设置完成后,即使重启,配置也不会失效。
更多#
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK