我有一台运行 K3OS 的 PC,带有两个以太网接口。一个 (eth0) 连接到没有具有静态 IP 地址的 DHCP 服务器的网络,另一个 (eth1) 连接到具有 DHCP 的网络,该网络返回默认网关。 K3OS 使用 connman 作为其网络管理器。
我配置了两个 connman 服务,c 和 d:
/net/connman/service/ethernet_00606561750c_cable
Type = ethernet
Security = [ ]
State = ready
Favorite = True
Immutable = False
AutoConnect = True
Name = Wired
Ethernet = [ Method=auto, Interface=eth0, Address=xx:xx:xx:xx:xx:xx, MTU=1500 ]
IPv4 = [ Method=dhcp, Address=10.4.144.15, Netmask=255.255.255.0, Gateway=10.4.144.254 ]
IPv4.Configuration = [ Method=dhcp ]
IPv6 = [ ]
IPv6.Configuration = [ Method=auto, Privacy=disabled ]
Nameservers = [ 10.1.1.60 ]
Nameservers.Configuration = [ ]
Timeservers = [ 10.1.1.60 ]
Timeservers.Configuration = [ ]
Domains = [ domain.com ]
Domains.Configuration = [ ]
Proxy = [ ]
Proxy.Configuration = [ ]
mDNS = False
mDNS.Configuration = False
Provider = [ ]
/net/connman/service/ethernet_00606561750d_cable
Type = ethernet
Security = [ ]
State = ready
Favorite = True
Immutable = False
AutoConnect = True
Name = Wired
Ethernet = [ Method=auto, Interface=eth1, Address=xx:xx:xx:xx:xx:xx, MTU=1500 ]
IPv4 = [ Method=manual, Address=192.168.10.3, Netmask=255.255.255.0 ]
IPv4.Configuration = [ Method=manual, Address=192.168.10.3, Netmask=255.255.255.0 ]
IPv6 = [ ]
IPv6.Configuration = [ Method=off ]
Nameservers = [ 8.8.8.8 ]
Nameservers.Configuration = [ ]
Timeservers = [ ]
Timeservers.Configuration = [ ]
Domains = [ ]
Domains.Configuration = [ ]
Proxy = [ ]
Proxy.Configuration = [ ]
mDNS = False
mDNS.Configuration = False
Provider = [ ]
现在发生了什么,在我重新启动 PC 或重新启动服务后,我得到了 connman 设置的通过 eth1 的默认路由。但 eth1 没有网关地址,因此我对其他网络的所有请求都会失败。我的理解是 connman 有内部服务排序。排序是通过尊重PreferredTechnologies
in的设置来进行的/etc/connman/main.config
。当相同技术的两种服务可用时,它将优先考虑第一个准备好的服务(来源:文档)。但我不明白的是,为什么 connman 会为没有默认网关的网络添加默认路由。有没有办法告诉 connman 某个服务没有默认网关?
谢谢。
答案1
您可以将不希望 connman 触及的接口添加到黑名单中/etc/connman/main.conf
:
NetworkInterfaceBlacklist=eth1
它不会尝试通过它们添加路由。