一、iptables防火墙(需要安装防火墙sudo apt-get install firewalld命令查看插件)
1、基本操作
# 查看防火墙状态service iptables status # 停止防火墙service iptables stop # 启动防火墙service iptables start # 重启防火墙service iptables restart # 永久关闭防火墙chkconfig iptables off # 永久关闭后重启chkconfig iptables on
[root@localhost /]# service iptables statusRedirecting to /bin/systemctl status iptables.serviceUnit iptables.service could not be found.
yum install iptables-services
vim /etc/sysconfig/iptables# 加入如下代码-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT#保存退出后重启防火墙service iptables restart
#查看
systemctl status firewalld
#开启防火墙
systemctl start firewalld.service
#重启防火墙
systemctl restart firewalld.service
#查看firewall防火墙的状态
firewall-cmd --state
#查看防火墙开放端口规则
firewall-cmd --list-port
#查看80端口是否开启
firewall-cmd --query-port=80/tcp
#开放80端口
firewall-cmd --permanent --add-port=80/tcp #(–permanent永久生效,没有此参数重启后就失效)
#加载生效开放的端口
firewall-cmd --reload
#查询指定端口80是否开放
firewall-cmd --query-port=80/tcp
# 移除端口
firewall-cmd --permanent --remove-port=8080/tcp