CentOS开启指定端口
<p>验证端口是否开启,如要验证服务器9998端口是否开启:</p><pre>sudo firewall-cmd --query-port=9998/tcp</pre>
<p>结果如下:</p>
<pre>no</pre>
<p>表明当前端口没有开启。</p>
<p>开启9998端口</p>
<p><strong>1、运行命令:</strong></p>
<pre>firewall-cmd --get-active-zones</pre>
<p>运行完成之后,可以看到zone名称,如下:</p>
<pre>public
interfaces: eth0
</pre>
<p><strong>2、再执行如下命令:</strong></p>
<pre>firewall-cmd --zone=public --add-port=9998/tcp --permanent</pre>
<p>显示如下:</p>
<pre>success</pre>
<p><strong>3、设置完需重启防火墙,运行命令:</strong></p>
<pre>firewall-cmd --reload</pre>
<p>成功重启如下:</p>
<pre>success</pre>
<p><strong>4、查看端口号是否开启,运行命令:</strong></p>
<pre>firewall-cmd --query-port=9998/tcp</pre>
<p>结果如下:</p>
<pre>yes</pre>
<p class="post-copyright">未经允许不得转载:<ahref="https://www.wangchao.info/">王超博客</a> » <ahref="https://www.wangchao.info/1925.html">CentOS开启指定端口</a></p>
页:
[1]