Linux防火墙常用操作及端口开放

Linux防火墙常用操作及端口开放

1.查看防火墙状态

firewall-cmd --state

2.开启防火墙

systemctl start firewalld.service

3.开启指定端口

firewall-cmd --zone=public --add-port=3306/tcp --permanent

firewall-cmd --zone=public --add-port=6379/tcp --permanent

显示success表示成功

--zone=public表示作用域为公共的

--add-port=443/tcp添加tcp协议的端口端口号为443

--permanent永久生效,如果没有此参数,则只能维持当前服务生命周期内,重新启动后失效;

4.重启防火墙

systemctl restart firewalld.service

5.重新加载防火墙

firewall-cmd --reload

6.其他命令

#查看已开启的端口

firewall-cmd --list-ports

#关闭指定端口

firewall-cmd --zone=public --remove-port=8080/tcp --permanent

systemctl restart firewalld.service

firewall-cmd --reload

#查看端口被哪一个进程占用

netstat -lnpt |grep 5672

#安装 net-tools

yum install -y net-tools

7.注意事项

telnet 42.193.96.174 3306

当在Linux中成功开启了某个端口,但是远程telnet还是无法ping通,是正常的;

因为3306端口没有被Linux进程监听,换句话说,就是该端口上没有运行任何程序;

如果这时,我将Mysql在Linux中启动,并配置完成,那么远程telnet该端口是可以成功的;

相关推荐
小阳睡不醒25 分钟前
小白成长之路-jenkins使用pipline部署
运维·jenkins
非ban必选1 小时前
netty-scoket.io路径配置
java·服务器·前端
fasewer1 小时前
玄机--windows日志分析
运维·服务器·windows·网络安全
Linux运维技术栈1 小时前
域名网页加载慢怎么解决:从测速到优化的全链路性能优化实战
运维·网络·nginx·性能优化·cloudflare
会开花的二叉树1 小时前
彻底搞懂 Linux 基础 IO:从文件操作到缓冲区,打通底层逻辑
linux·服务器·c++·后端
呼啦啦5612 小时前
【Linux】权限
linux·权限
晨曦5432102 小时前
零基础12周精通Linux学习计划
linux
linux修理工2 小时前
n1 Armbian OS 24.11.0 noble 安装suricata
linux·运维·服务器
傅里叶2 小时前
sudo启动Flutter程序AMD初始化失败
linux·flutter
bug攻城狮2 小时前
CentOS 7 出现 “Could not resolve host“ 错误的修复方案
linux·运维·centos