旁路由 immortalwrt 下的 wireguard 只有发送数据,但是没有已接收数据,是为什么?
已知:
1、华三路由上配置了虚拟服务器和端口,这个虚拟服务器的内网(lan)ip就是 immortalwrt 的ip 对应有一个 外网(wan)ip。
2、在immortalwrt 上只有一个lan ,这个lan是有数据来往的,可以正常上网,还有两个未配置的网卡。
3、新增的wireguard接口,常规设置里配置了10.0.0.1/24 对端peer里配置了允许的IP是0.0.0.0/0,对端主机设置的是 华三路由上配置的虚拟服务器外网的IP和端口。
4、防火墙-区域里设置了,与lan的区域转发。
immortalwrt 下的wireguard 配置问题,求指导!
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
1条回答 默认 最新
关注让码农阿豪来帮你解答,本回答参考通义千问qwen-plus模型编写提供,如果还有疑问可以评论或留言
### 问题分析根据你的描述,WireGuard 在 ImmortalWRT 上只有发送数据但没有接收数据。我们需要从多个角度来排查问题,包括网络配置、防火墙规则、路由表等。
已知信息总结
- 华三路由:配置了虚拟服务器,将外部端口映射到 ImmortalWRT 的 LAN IP。
- ImmortalWRT:
- 有一个正常工作的 LAN 接口。
- 有两个未配置的网卡。
- 新增了一个 WireGuard 接口,配置了
10.0.0.1/24。 - WireGuard Peer 配置了允许的 IP 是
0.0.0.0/0,对端主机设置为华三路由上配置的虚拟服务器外网 IP 和端口。 - 防火墙区域设置中,与 LAN 区域进行了转发。
可能的原因及排查步骤
1. 网络配置问题
- 检查 WireGuard 配置文件:确保 WireGuard 配置文件中的
ListenPort和AllowedIPs设置正确。 - 检查路由表:确保路由表中有正确的路由条目,使数据包能够通过 WireGuard 接口传输。
# 查看 WireGuard 配置 cat /etc/wireguard/wg0.conf # 查看路由表 ip route show2. 防火墙规则
- 检查防火墙规则:确保防火墙规则允许 WireGuard 接口的数据通过。
# 查看防火墙规则 iptables -L -v -n3. 端口映射问题
- 检查华三路由的端口映射:确保虚拟服务器的端口映射配置正确,且外部 IP 和端口与 WireGuard 配置一致。
4. WAN 接口问题
- 检查 WAN 接口:虽然你提到 ImmortalWRT 没有配置 WAN 接口,但这并不一定意味着缺少 WAN 接口。WAN 接口可以通过多种方式配置,例如 PPPoE、静态 IP 等。
# 查看网络接口 ifconfig解决方案
1. 配置 WAN 接口
如果确实缺少 WAN 接口,可以考虑以下方法:
- PPPoE 拨号:如果你使用的是宽带拨号,可以配置 PPPoE 接口。
# 编辑 PPPoE 配置文件 vi /etc/config/network # 添加以下内容 config interface 'wan' option ifname 'eth0' option proto 'pppoe' option username 'your_username' option password 'your_password'- 静态 IP:如果你使用的是静态 IP,可以配置静态 IP 接口。
# 编辑网络配置文件 vi /etc/config/network # 添加以下内容 config interface 'wan' option ifname 'eth0' option proto 'static' option ipaddr '192.168.1.2' option netmask '255.255.255.0' option gateway '192.168.1.1' option dns '8.8.8.8 8.8.4.4'2. 检查并调整防火墙规则
确保防火墙规则允许 WireGuard 接口的数据通过。
# 允许 WireGuard 接口的数据通过 iptables -A INPUT -i wg0 -j ACCEPT iptables -A FORWARD -i wg0 -j ACCEPT iptables -A OUTPUT -o wg0 -j ACCEPT3. 重新启动服务
重启网络服务和 WireGuard 服务,确保配置生效。
# 重启网络服务 /etc/init.d/network restart # 重启 WireGuard 服务 /etc/init.d/wireguard restart示例代码
WireGuard 配置文件示例 (
/etc/wireguard/wg0.conf)[Interface] PrivateKey = your_private_key Address = 10.0.0.1/24 ListenPort = 51820 [Peer] PublicKey = peer_public_key AllowedIPs = 0.0.0.0/0 Endpoint = external_ip:external_portPPPoE 配置示例 (
/etc/config/network)config interface 'wan' option ifname 'eth0' option proto 'pppoe' option username 'your_username' option password 'your_password'静态 IP 配置示例 (
/etc/config/network)config interface 'wan' option ifname 'eth0' option proto 'static' option ipaddr '192.168.1.2' option netmask '255.255.255.0' option gateway '192.168.1.1' option dns '8.8.8.8 8.8.4.4'总结
通过以上步骤,你可以逐步排查并解决 WireGuard 只有发送数据但没有接收数据的问题。确保网络配置、防火墙规则和路由表都正确无误,必要时配置 WAN 接口。希望这些信息对你有所帮助!
解决 无用评论 打赏 举报