firewall-cmd 筆記

不得不說 centos 7 讓我用得很痛苦 XD 原本是用 setup 就可以設定防火牆了. 現在預設是使用 firewall 當然可以用下列指令把它改回來

# systemctl disable firewalld
# systemctl stop firewalld
# yum install iptables-services
# systemctl start iptables
# systemctl start ip6tables
# systemctl enable iptables
# systemctl enable ip6tables

不過還是算了. 用預設的看看好了

先取得目前有的 zone

# firewall-cmd –get-active-zones

一般而言預設的話都會有一個 public

下列指令是開 http 服務

# firewall-cmd –permanent –zone=public –add-service=http

也可以用下列指令指定 port

# firewall-cmd –permanent –zone=public –add-port=8080/tcp

設定好後記得 reload

# firewall-cmd –reload

用下列指令檢查狀態

# firewall-cmd –zone=public –list-all

# firewall-cmd –get-active-zones
# firewall-cmd –zone=public –add-port=80/tcp –permanent
# firewall-cmd –zone=public –add-port=443/tcp –permanent
# firewall-cmd –reload

Leave a Reply

Your email address will not be published. Required fields are marked *