Skip to content

Commit 8cfe857

Browse files
committed
Prefer additional network over user network
If using additional network (e.g. lima:shared), override the dhcp rote metric so the additional metric is preferred. This fixes issues with k8s components (like submariner) that use the first default route and break since the user network has not connectivity between vms. With this change they always use the additional network. Example routes with this change when using socket_vmnet: $ ip route default via 192.168.105.1 dev lima0 proto dhcp src 192.168.105.7 metric 100 default via 192.168.5.2 dev eth0 proto dhcp src 192.168.5.15 metric 200 192.168.5.0/24 dev eth0 proto kernel scope link src 192.168.5.15 metric 200 192.168.5.2 dev eth0 proto dhcp scope link src 192.168.5.15 metric 200 192.168.105.0/24 dev lima0 proto kernel scope link src 192.168.105.7 metric 100 192.168.105.1 dev lima0 proto dhcp scope link src 192.168.105.7 metric 100 Example routes without additional network: $ ip route default via 192.168.5.2 dev eth0 proto dhcp src 192.168.5.15 metric 200 192.168.5.0/24 dev eth0 proto kernel scope link src 192.168.5.15 metric 200 192.168.5.2 dev eth0 proto dhcp scope link src 192.168.5.15 metric 200 Another way to solve this issue is to fixup the metric in the provisioning script as done in RamenDR: https://github.com/RamenDR/ramen/blob/c02119785e734e15511236edd935c04ff71b6646/test/drenv/providers/lima/k8s.yaml#L37 But I think it is better to fix this in lima, since the current network configuration is very problematic. Signed-off-by: Nir Soffer <[email protected]>
1 parent 95d1863 commit 8cfe857

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/cidata/cidata.TEMPLATE.d/network-config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ ethernets:
66
macaddress: '{{$nw.MACAddress}}'
77
dhcp4: true
88
set-name: {{$nw.Interface}}
9+
dhcp4-overrides:
10+
{{- if (eq $nw.Interface $.SlirpNICName) }}
11+
route-metric: 200
12+
{{- else }}
13+
route-metric: 100
14+
{{- end }}
915
{{- if and (eq $nw.Interface $.SlirpNICName) (gt (len $.DNSAddresses) 0) }}
1016
nameservers:
1117
addresses:

0 commit comments

Comments
 (0)