Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for custom IP configuration #1293

Closed
JayDoubleu opened this issue Jan 9, 2020 · 26 comments
Closed

Allow for custom IP configuration #1293

JayDoubleu opened this issue Jan 9, 2020 · 26 comments

Comments

@JayDoubleu
Copy link

It would be very helpful to have the functionality of providing static IP address to primary using cloud-init.

  • It seems that on every reboot the IP address range changes randomly with hyper-v so cannot even set it statically within the ubuntu itself.
  • Alternatively, please update etc/hosts file as well as etc/hosts.ics on host machine so it could be used within WSL which can use windows hosts file if configured.

One of use cases of above would be hosting docker daemon within multipass and having WSL connect to it. For that we need either static IP address or dns resolution of primary.mshome.net which is only provided by etc/hosts.ics file. ( currently I am building up ubuntu's etc/hosts file in bashrc by copying etc/hosts.ics however it seems an ugly workaround.

@Saviq
Copy link
Collaborator

Saviq commented Jan 9, 2020

Under Hyper-V, we're using the "Default Switch" network, and we have no control over what it's doing, I'm afraid. It's surprising it would use a different DHCP range on every boot, we'll have to investigate there.

FWIW Get-HNSNetwork can give you details about the default network.

As for using static IPs, Multipass currently relies on IP connectivity between the host and the instance. And using something from a different subnet we'd need to set up routing and DNS for it.

We're planning to detach Multipass functions from networking (where possible) by communicating with the instance via a "virtual socket", at which point we'll be able to expose much more complex networking configurations.

@Saviq Saviq changed the title Allow for static IP within cloud-init for primary. Allow for custom IP configuration Jan 9, 2020
@Saviq
Copy link
Collaborator

Saviq commented Jan 9, 2020

Related: bridged networking (#118) and custom cloud-init metadata (#557).

@JayDoubleu
Copy link
Author

JayDoubleu commented Jan 9, 2020

Looks like Get-HNSNetwork is quite painful to execute from WSL as it needs to run as admin, got myself a dirty script below into bashrc and seems to work fine for now.

#!/bin/bash
ics_gateway=$(powershell.exe -Command \
	"(Get-NetAdapter -Name 'vEthernet (Default Switch)'|Get-NetIPAddress -AddressFamily IPv4).IPAddress")
sudo tee /etc/resolv.conf > /dev/null <<EOF
nameserver $ics_gateway
EOF

@ticozz
Copy link

ticozz commented Mar 29, 2020

I assume that using static IP on multipass is still not available? or not possible? until now?

@Saviq
Copy link
Collaborator

Saviq commented Mar 29, 2020

Hi @ticozz we'll be working on allowing custom network configuration for additional interfaces real soon. You'll be able to ask for an interface to be bridged with an interface of your choice, and then in the instance itself set the static IP configuration.

@ticozz
Copy link

ticozz commented Mar 29, 2020

Thanks @Saviq for now I had to opt for an alternate solution to host the VM, as assigning a static IP with gateway and nameserver was a must. Thanks for replying and keep up the great work

@imbroisi
Copy link

imbroisi commented Apr 11, 2020

Yes, be able set the IP of the instance is a must for us developers. Please give us this gift. :-)
I am a React developer (at Mac OS) and also developing a lot of Node, Rust an C backend stuff for Ubuntu. Multipass is an excellent choice to do my job.

@akunaatrium
Copy link

Every time the IP of the instance changes, I have to update it also in the MobaXTerm saved session to be able to log in. Quite annoying.

@Saviq
Copy link
Collaborator

Saviq commented Apr 15, 2020

Hi @akunaatrium you can use <instance_name>.mshome.net rather than the IP.

@akunaatrium
Copy link

@Saviq Nice, worked indeed, thanks! Do you know if it also documented somewhere?

@Saviq
Copy link
Collaborator

Saviq commented Apr 16, 2020

Do you know if it also documented somewhere?

Not yet - I've added it to the list of topics we should document on https://multipass.run/docs.

@devcircus
Copy link

On windows, you could add a virtual switch in hyper-v manager and then use your dhcp device to always assign the same ip for the instance. It's not ideal and I'm sure there are limitations, but it has worked for me so far.

@JayDoubleu
Copy link
Author

JayDoubleu commented Aug 3, 2020

any news on this ?

@Saviq
Copy link
Collaborator

Saviq commented Aug 4, 2020

We're working on bridging support (#118) right now, which will also allow adding an interface to a custom switch without configuration, so this will come real soon.

@okedialf
Copy link

okedialf commented Oct 6, 2020

Still waiting...

@Saviq
Copy link
Collaborator

Saviq commented Oct 6, 2020

Still waiting...

Hi @okedialf, we're actively working on it (#1663). It's a significant change, so please bear with us.

@yingshaoxo
Copy link

If you are using windows10, you should check a file which called hosts.ics under C:\Windows\System32\drivers\etc

# Copyright (c) 1993-2001 Microsoft Corp.
#
# This file has been automatically generated for use by Microsoft Internet
# Connection Sharing. It contains the mappings of IP addresses to host names
# for the home network. Please do not make changes to the HOSTS.ICS file.
# Any changes may result in a loss of connectivity between machines on the
# local network.
#

192.168.234.66 primary.mshome.net # 2020 10 3 28 6 34 15 247
192.168.234.65 Thinkpad-yoga260.mshome.net # 2025 10 1 20 6 34 15 24

It says I could use http://primary.mshome.net/ to visit my ubuntu instance. Here, for example, I use it to visit the jupyter-notebook inside ubuntu: http://primary.mshome.net:8888/tree

@Hamberfim
Copy link

Hi @ticozz we'll be working on allowing custom network configuration for additional interfaces real soon. You'll be able to ask for an interface to be bridged with an interface of your choice, and then in the instance itself set the static IP configuration.

Has this been implemented yet?

@Saviq
Copy link
Collaborator

Saviq commented Dec 24, 2020

Hi @Hamberfim, there's a prerelease build available here:

#118 (comment)

@Hamberfim
Copy link

Hi @Hamberfim, there's a prerelease build available here:

#118 (comment)

Thanks. My desire is to be able to implement this on a headless Ubuntu server, but as I understand it this is Win/Mac OS specific.

@Saviq
Copy link
Collaborator

Saviq commented Dec 27, 2020

as I understand it this is Win/Mac OS specific.

We're working on Linux support via LXD now. Stay tuned.

@Hamberfim
Copy link

as I understand it this is Win/Mac OS specific.

We're working on Linux support via LXD now. Stay tuned.

Awesome...looking forward to it. :D

@JayDoubleu
Copy link
Author

as I understand it this is Win/Mac OS specific.

We're working on Linux support via LXD now. Stay tuned.

So if the solution is locked to LXD it means it's for Ubuntu support rather than Linux.
Any plans for other solutions that would work on all distributions without the need to install LXD ?

@tuxerrante
Copy link

Hi @akunaatrium you can use <instance_name>.mshome.net rather than the IP.

How should we set it as static for using as a server (kubernetes node)?
Could it work setting up netplan from inside the machine? (https://linuxize.com/post/how-to-configure-static-ip-address-on-ubuntu-20-04/)
I've tried but then I've lost the connection to the VM

@Saviq
Copy link
Collaborator

Saviq commented Sep 1, 2021

@tuxerrante you can append static IPs, just add e.g. addresses: [10.3.0.1/24] to the entry in /etc/netplan/50-cloud-init.yaml. Don't disable DHCP as that indeed will break connection to the instance.

@townsend2010
Copy link
Contributor

The --network option has been released some time ago. If this is not sufficient for the purposes described in this bug, please open a new bug so we can track easier. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests