Linux网络端口相关

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值