Vultr CentOS 7 firewalld防火墙打开,关闭等常用设置命令
- 行业动态
- 2024-03-21
- 2
打开防火墙: sudo systemctl start firewalld,关闭 防火墙: sudo systemctl stop firewalld,重启防火墙: sudo systemctl restart firewalld,查看防火墙状态: sudo systemctl status firewalld
Vultr CentOS 7 firewalld防火墙打开、关闭等常用设置命令
1、打开firewalld防火墙:
“`
sudo systemctl start firewalld
“`
2、关闭firewalld防火墙:
“`
sudo systemctl stop firewalld
“`
3、查看firewalld防火墙状态:
“`
sudo systemctl status firewalld
“`
4、开机自启动firewalld防火墙:
“`
sudo systemctl enable firewalld
“`
5、取消开机自启动firewalld防火墙:
“`
sudo systemctl disable firewalld
“`
6、重新加载firewalld防火墙配置:
“`
sudo firewallcmd reload
“`
7、查看当前firewalld防火墙规则:
“`
sudo firewallcmd listall
“`
8、添加端口转发规则(以端口转发TCP协议的80端口为例):
“`
sudo firewallcmd permanent addforwardport=port=80:proto=tcp:toport=8080
“`
9、删除端口转发规则(以删除上述添加的端口转发规则为例):
“`
sudo firewallcmd permanent removeforwardport=port=80:proto=tcp:toport=8080
“`
10、允许特定IP访问(以允许IP地址为192.168.1.100的主机访问为例):
“`
sudo firewallcmd permanent addrichrule=’rule family="ipv4" source address="192.168.1.100" port protocol="tcp" port="80" accept’
“`
11、拒绝特定IP访问(以拒绝IP地址为192.168.1.100的主机访问为例):
“`
sudo firewallcmd permanent addrichrule=’rule family="ipv4" source address="192.168.1.100" reject’
“`
相关问题与解答:
问题1:如何查看firewalld防火墙是否已经安装?
解答:可以使用以下命令查看firewalld防火墙是否已经安装:rpm qa | grep firewalld,如果已经安装,会显示类似于firewalld0.7.45.el7.x86_64的结果,如果没有安装,则不会显示任何结果。
问题2:如何在firewalld防火墙中开放某个端口?
解答:可以使用以下命令在firewalld防火墙中开放某个端口(以开放TCP协议的80端口为例):sudo firewallcmd zone=public addport=80/tcp permanent,这将永久开放TCP协议的80端口,如果要开放UDP协议的端口,可以将addport=80/tcp替换为addport=80/udp。
本站发布或转载的文章及图片均来自网络,其原创性以及文中表达的观点和判断不代表本站,有问题联系侵删!
本文链接:http://www.xixizhuji.com/fuzhu/186377.html