networking - 在同一子网上配置 2 个 NIC
问题描述
出于调试目的,我需要在 2 个设备之间设置 MITM 代理。所有设备都具有静态 IP(示例)并且彼此直接连接:
Device 1 : 192.168.10.50
Device 2 : 192.168.10.60
代理计算机在同一子网上有 2 个网卡,并且位于其他设备之间:
D1 .50 <=> [.60 PROXY .50] <=> D2 .60
我的问题是,如果 2 个 nic 之一被禁用,则 D1 或 D2 可以从代理访问代理。
一旦我调出 2 nic,没有人可以看到任何其他设备。D1 和 D2 ip 不能更改。
代理是linux centos 8。
已经测试过:
- 在 iptables 上添加日志:如果 2 个 nic 已启动,则不再有输入/输出日志
- 删除所有输入/输出,然后只接受来自正确接口的正确 ip => 没有结果
- 更改 arp_filter = 1 和 arp_announce = 2 => 没有结果
- 在同一子网上测试多个关于 2 nic 的 SO 帖子
如果有人可以提供帮助。
谢谢 。
解决方案
我找到了一个解决方案,它包括创建一个透明代理并拦截一些数据包。
1-使用 2 个 NIC 创建一个网桥:
nmcli connection add type bridge autoconnect yes con-name "br0" ifname "br0"
nmcli connection modify "br0" ipv4.addresses "192.168.10.10/24" ipv4.method manual
nmcli connection delete enp0s3
nmcli connection delete enp0s8
nmcli connection add type bridge-slave autoconnect yes con-name enp0s3 ifname enp0s3 master br0
nmcli connection add type bridge-slave autoconnect yes con-name enp0s8 ifname enp0s8 master br0
2 添加正确的规则拦截特定流量
nft add table bridge mitm
nft add chain bridge mitm filter { type filter hook prerouting priority 0\; }
nft add rule bridge mitm filter tcp dport 10000 ip saddr 192.168.10.50 meta pkttype set host ether daddr set xx:xx:xx:xx:xx:xx # br0 mac address
nft add rule ip nat PREROUTING tcp dport 10000 ip saddr 192.168.10.50 dnat to 192.168.10.10
它对我有用。
推荐阅读
- css - 在wordpress中更改按钮位置
- matlab - 在嵌套单元格中搜索匹配的字符串并提供索引
- heroku - Heroku/Nuxt 没有使用 mixin?
- python - 如何在 Python 中使用 Selenium 获取 h1 标签
- php - 写入日志文件错误 file_put_contents(/var/www/html/myproject/ulogs/my-log.log):无法打开流:权限被拒绝
- javascript - Animated.View 仅适用于展开,不适用于折叠
- recursion - 由于递归函数,理论函数堆栈的最大深度?
- python - 输入时间限制
- c++ - App Verifier Stop 00000900 使用文件打开对话框
- python - 我对 if 语句(Python)有一些问题