当前位置:首页 > linux > 正文内容

Linux防火墙端口操作

six2年前 (2024-04-29)linux1691

1. 查看防火墙的状态

firewall-cmd --statesystemctl status firewalld

active (running)-->表示防火墙已经开启;
inactive (dead)-->表示防火墙已经关闭 

2. 开关防火墙

启动防火墙:systemctl start firewalld.service

重启防火墙:systemctl restart firewalld.service

关闭防火墙:systemctl stop firewalld.service

设置开机启用防火墙:systemctl enable firewalld.service

设置开机禁用防火墙:systemctl disable firewalld.service

设置开机自启动:systemctl enable firewalld

3. 开放或者关闭服务器端口

1)查看防火墙端口

查看开放的端口:firewall-cmd --list-ports

查询防火墙所有规则:firewall-cmd --list-all

2)开放或限制端口

开放80端口:firewall-cmd --zone=public --add-port=80/tcp --permanent

关闭80端口:firewall-cmd -zone=public --remove-port=80/tcp --permanent

配置立即生效:firewall-cmd --reload

备注:

zone #作用域

add-port=80/tcp #添加端口,格式为:端口/通讯协议

permanent #永久生效,没有此参数ze重启后失效

相关文章

Linux系统 ifconfig使用不了 解决方法

1、首先需要先确认是否未配置环境变量,因为ifconfig在“/sbin/”目录,需要使用管理员用户进行操作,使用 echo %PATH 查看用户环境变量 ls /sbin | grep if...

CentOS常用基础命令大全

1.关机 (系统的关机、重启以及登出 ) 的命令 shutdown -h now 关闭系统(1) init 0 关闭系统(2) telinit 0 关闭系统(3) shutdo...

centos7修改系统时间和修改硬件时间

CentOS7的时间分为系统时间和硬件时间。二者都修改,重启系统才会永久生效。 修改步骤如下 1.查看当前系统时间 date 2.修改当前系统时间 date -s "2022-10-14 19:...

shell脚本编程:将文件中指定行的内容进行替换

(1)在文件中通过关键字查找得到其所在的行号        &nbs...

SFTP基本功之get、put命令操作

登录远程服务器 open xxx.xxx.xxx.xxx // ip get 远程文件名 本地文件名 put 本地文件名 远程文件名 服务器下载至本地 get -r xxxx.xx //...

xshell 之win控制台启动参数

-url [protocol://][user[:password]@]host[:port] xshell 启动参数 xshell -url  ftp://root:123456@192...