/etc/init.d/iptables status   查看当前的防火墙状态

如果返回,iptables: Firewall is not running

需要开启防火墙  service iptables start     (service iptables stop   关闭防火墙)

Linux下开启防火墙放行某个端口?

添加8080端口的开放:iptables -A INPUT -p tcp --dport 8080 -j ACCEPT (注意空格)

Linux下开启防火墙放行某个端口?

8080可以修改为任意想要放行的端口 然后就可以访问了

 

小知识:

添加防火墙规则 

-A默认是插入到尾部的,可以-I来插入到指定位置

[[email protected] ~]# iptables -I INPUT 3 -p tcp -m tcp --dport 20 -j ACCEPT  // 插入到INPUT 第3号

[[email protected] ~]# iptables -A INPUT -p tcp -m tcp --dport 21 -j ACCEPT   //开放21端口

[[email protected] ~]# iptables -R INPUT 3 -j DROP     //将规则3修改成DROP

[[email protected] ~]# iptables -D INPUT 3   //删除input的第3条规则

参考了https://blog.csdn.net/ssergsw/article/details/14168069 大神的文章

相关文章:

  • 2022-12-23
  • 2021-08-14
  • 2022-02-09
  • 2022-12-23
  • 2021-12-09
猜你喜欢
  • 2022-02-11
  • 2022-01-30
  • 2022-12-23
  • 2021-12-09
  • 2021-12-20
  • 2021-11-15
  • 2021-10-18
相关资源
相似解决方案