CentOS7 开放,关闭端口,防火墙

CentOS7 开放,关闭端口,防火墙

端口号

开放

# 开放端口号
firewall-cmd --zone=public --add-port=80/tcp --permanent
#说明:
#–zone #作用域
#–add-port=80/tcp #添加端口,格式为:端口/通讯协议
#–permanent 永久生效,没有此参数重启后失效
 
#多个端口:
firewall-cmd --zone=public --add-port=80-90/tcp --permanent

查看

#centos7查看防火墙所有信息
firewall-cmd --list-all
#centos7查看防火墙开放的端口信息
firewall-cmd --list-ports

# 查看监听服务
netstat -ntlp

#  查看本机已经启用的监听端口:
# centos7以下使用
netstat -ant
# 7 可以使用 ss
ss -ant

删除

#删除
firewall-cmd --zone=public --remove-port=80/tcp --permanent

防火墙

 #centos7启动防火墙
systemctl start firewalld.service

#centos7停止防火墙/关闭防火墙
systemctl stop firewalld.service

#centos7重启防火墙
systemctl restart firewalld.service

# 查看当前防火墙状态
firewall-cmd --state
# not running 关闭状态
# running 开启状态
 
#设置开机启用防火墙
systemctl enable firewalld.service

#设置开机不启动防火墙
systemctl disable firewalld.service

#  查看防火墙设置开机自启是否成功
systemctl is-enabled firewalld.service;echo $?
#	disabled
#	1
#    没有开机启动

# 	enabled
# 	0
#   开机启动成功
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值