1、firewalld的基本使用
启动: systemctl start firewalld关闭: systemctl stop firewalld查看状态: systemctl status firewalld开机禁用 : systemctl disable firewalld开机启用 : systemctl enable firewalld临时关闭:systemctl stop firewalld重启:systemctl enable firewalld
2.systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。
启动一个服务:systemctl start firewalld.service关闭一个服务:systemctl stop firewalld.service重启一个服务:systemctl restart firewalld.service显示一个服务的状态:systemctl status firewalld.service在开机时启用一个服务:systemctl enable firewalld.service在开机时禁用一个服务:systemctl disable firewalld.service查看服务是否开机启动:systemctl is-enabled firewalld.service查看已启动的服务列表:systemctl list-unit-files|grep enabled查看启动失败的服务列表:systemctl --failed
3.配置firewalld-cmd
查看版本: firewall-cmd --version查看帮助: firewall-cmd --help显示状态: firewall-cmd --state查看所有打开的端口: firewall-cmd --zone=public --list-ports更新防火墙规则: firewall-cmd --reload查看区域信息: firewall-cmd --get-active-zones查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0拒绝所有包:firewall-cmd --panic-on取消拒绝状态: firewall-cmd --panic-off查看是否拒绝: firewall-cmd --query-panic
那怎么开启一个端口呢
添加
firewall-cmd —zone=public —add-port=5432/tcp —permanent (—permanent永久生效,没有此参数重启后失效)
重新载入
firewall-cmd —reload
查看
firewall-cmd —zone=public —query-port=80/tcp
删除
firewall-cmd —zone=public —remove-port=80/tcp —permanent
netstat命令
netstat -tunlp 用于显示 tcp,udp 的端口和进程等相关情况。
netstat 查看端口占用语法格式:
netstat -tunlp | grep 端口号
- -t (tcp) 仅显示tcp相关选项
- -u (udp)仅显示udp相关选项
- -n 拒绝显示别名,能显示数字的全部转化为数字
- -l 仅列出在Listen(监听)的服务状态
- -p 显示建立相关链接的程序名
netstat -tuln 查询当前计算机下开了哪些端口
netstat -an 查看所有端口信息
netstat -rn 查看路由
chown 修改文件和文件夹的用户和用户组属性
chmod 修改文件和文件夹读写执行属性
