This article tells about several elements:
- What are the firewall and work is
- Use firewalld the firewall management
First, what is firewall
It is a combination of software and hardware together, between the internal network and external networks, configured on the border between the private network and the public network protective barrier (defined Baidu Encyclopedia). Firewall is a protective barrier, a barrier.
As with real walls that can protect the wall stuff, but this wall can open a lot of doors (port). Firewall played reject all traffic without permission to access the server.
But sometimes we need to open some ports so that other machines can access the server, so you need to make some firewall settings
Second, the use firewalld the firewall management (centos7 for release)
1, the installation firewalld
First check firewalls status
systemctl status firewalld
If the "running" state occurs is illustrated in FIG firewalld in running
if the firewall is not installed, the installation via yum
yum install firewalld
2, firewalld commonly used commands
1, start, stop, view firewalld
systemctl start firewalld #启动
systemctl stop firewalld #停止
systemctl status firewalld #查看firewalld状态
2, for the operation of the port
firewall-cmd --zone=public --list-ports #查看所有打开的端口
firewall-cmd --zone=public --query-port=80/tcp #查看指定端口是否打开
firewall-cmd --zone=public --add-port=80/tcp --permanent #开放一个新端口 没有--permanent防火墙规则更新后端口会消失
firewall-cmd --zone=public --remove-port=80/tcp --permanent #删除指定端口
firewall-cmd --reload #重载防火墙规则