网站建设工作动态,公司名字大全洋气,游戏推广渠道有哪些,seo薪酬水平在Linux系统中#xff0c;可以使用iptables或firewalld#xff08;取决于系统使用的防火墙管理工具#xff09;来开启/关闭特定的端口。以下是两种情况的示例命令#xff1a;
iptables防火墙服务
chkconfig --list | grep iptables #查看防火墙的服务
chkconfig iptables…在Linux系统中可以使用iptables或firewalld取决于系统使用的防火墙管理工具来开启/关闭特定的端口。以下是两种情况的示例命令
iptables防火墙服务
chkconfig --list | grep iptables #查看防火墙的服务
chkconfig iptables off #永久关闭防火墙
chkconfig iptables on #永久开启防火墙iptables systemctl基本命令
systemctl status iptables.service #查看防火墙的状态
systemctl stop iptables.service #停止防火墙
systemctl start iptables.service #启动防火墙
systemctl restart iptables.service #重启防火墙
systemctl reload iptables.service #重载防火墙等价于restart
systemctl disable iptables.service #禁止开机启动防火墙
systemctl enable iptables.service #开机启动防火墙iptables service基本命令
service iptables status #查看防火墙状态
service iptables start #启动防火墙
service iptables stop #停止防火墙
service iptables restart #重启防火墙
service iptables try-restart #尝试重启防火墙
service iptables reload #重载防火墙
service iptables force-reload #强制重载防火墙使用iptables
开启/关闭特定端口例如开启/关闭端口80
#先查看防火墙端口规则
iptables -L -n
#或
iptables -L -n --line-number#开启80
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
#丢弃开启中的80
sudo iptables -A INPUT -p tcp --dport 80 -j DROP
#禁止80
sudo iptables -A INPUT -p tcp --dport 80 -j REJECT#防火墙指定IP允许/禁止访问指定端口
#允许访问3306
iptables -A INPUT -s 192.168.xx.x -p tcp -m tcp --dport 3306 -j ACCEPT
#禁止访问3306
iptables -A OUTPUT -s 192.168.xx.x -p tcp -m tcp --sport 3306 -j DROP使用firewalld
开启/关闭特定端口例如关闭端口80
#查看防火墙状态
firewall-cmd --state
#启动防火墙
systemctl start firewalld
#设置防火墙开机启动
systemctl enable firewalld
#暂停止防火墙
systemctl stop firewalld
#永久关闭防火墙
systemctl disable firewalld
#查看所有开放的端口
sudo firewall-cmd --zonepublic --list-ports
#开启
sudo firewall-cmd --zonepublic --add-port80/tcp --permanent
#关闭
sudo firewall-cmd --permanent --zonepublic --remove-port80/tcp
#重载
sudo firewall-cmd --reload