This commit is contained in:
2025-10-19 17:55:16 +08:00
parent 53b962a4e0
commit 09497cb6ab
3 changed files with 82 additions and 2 deletions

View File

@@ -10,6 +10,10 @@ const links = [
link: './mz/',
title: 'Dnake的adb 的快捷指令,相关资料',
},
{
link: './ip/',
title: 'IP 相关文档, IPTABLES 配置如何从A 局域网 ping 同B 局域网',
}
];
---

65
docs/src/pages/ip.mdx Normal file
View File

@@ -0,0 +1,65 @@
# iptables
## 提示词
有一个andorid有两个网口一个网口是A局域网一个是B局域网。A 的地址是 192.168.3.3,名字叫 A地址B 地址是 192.168.9.57 名字叫 B 地址, 如何实现A局域网下的有一个设备能直接访问B局域网的 一个设备比如192.168.9.4这是 C 设备他是是B的局域网内的. 要从192.168.3.33 的 D 设备D 设备是 MAC 设备,是 A 局域网的。A 局域网的 D需要访问到 B 局域网中的 192.168.9.4的设备 C如何配置
## 开启 iptables
```sh
# 查看当前状态
cat /proc/sys/net/ipv4/ip_forward
# 启用 IP 转发(需要 root
echo 1 > /proc/sys/net/ipv4/ip_forward
# 禁用 IP 转发
echo 0 > /proc/sys/net/ipv4/ip_forward
```
## 查看网卡信息
```sh
ip link
ip addr show eth0 # 查看 eth0 网卡信息
ip addr show eth1 # 查看 eth1 网卡信息
```
### 设置静态路由
```
ip route add 192.168.3.0/24 dev eth1
ip route add 192.168.9.0/24 dev eth0
```
### 开启路由
```sh
iptables -t nat -A POSTROUTING -s 192.168.3.0/24 -d 192.168.9.0/24 -j MASQUERADE
iptables -A FORWARD -s 192.168.3.0/24 -d 192.168.9.0/24 -j ACCEPT
iptables -A FORWARD -d 192.168.3.0/24 -s 192.168.9.0/24 -j ACCEPT
# 删除配置
# 删除 NAT 表中的 MASQUERADE 规则
iptables -t nat -D POSTROUTING -s 192.168.3.0/24 -d 192.168.9.0/24 -j MASQUERADE
# 删除 FORWARD 链中的规则
iptables -D FORWARD -s 192.168.3.0/24 -d 192.168.9.0/24 -j ACCEPT
iptables -D FORWARD -d 192.168.3.0/24 -s 192.168.9.0/24 -j ACCEPT
```
### 本地 mac 192.168.3.33
```sh
sudo route -n add 192.168.9.0/24 192.168.3.3
# 验证路由是否添加成功
netstat -nr | grep 192.168.3
## 添加失败就先删除
sudo route -n delete 192.168.3.0/24
# 删除 Mac 上添加的路由
sudo route -n delete 192.168.9.0/24 192.168.3.3
ping 192.168.9.4
```

View File

@@ -37,6 +37,11 @@ adb shell tcpdump -i any -s 0 -w /sdcard/dnake.pcap
# 下载抓包文件
adb pull /sdcard/dnake.pcap .
# 使用 Wireshark 打开 dnake.pcap 进行分析
# 抓包只抓目的地址为
adb shell tcpdump -i any -s 0 -w /sdcard/remote.pcap dst 192.168.9.4
```
## dnake 楼道内网网卡 192.168.9.57
@@ -56,9 +61,15 @@ adb connect 192.168.3.3:5555
adb shell
adb kill-server
adb start-server
# 从家庭内网跳转到楼道内网
adb connect 192.168.9.57:5555
adb shell
adb connect 192.168.9.4:5555
adb disconnect 192.168.9.4:5555
# 指定连接到具体设备的shell
adb -s 192.168.9.4:5555 shell
```
### 管理的admin界面 8080