1. http server
复杂的有aphache, tomcat, nginx等。 其中apache只支持html这些静态网页。 像php, cgi, jsp等动态网页需要tomcat来处理。
nginx是一个反向代理服务器。 (正向代理客户端, 反向代理服务端)
简单的如busybox的httpd, python组件中的SimpleHTTPServer, 其他也可以自己简单写个http server。
记录个python的
python -m SimpleHTTPServer 9090 # 9090端口
2. netstat 查看端口状态
netstat -ntp | grep 9090
3. lsof -i # -i select IPv[46] files
river@river-VirtualBox:~/w3c_workspace/web_html$ lsof -i
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
python 3009 river 3u IPv4 32680 0t0 TCP *:9090 (LISTEN)
4. nmap # Network exploration tool and security / port scanner
# 端口扫描
river@river-VirtualBox:~/w3c_workspace/web_html$ nmap -p 0-10000 localhost
Starting Nmap 7.60 ( https://nmap.org ) at 2020-01-08 10:01 CST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000061s latency).
Not shown: 9997 closed ports
PORT STATE SERVICE
22/tcp open ssh
631/tcp open ipp
8080/tcp open http-proxy
9090/tcp open zeus-admin
6. netcat # nc — arbitrary TCP and UDP connections and listens
# BSD General Command Manual
相关功能很多, 可参考以下文档
https://www.oschina.net/translate/linux-netcat-command
关于端口扫描, 比如如下命令
river@river-VirtualBox:~/w3c_workspace/web_html$ netcat -z -v localhost 20-100
netcat: connect to localhost port 20 (tcp) failed: Connection refused
netcat: connect to localhost port 21 (tcp) failed: Connection refused
Connection to localhost 22 port [tcp/ssh] succeeded!
netcat: connect to localhost port 23 (tcp) failed: Connection refused
netcat: connect to localhost port 24 (tcp) failed: Connection refused
netcat: connect to localhost port 25 (tcp) failed: Connection refused
netcat: connect to localhost port 26 (tcp) failed: Connection refused
netcat: connect to localhost port 27 (tcp) failed: Connection refused
netcat: connect to localhost port 28 (tcp) failed: Connection refused
river@river-VirtualBox:~/w3c_workspace/web_html$ netcat -z -v localhost 9090
Connection to localhost 9090 port [tcp/*] succeeded!
7. ufw # unix firewall
NAME
ufw - program for managing a netfilter firewall
DESCRIPTION
This program is for managing a Linux firewall and aims to provide an easy to use interface for the user.
linux的防火墙进程, 具体可参考man手册。
可以使用systemd来控制,
systemctl stop ufw.service
systemctl start ufw.service
可通过
ufw命令添加/删除 屏蔽端口等
如
sudo ufw status
sudo ufw allow 9090
sudo ufw delete allow 9090