在ubuntu下面开放端口好像主要有两种方法,一种是ubuntu自带的防火墙,一种是iptables,这里我们主要使用iptables。本文的系统版本为ubuntu14.04和ubuntu16.04
安装iptables
一般情况下,ubuntu安装好的时候,iptables会被安装上,没有安装上也没啥,一条命令就可以安装了。
apt-get install iptables
1
安装好了之后就可以添加规则了
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
1
然后可以直接保存了
iptables-save
1
持久化iptables
上文那样做只是暂时保存了开放端口的信息,如果服务器重启,保存的信息就掉了,所以我们需要持久化一下端口信息,这里我们使用 iptables-persistent
安装iptables-persistent
apt-get install iptables-persistent
1
持久化信息
service iptables-persistent save
————————————————
版权声明:本文为CSDN博主「ThunderingII」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/zhang201322/article/details/52093683/