防火墙
1 firewalld.server 一般是linux系统自带的系统服务,
/usr/lib/systemd/system/
在/usr/lib/systemd/system下的服务,可以使用systemctl指令去操作
2 iptables 服务一般是需要自己手动安装
上面两种都是启到防火墙的作用,一般而言,二者是平级的,对于firewall调用了iptable service,
他们都需要调用linux内核
3 系统服务的操作指令 systemctl ,该指令兼容了service和chkconfig的功能于一体。
对于安装的系统服务,我们之前使用service指令进行启停服务,现在完全可以使用systemctl操作
4 实例
4.1 对于sshd服务使用service启动和使用chkconfig配置开机启动,需要使用两个指令分别操作
# 启动sshd服务
service sshd start
# 设置sshd服务开机启动
chkconfig sshd start
4.2 systemctl融合了上面两者的指令
systemctl start sshd.service //启动sshd服务
systemctl enable sshd.service //设置开机自动启动
5 查看防火墙服务
5.1 使用service启动系统服务
# 查看状态 显示是否激活
$ service firewall status
# 开启firewall服务
$ service firewall start
# 关闭服务
$ service firewall stop
# 重启服务
$ service firewall reload
chkconfig firewall start //开记启动
chkconfig firewall stop //禁止开机启动
5.2 使用systemctl操作系统服务
# 查看状态
$ systemctl status firewalld.service
$ systemctl start firewalld.service
$ systemctl reload firewalld.service
$ systemctl stop firewalld.service
# 配置是否开机启动
$ systemctl enable firewalld.service //开机启动
$ systemctl disable firewalld.service //禁止开启启动
$ yum
查看端口
# 指定端口,查看被那个应用占用
$ lsof -i:<port>
使用 netstat命令各个参数说明如下:
-t : 指明显示TCP端口
-u : 指明显示UDP端口
-l : 仅显示监听套接字(所谓套接字就是使应用程序能够读写与收发通讯协议(protocol)与资料的程序)
-p : 显示进程标识符和程序名称,每一个套接字/端口都属于一个程序。
-n : 不进行DNS轮询,显示IP(可以加速操作)
$ netstat -tunpl | grep <port>