File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ title : " Linux中网络相关的命令"
3+ date : 2025-05-07 20:51:47
4+ updated : 2025-05-07 20:59:43
5+ tags :
6+ - 网络
7+ - 常用软件
8+ - 终端工具
9+ categories : 终端相关
10+ comments : false
11+ ---
12+ # 写在前面
13+
14+ 目前用到的有:
15+ - ping
16+ - ifconfig
17+ - curl
18+ - netstat
19+ - nc
20+ - route
21+ - lsof
22+
23+ 软件:
24+ - frp
25+ - chisel
26+ - rsync & scp
27+ - proxychains
28+
29+ # 命令介绍
30+
31+ ## route
32+
33+ 如果有多张网卡启用:
34+ - en0 wifi
35+ - en12 有线宽带
36+
37+ 使用这个命令添加路由:使 向 10.10.5.4 的流量 走 10.11.3.254 网关 gate_way
38+ ``` shell
39+ sudo route -n add 10.10.5.4 10.11.3.254
40+ ```
41+
42+ 查看路由表:[ netstat] ( #netstat )
43+
44+ ## netstat
45+
46+ 查看路由表:
47+ ``` shell
48+ netstat -rn
49+ ```
50+
51+ ## lsof
52+
53+ 查看端口被哪个进程占用:
54+ ``` shell
55+ lsof -i :< port>
56+ ```
57+
58+ ## curl
59+
60+ 几个好用的URL:
61+ - cip.cc
62+ - ifconfig.me
63+ - ipinfo.io
64+
65+
66+ ## nc
67+
Original file line number Diff line number Diff line change @@ -65,6 +65,8 @@ ssh REMOTE "shell"
6565
6666# 认证后 把 ssh 进程 放在后台
6767# 这个一般搭配 端口转发 或者 传入让 远程机器执行的 命令
68+ # 后面要加一个 command 例如 sleep true 之类的
69+ # 端口转发时候想常驻链接 可以用 死循环 "while true;do sleep 1;done"
6870-f
6971
7072# 允许 允许非本机 通过局域网 连接本地转发的端口 大概是这样
@@ -132,6 +134,11 @@ ssh -L 9999:<remote addr>:8888 user@remote_host
132134 所有发往本地 9999 端口的流量 会通过 ssh 隧道 转发到远程 remote 上的 `remote addr:9999`
133135- 打开一个shell(如果不像打开shell 可以用 -f 在后台运行,可以使用 -g 允许局域网内的连接)
134136
137+ 举个例子:比如我要用 T4 localhost:7860 的服务 我就可以:
138+ ``` shell
139+ ssh -4(指定ipv4) -f -L 7860:localhost:7860 ICCT-T " while true;do sleep 10;done"
140+ ```
141+
135142### 远程转发 - 访问远程的流量 F 本地
136143
137144` ssh -R ` 用于把 远程端口 的流量 转发到 本地的某个端口上。也就是允许 远程机器访问本地的服务。
@@ -165,3 +172,4 @@ Host <别名>
165172 RemoteForward 9090 localhost:90
166173 Compression yes # 压缩流量 用于节省带宽
167174```
175+
Original file line number Diff line number Diff line change 1+ ---
2+ title: "Linux中网络相关的命令"
3+ date: 2025-05-07 20:51:47
4+ updated: 2025-05-07 20:59:43
5+ tags:
6+ - 网络
7+ - 常用软件
8+ - 终端工具
9+ categories: 终端相关
10+ comments: false
11+ ---
12+ # 写在前面
13+
14+ 目前用到的有:
15+ - ping
16+ - ifconfig
17+ - curl
18+ - netstat
19+ - nc
20+ - route
21+ - lsof
22+
23+ 软件:
24+ - frp
25+ - chisel
26+ - rsync & scp
27+ - proxychains
28+
29+ # 命令介绍
30+
31+ ## route
32+
33+ 如果有多张网卡启用:
34+ - en0 wifi
35+ - en12 有线宽带
36+
37+ 使用这个命令添加路由:使 向 10.10.5.4 的流量 走 10.11.3.254 网关 gate_way
38+ ```shell
39+ sudo route -n add 10.10.5.4 10.11.3.254
40+ ```
41+
42+ 查看路由表:[netstat](#netstat)
43+
44+ ## netstat
45+
46+ 查看路由表:
47+ ```shell
48+ netstat -rn
49+ ```
50+
51+ ## lsof
52+
53+ 查看端口被哪个进程占用:
54+ ```shell
55+ lsof -i :<port>
56+ ```
57+
58+ ## curl
59+
60+ 几个好用的URL:
61+ - cip.cc
62+ - ifconfig.me
63+ - ipinfo.io
64+
65+
66+ ## nc
67+
Original file line number Diff line number Diff line change @@ -65,6 +65,8 @@ ssh REMOTE "shell"
6565
6666# 认证后 把 ssh 进程 放在后台
6767# 这个一般搭配 端口转发 或者 传入让 远程机器执行的 命令
68+ # 后面要加一个 command 例如 sleep true 之类的
69+ # 端口转发时候想常驻链接 可以用 死循环 "while true;do sleep 1;done"
6870-f
6971
7072# 允许 允许非本机 通过局域网 连接本地转发的端口 大概是这样
@@ -132,6 +134,11 @@ ssh -L 9999:<remote addr>:8888 user@remote_host
132134 所有发往本地 9999 端口的流量 会通过 ssh 隧道 转发到远程 remote 上的 `remote addr:9999`
133135- 打开一个shell(如果不像打开shell 可以用 -f 在后台运行,可以使用 -g 允许局域网内的连接)
134136
137+ 举个例子:比如我要用 T4 localhost:7860 的服务 我就可以:
138+ ```shell
139+ ssh -4(指定ipv4) -f -L 7860:localhost:7860 ICCT-T "while true;do sleep 10;done"
140+ ```
141+
135142### 远程转发 - 访问远程的流量 F 本地
136143
137144`ssh -R` 用于把 远程端口 的流量 转发到 本地的某个端口上。也就是允许 远程机器访问本地的服务。
@@ -165,3 +172,4 @@ Host <别名>
165172 RemoteForward 9090 localhost:90
166173 Compression yes # 压缩流量 用于节省带宽
167174```
175+
Original file line number Diff line number Diff line change @@ -165,4 +165,3 @@ Host <别名>
165165 RemoteForward 9090 localhost:90
166166 Compression yes # 压缩流量 用于节省带宽
167167```
168-
Original file line number Diff line number Diff line change 1515网络
1616终端模拟器
1717kitty
18+ 终端工具
You can’t perform that action at this time.
0 commit comments