网站首页 > linux / 正文
防火墙
我们都知道,外部网络想要访问虚拟机内部的linux系统,一定是要将linux防火墙开放对应端口或者直接关闭防火墙,不然外部连接会出现很大问题。
Linux中有两种防火墙软件,ConterOS7.0以上使用的是firewall,ConterOS7.0以下使用的是iptables
防火墙根据配置文件/etc/sysconfig/iptables来控制本机的”出”、”入”网络访问行为。
firewall
- 开启防火墙:
systemctl start firewalld
- 关闭防火墙:
systemctl stop firewalld
- 查看防火墙状态:
systemctl status firewalld
- 设置开机启动:
systemctl enable firewalld
- 禁用开机启动:
systemctl disable firewalld
- 重启防火墙:
firewall-cmd --reload
- 开放端口(修改后需要重启防火墙方可生效):
firewall-cmd --zone=public --add-port=8080/tcp --permanent
- 查看开放的端口:
firewall-cmd --list-ports
- 关闭端口:
firewall-cmd --zone=public --remove-port=8080/tcp --permanent
Iptables
安装
由于CenterOS7.0以上版本并没有预装Iptables,我们需要自行安装。因为centos7以上用firewall,所以暂时不用管iptables
- 安装前先关闭firewall防火墙
- 安装iptables:
yum install iptables
- 安装iptables-services:
yum install iptables-services
使用
- 开启防火墙:
systemctl start iptables.service
- 关闭防火墙:
systemctl stop iptables.service
- 查看防火墙状态:
systemctl status iptables.service
- 设置开机启动:
systemctl enable iptables.service
- 禁用开机启动:
systemctl disable iptables.service
Tags:关闭linux防火墙命令
猜你喜欢
- 2024-11-26 CentOS7 设置防火墙、开放指定端口操作
- 2024-11-26 Linux系统中的防火墙主要有两种
- 2024-11-26 Iptables 教程 – 使用 Linux 防火墙保护 Ubuntu VPS
- 2024-11-26 Centos7版本不能解压*.zip格式文件
- 2024-11-26 什么是linux防火墙?让首批红帽授权认证专家为你详细解答
- 2024-11-26 学习笔记-Linux 防火墙 - Firewall-cmd
- 2024-11-26 Linux防火墙Iptables与Firewalld的学习总结!PDF版可领取
- 2024-11-26 Linux防火墙基础和iptables命令文档,看完终于明白了
- 2024-11-26 linux怎么看防火墙是否开启?删除iptables规则
- 2024-11-26 linux命令-centos7防火墙