Individual IP for VMs

delghen

New Member
Sep 8, 2024
3
0
1
Hello,
I would like to set up an environment with multiple VMs running on a single server and assign an individual static IP for each of the VMs. The main server would be connecting to a single router with a public static IP.
Is there even a way to do this? I am new to this so apologies if this is a simple query.
 
Sounds like you need a DHCP server on your network with static reservations or you need to hard code the IP address in each VM manually. LXCs you can specify the IP address in the config or use DHCP.
 
Sounds like you need a DHCP server on your network with static reservations or you need to hard code the IP address in each VM manually. LXCs you can specify the IP address in the config or use DHCP.
Could you break that down a little bit? I am a complete beginner.
What is the cheapest/easiest to implement?
 
The easiest way is to hard code the IP address in each LXC/VM. The LXC can be done in the Proxmox gui. Here is a screen shot of the Network tab as you create one. Change the IPv4/CIDR to your desired IP address for that LXC.

1726503413584.png

If you already have it created, you can click in the LXC and goto Network and view/change it:
1726503527505.png
The /24 on the end of the IP address means it is a Class C or a 24 bit network. Generally home use use 192.168.x.x where the first x is usually a 1 but as you see in my case, I used a 5. The second x can be anything from 1-254 (0 and 255 is reserved and can't be assigned). Your router will probably be either 1 or 254 (first or last ip address you can assign). As you see in my example above, mine is 1.

For the VMs, it depends on the guest you are installing. If you go with Ubuntu server, this is a link on how to do it. It will be similar for each flavor of linux but check the documentation. https://ubuntu.com/server/docs/configuring-networks

Keep in mind, if your current router assigns IP addresses already (DHCP) then you will need to not assign them in the range that your router does. Most don't use the full 256 IPs and just use a subset - typically something like between IPs ending between 100 and 199 or something like that.


If you decide to go the DHCP route (with static IP reservations) there are many options and that depends on if you want a gui to work with, can set reservations on your current router, or need to install a DHCP service on a VM (linux or windows). This is a better end solution in my opinion but will be a longer setup as you have to learn this side before you can deploy it.
 
The easiest way is to hard code the IP address in each LXC/VM. The LXC can be done in the Proxmox gui. Here is a screen shot of the Network tab as you create one. Change the IPv4/CIDR to your desired IP address for that LXC.

View attachment 74746

If you already have it created, you can click in the LXC and goto Network and view/change it:
View attachment 74747
The /24 on the end of the IP address means it is a Class C or a 24 bit network. Generally home use use 192.168.x.x where the first x is usually a 1 but as you see in my case, I used a 5. The second x can be anything from 1-254 (0 and 255 is reserved and can't be assigned). Your router will probably be either 1 or 254 (first or last ip address you can assign). As you see in my example above, mine is 1.

For the VMs, it depends on the guest you are installing. If you go with Ubuntu server, this is a link on how to do it. It will be similar for each flavor of linux but check the documentation. https://ubuntu.com/server/docs/configuring-networks

Keep in mind, if your current router assigns IP addresses already (DHCP) then you will need to not assign them in the range that your router does. Most don't use the full 256 IPs and just use a subset - typically something like between IPs ending between 100 and 199 or something like that.


If you decide to go the DHCP route (with static IP reservations) there are many options and that depends on if you want a gui to work with, can set reservations on your current router, or need to install a DHCP service on a VM (linux or windows). This is a better end solution in my opinion but will be a longer setup as you have to learn this side before you can deploy it.
Thank you for the great write-up Chad. I assume these steps are for private IPs, would this work for public IPs as well? I would like for my VMs to all have different IPs as seen from the outside world.
I read there is an option in Azure to do this and was wondering if there is a way in Proxmox too.
 
Last edited:
Could it be done? Sure. Would I do that? No. I would put each system on an internal IP and route the traffic through a firewall like pfSense. Let the pfSense firewall connect to the public IP space. This gives you protection and the ability to control traffic to/from the systems.

Another option is to use cloudflare zero trust and not expose your systems to the internet directly - let cloudflare proxy for you. This only works for http traffic - ssh and other access doesn't work without having a client installed on the originating system. Doesn't work if you want to have public systems connect.

I use a combination - I have web sites I host internally that I let the public (filtered via cloudflare as needed) access. Things such as a nextcloud instance, my proxmox admin portal (yes, this is filtered), etc. I also have things that don't work so I route via my pfSense like a Minecraft server my son and his friends use.

I only have 1 public IP address but with different URLs, I am able to host several services this way. Also, if you port scan my public IP address, there are only a small number of open ports (Minecraft).
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!