设置
- 路由器作为我网络上的 Wireguard 服务器
- 树莓派
- 操作系统:Raspbian Buster
- 通过 wifi 连接到移动热点(接口 wlan0)
- et0设置为静态IP,可以直接控制静态IP的设备,无需交换机或路由器
- wg0 配置为连接到我的路由器上的服务器
问题
仅当我使用 禁用 eth0 时,wireguard 连接才有效ifconfig eth0 down
。
我想做的事:
我需要在 Pi 上更新并测试软件的更新。该软件使用连接在 eth0 上的设备,因此我需要 eth0 处于活动状态。
我尝试过的
除了谷歌之外,什么也没有,但我找不到任何适合我的具体问题的东西。
我怀疑我需要更改路由表,但我不确定谁和我不想中断 wifi 连接。
Pi 上的 Wireguard 配置
[Interface]
PrivateKey = myPrivateKey
Address = 192.168.180.201/24
DNS = 192.168.180.1
DNS = fritz.box
[Peer]
PublicKey = myPublicKey
PresharedKey = Key
AllowedIPs = 192.168.180.0/24,0.0.0.0/0
Endpoint = myfritzdomain:59047
PersistentKeepalive = 25
/etch/dhcpcd.conf 中的 eth0 配置
# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.
# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel
# Inform the DHCP server of our hostname for DDNS.
hostname
# Use the hardware address of the interface for the Client ID.
clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
#duid
# Persist interface configuration when dhcpcd exits.
persistent
# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit
# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu
# Most distributions have NTP support.
#option ntp_servers
# A ServerID is required by RFC2131.
require dhcp_server_identifier
# Generate SLAAC address using the Hardware Address of the interface
#slaac hwaddr
# OR generate Stable Private IPv6 Addresses based from the DUID
slaac private
interface eth0
static ip_address=192.168.1.45/16
static routers=192.168.1.1
static domain_name_servers=192.168.1.1
答案1
对我来说,解决方案是删除定义静态 IP 的static routers
行。我不确定是否必须将两者都删除。我认为删除 dns 应该就足够了,因为 Pi 可能试图通过不可用的静态 dns 找到我的wiregurad 域。static domain_name_servers
/etch/dhcpcd.conf
感谢 AB 提供了正确方向的提示。