如何在 Linux 中打开端口 [英] How to open port in Linux

查看:20
本文介绍了如何在 Linux 中打开端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了在 RHEL (centOS) 上的 8080 端口上运行的 Web 应用程序.我只有命令行访问那台机器.我试图从我通过命令行连接到服务器的 Windows 机器访问该应用程序,但它给出了连接超时错误.

I have installed and web application which is running on port 8080 on RHEL (centOS). I only have command line access to that machine. I have tried to access that application from my windows machine from which I am connected to server via command-line, but it is giving connection time out error.

然后我尝试打开端口 8080.我在 iptables 中添加了以下条目.

Then I have tried to open port 8080. I have added following entry into the iptables.

-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT

将其添加到 iptables 后,我重新启动了它 -/etc/init.d/iptables 重启

After adding this into the iptables I have restarted it with - /etc/init.d/iptables restart

但我仍然无法从我的 Windows 机器访问该应用程序.

But still I am not able to access that application from my windows machine.

我是否做错了什么或遗漏了什么?

Am I doing any mistake or missing something?

推荐答案

首先,你应该禁用 selinux,编辑文件 /etc/sysconfig/selinux 使它看起来像这个:

First, you should disable selinux, edit file /etc/sysconfig/selinux so it looks like this:

SELINUX=disabled
SELINUXTYPE=targeted

保存文件并重启系统.

然后你可以将新规则添加到iptables:

Then you can add the new rule to iptables:

iptables -A INPUT -m state --state NEW -p tcp --dport 8080 -j ACCEPT

然后用 /etc/init.d/iptables restart 重启 iptables

如果它不起作用,您应该检查其他网络设置.

If it doesn't work you should check other network settings.

这篇关于如何在 Linux 中打开端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆