linux/ubuntu 端口开放

转载于:https://blog.csdn.net/zhang201322/article/details/52093683

在ubuntu下面开放端口好像主要有两种方法,一种是ubuntu自带的防火墙,一种是iptables,这里我们主要使用iptables。本文的系统版本为ubuntu14.04和ubuntu16.04

安装iptables

一般情况下,ubuntu安装好的时候,iptables会被安装上,没有安装上也没啥,一条命令就可以安装了。

apt-get install iptables
  
  

    安装好了之后就可以添加规则了

    iptables -I INPUT -p tcp --dport 80 -j ACCEPT
      
      

      然后可以直接保存了

      iptables-save
        
        

        持久化iptables

        上文那样做只是暂时保存了开放端口的信息,如果服务器重启,保存的信息就掉了,所以我们需要持久化一下端口信息,这里我们使用 iptables-persistent

        安装iptables-persistent

        apt-get install iptables-persistent
          
          

          持久化信息

          service iptables-persistent save
          

          猜你喜欢

          转载自blog.csdn.net/QEcode/article/details/83718346
          今日推荐