[GH-ISSUE #21] Add Nic during the creation of an LXC #18

Closed
opened 2026-02-26 17:32:08 +03:00 by kerem · 3 comments
Owner

Originally created by @J-Corentin on GitHub (Sep 9, 2024).
Original GitHub issue: https://github.com/Corsinvest/cv4pve-api-powershell/issues/21

What happened?

I would like to add a network card when creating an LXC. For this, I based myself on the configuration of an existing container with the following configuration:

net0 : name=eth0,bridge=vmbr0,hwaddr=BC:24:11:4C:93:0B,ip=dhcp,ip6=dhcp,type=veth

I saw in a post that we should use a certain format with Hashtables. So, I converted the configuration to the required format:

$networkConfig = @{ 1 = "name%3Deth0%2Cbridge%3Dvmbr0%2Chwaddr%3DBC:24:11:4C:93:0B%2Cip%3Ddhcp%2Cip6%3Ddhcp%2Ctype%3Dveth" }

However, I get a 400 error when creating the machine. The creation works fine without adding the network card.

I also tried the following format:

$networkConfig = @{ 1 = [uri]::EscapeDataString("name=eth0,bridge=vmbr0,hwaddr=BC:24:11:4C:93:0B,ip=dhcp,ip6=dhcp,type=veth") }

Without any more success

So, I wanted to know what the correct format to use is, as well as the supported arguments for adding a network card when creating an LXC.

Expected behavior

Being able to add a network card during the creation of an LXC

Relevant log output

No response

Proxmox VE Version

8.2.4

Version (bug)

8.2.2

Version (working)

No response

On what operating system are you experiencing the issue?

Windows

Pull Request

  • I would like to do a Pull Request
Originally created by @J-Corentin on GitHub (Sep 9, 2024). Original GitHub issue: https://github.com/Corsinvest/cv4pve-api-powershell/issues/21 ### What happened? I would like to add a network card when creating an LXC. For this, I based myself on the configuration of an existing container with the following configuration: net0 : name=eth0,bridge=vmbr0,hwaddr=BC:24:11:4C:93:0B,ip=dhcp,ip6=dhcp,type=veth I saw in a post that we should use a certain format with Hashtables. So, I converted the configuration to the required format: $networkConfig = @{ 1 = "name%3Deth0%2Cbridge%3Dvmbr0%2Chwaddr%3DBC:24:11:4C:93:0B%2Cip%3Ddhcp%2Cip6%3Ddhcp%2Ctype%3Dveth" } However, I get a 400 error when creating the machine. The creation works fine without adding the network card. I also tried the following format: $networkConfig = @{ 1 = [uri]::EscapeDataString("name=eth0,bridge=vmbr0,hwaddr=BC:24:11:4C:93:0B,ip=dhcp,ip6=dhcp,type=veth") } Without any more success So, I wanted to know what the correct format to use is, as well as the supported arguments for adding a network card when creating an LXC. ### Expected behavior Being able to add a network card during the creation of an LXC ### Relevant log output _No response_ ### Proxmox VE Version 8.2.4 ### Version (bug) 8.2.2 ### Version (working) _No response_ ### On what operating system are you experiencing the issue? Windows ### Pull Request - [ ] I would like to do a Pull Request
kerem closed this issue 2026-02-26 17:32:08 +03:00
Author
Owner

@SoarinFerret commented on GitHub (Sep 10, 2024):

It needs to be provided as a string. Here is an example:

New-PveNodesLxc -Node pve -Vmid 102 -Ostemplate "local:vztmpl/ubuntu.tar.xz" -Hostname "test2" -Storage "vms" -NetN @{1='name=eth0,bridge=vmbr0,ip=dhcp'}
<!-- gh-comment-id:2339546134 --> @SoarinFerret commented on GitHub (Sep 10, 2024): It needs to be provided as a string. Here is an example: ```powershell New-PveNodesLxc -Node pve -Vmid 102 -Ostemplate "local:vztmpl/ubuntu.tar.xz" -Hostname "test2" -Storage "vms" -NetN @{1='name=eth0,bridge=vmbr0,ip=dhcp'} ```
Author
Owner

@SoarinFerret commented on GitHub (Sep 10, 2024):

A good place to find the way the parameters should be provided is this link here: https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/lxc

<!-- gh-comment-id:2339546823 --> @SoarinFerret commented on GitHub (Sep 10, 2024): A good place to find the way the parameters should be provided is this link here: https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/lxc
Author
Owner

@J-Corentin commented on GitHub (Sep 10, 2024):

Thank you very much for the response. It works perfectly with the format :

-NetN @{1='name=eth0,bridge=vmbr0,ip=dhcp'}

I will also read the documentation.

<!-- gh-comment-id:2341002868 --> @J-Corentin commented on GitHub (Sep 10, 2024): Thank you very much for the response. It works perfectly with the format : ```ps -NetN @{1='name=eth0,bridge=vmbr0,ip=dhcp'} ``` I will also read the documentation.
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cv4pve-api-powershell#18
No description provided.