2019-09-18 nmap & firewall-cmd
2019-12-09 本文已影响0人
Ztry
Centos7x64使用中遇到的问题
1. 安装nginx顺利完成,却无法通过IP访问
- 使用nmap扫描端口,看看80端口是否有开放
yum install nmap #输入y安装 nmap localhost #查看主机当前开放的端口 nmap -p 1024-65535 localhost #查看主机端口(1024-65535)中开放的端口 nmap -PS ip #探测目标主机开放的端口 nmap -PS22,80,3306 ip #探测所列出的目标主机端口 nmap -O ip #探测目标主机操作系统类型 nmap -A ip #探测目标主机操作系统类型 nmap --help #更多nmap参数请查询帮助信息
- 发现80端口没有开放,通过防火墙开启端口
firewall-cmd --list-ports # 查看已经开放的端口 firewall-cmd --zone=public --add-port=80/tcp --permanent # –zone:作用域;–add-port=80/tcp #添加端口,格式为:端口/通讯协议;–permanent #永久生效,没有此参数重启后失效 firewall-cmd --reload #重启firewall systemctl status firewalld # firewall状态 systemctl start firewalld # 开启firewall systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service #禁止firewall开机启动
- 常用输入命令行时的操作
# 输入命令行时,ctrl+c,重新输入 # 输入命令行时,ctrl+l,清空,=clear # 输入命令行时,ctrl+w,往回删除一个单词,光标放在最末尾 # 输入命令行时,ctrl+k,往前删除到末尾,光标放在最前面(可以使用ctrl+a) # 输入命令行时,ctrl+u 删除光标以前的字符 # 输入命令行时,ctrl+k 删除光标以后的字符 # 输入命令行时,ctrl+a 移动光标至的字符头 # 输入命令行时,ctrl+e 移动光标至的字符尾
- 开放端口后,扫描也出现了80端口,但是ip还是访问不到,就重启了下nginx就可以了
nginx # 直接启动 systemctl start nginx.service # 通用型服务启动 ps aux | grep nginx # 查看nginx是否启动,有3条记录就代表nginx正常启动 nginx -s stop # 立即停止服务 nginx -s quit # 从容停止服务 killall nginx # 杀死进程 systemctl stop nginx.service # systemctl 停止 systemctl restart nginx.service # systemctl 重启 nginx -s reload # 重新载入配置文件 netstat -tlnp # 看端口号的占用情况