Centos7(Firewall)防火墙开启常见端口命令
安装Firewall命令:
yuminstallfirewalldfirewalld-config
Firewall开启常见端口命令:
firewall-cmd--zone=public--add-port=80/tcp--permanent
firewall-cmd--zone=public--add-port=443/tcp--permanent
firewall-cmd--zone=public--add-port=22/tcp--permanent
firewall-cmd--zone=public--add-port=21/tcp--permanent
firewall-cmd--zone=public--add-port=53/udp--permanent
Firewall关闭常见端口命令:
firewall-cmd--zone=public--remove-port=80/tcp--permanent
firewall-cmd--zone=public--remove-port=443/tcp--permanent
firewall-cmd--zone=public--remove-port=22/tcp--permanent
firewall-cmd--zone=public--remove-port=21/tcp--permanent
firewall-cmd--zone=public--remove-port=53/udp--permanent
批量添加区间端口
firewall-cmd--zone=public--add-port=4400-4600/udp--permanent
firewall-cmd--zone=public--add-port=4400-4600/tcp--permanent
开启防火墙命令:
systemctlstartfirewalld.service
重启防火墙命令:
firewall-cmd--reload或者servicefirewalldrestart
查看端口列表:
firewall-cmd--permanent--list-port
禁用防火墙
systemctlstopfirewalld
设置开机启动
systemctlenablefirewalld
停止并禁用开机启动
sytemctldisablefirewalld
查看状态
systemctlstatusfirewalld或者firewall-cmd--state