lima
lima copied to clipboard
Support for flexible Slirp IP address
Description
Lima currently uses the 192.168.5.0/24 subnet and it is currently hardcoded. There should be room for flexibility to accommodate users with a clashing IP address.
https://github.com/lima-vm/lima/blob/3ad14f6618f8837a729a79b0ce765beb75f668ab/pkg/qemu/const/const.go#L6
Related Issue: https://github.com/abiosoft/colima/issues/335
Hi @abiosoft For networking settings, I am using vmnet as an alternative to manage the IP Range of my cluster (on macOS M1). Have a look at below:
~/.lima/_confi/network.yaml
paths:
vdeSwitch: /opt/rancher-desktop/bin/vde_switch
vdeVMNet: /opt/rancher-desktop/bin/vde_vmnet
varRun: /private/var/run/lima
sudoers: /private/etc/sudoers.d/lima
group: everyone
networks:
shared:
mode: shared
gateway: 192.168.105.1
dhcpEnd: 192.168.105.254
netmask: 255.255.255.0
bridged:
mode: bridged
interface: en0
# bridged mode doesn't have a gateway; DHCP is managed by the outside network
host:
mode: host
gateway: 192.168.2.1
dhcpEnd: 192.168.2.254
netmask: 255.255.255.0
Thus, I am advertising my cluster to use the shared IP. The result is shown below.
kgno -owide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
lima-manager-1 Ready control-plane,etcd,master 27m v1.23.6+k3s1 192.168.105.44 192.168.105.44 Ubuntu 21.10 5.13.0-48-generic containerd://1.5.11-k3s2
lima-manager-2 Ready control-plane,etcd,master 26m v1.23.6+k3s1 192.168.105.46 192.168.105.46 Ubuntu 21.10 5.13.0-48-generic containerd://1.5.11-k3s2
lima-manager-3 Ready control-plane,etcd,master 23m v1.23.6+k3s1 192.168.105.47 192.168.105.47 Ubuntu 21.10 5.13.0-48-generic containerd://1.5.11-k3s2
lima-node-1 Ready <none> 22m v1.23.6+k3s1 192.168.105.34 192.168.105.34 Ubuntu 21.10 5.13.0-48-generic containerd://1.5.11-k3s2
lima-node-2 Ready <none> 21m v1.23.6+k3s1 192.168.105.37 192.168.105.37 Ubuntu 21.10 5.13.0-48-generic containerd://1.5.11-k3s2
lima-node-3 Ready <none> 20m v1.23.6+k3s1 192.168.105.40 192.168.105.40 Ubuntu 21.10 5.13.0-48-generic containerd://1.5.11-k3s2
But would be very nice be able for setting the Slirp IP.
Can you have more description for the relationship among the guest IP (192.168.5.15/24), share IP 192.168.105.0/24 and host IP (192.168.2.0/24 )? I also using vmnet on my MacBook (Intel). I cannot ping guest IP from my MacBook but guest can reach out to the Internet.
guest info: $ ifconfig -a docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255 ether 02:42:ab:04:8d:9e txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.5.15 netmask 255.255.255.0 broadcast 192.168.5.255
inet6 fec0::5055:55ff:fe29:8ce5 prefixlen 64 scopeid 0x40
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
$ netstat -rn Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 0.0.0.0 192.168.5.2 0.0.0.0 UG 0 0 0 eth0 172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0 192.168.5.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.5.2 0.0.0.0 255.255.255.255 UH 0 0 0 eth0 192.168.5.3 0.0.0.0 255.255.255.255 UH 0 0 0 eth0
$ fping www.google.com www.google.com is alive
How the guest (Lima instance) reach out www.google.com ? 192.168.5.2 -> 192.168.105.1 ?
Any update on what would be required to support this? We are in the unfortunate situation of our office CIDR precisely clashing with Lima's...
I also have run into the situation where one of my existing networks is 192.168.5.0/24 so the ability to configure that by the user would be ideal. I am using a bridged network in my setup so I am not sure if I am missing anything in terms of an ability to completely disable the slirp network that is created and attached as eth0 but from what I can tell, there are dependencies on that local network to exist for lima to interact with the VM.
This PR https://github.com/lima-vm/lima/pull/1626 should address this by providing support for configurable usernet network
@AkihiroSuda This is now supported via user-v2. I think we can close this issue.
Thanks!