网站首页 > 技术教程 正文
Linux 端口的开启
- Linux 端口的开启
- 一、firewall 方式 (centOS7.*)
- 二、修改 iptables 方式 (centOS6.*)
一、firewall 方式 (centOS7.*)
- 查看防火墙状态
firewall-cmd --state
如果返回的是 “not running”,那么需要先开启防火墙;
- 开启防火墙
systemctl start firewalld.service
再次查看防火墙状态,发现已开启!
- 开启指定端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
显示 success 表示成功
–zone=public 表示作用域为公共的
–add-port=443/tcp 添加 tcp 协议的端口端口号为 443
–permanent 永久生效,如果没有此参数,则只能维持当前 服 务生命周期内,重新启动后失效;
- 重启防火墙
systemctl restart firewalld.service
系统没有任何提示表示成功!
- 重新加载防火墙
firewall-cmd --reload
显示 success 表示成功
- 其他命令
#查看已开启的端口
firewall-cmd --list-ports
#关闭指定端口
firewall-cmd --zone=public --remove-port=8080/tcp --permanent
systemctl restart firewalld.service
firewall-cmd --reload
#查看端口被哪一个进程占用
netstat -lnpt |grep 5672
# centos7默认没有 netstat 命令,需要安装 net-tools 工具:
# 安装 net-tools
yum install -y net-tools
# 临时关闭防火墙
systemctl stop firewalld.service
# 或者
systemctl stop firewalld
# 永久关闭防火墙(必须先临时关闭防火墙,再执行该命令,进行永久关闭)
systemctl disable firewalld.service
# 或者
systemctl disable firewalld
二、修改 iptables 方式 (centOS6.*)
centOS6.* 的linux版本是自带iptables的,所以可以直接使用该方式,centOS7 不自带iptables的,所以要使用该方式,需要手动安装iptables后,再使用该方式!
2.1 修改 iptables 文件
#修改iptables
[root@localhost sbin]# vi /etc/sysconfig/iptables
2.2 重启防火墙
[root@localhost sbin]# /etc/init.d/iptables restart
三、注意事项
当在 Linux 中成功开启了某个端口,但是远程 telnet 还是无法 ping 通,是正常的!
因为 3306 端口没有被 Linux 进程监听,换句话说,就是该端口上没有运行任何程序!!!
如果这时,我将 Mysql 在 Linux 中启动,并配置完成,那么远程 telnet 该端口是可以成功的!!!
猜你喜欢
- 2025-06-13 linux关闭占用特定端口的进程(linux关闭所有端口)
- 2025-06-13 端口被占用怎么办(端口被占用什么意思)
- 2025-06-13 Linux: SSH隧道 (端口转发)(ssh隧道远程转发)
- 2025-06-13 如何解决Linux下侦听端口被占用(linux监听80端口)
- 2025-06-13 Linux普通账户启动应用程序时监听1024以下端口好方法
- 2025-06-13 Linux 系统下如何结束一个特定端口上的进程 ?赶紧收藏!
- 2025-06-13 Linux 或 Windows 上实现端口映射
- 2025-06-13 linux下端口与进程互查(linux进程端口号查询)
- 2025-06-13 在Linux中杀死特定端口上运行的进程
- 2025-06-13 服务器远程端口是什么及简单介绍(服务器配置远程端口)
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)