[SOLVED] Simple way to change network config of an existing container with the command line ?

norbertk

Renowned Member
Jan 20, 2014
20
7
68
Hello all,
UPDATE: This is in the wron forum. @MOD Can you move it, please ?


i want to change the ip address(es) of existing lxc containers after installation from the command line.

What do people do in such situations ?

I thought about pvesh but get the impression that this would not work:

Bash:
root@grossglockner:~\ pvesh get /nodes/grossglockner/lxc/100/config/net0
No 'get' handler defined for '/nodes/grossglockner/lxc/100/config/net0'




Thanks a lot for any hints

Norbert
 
Last edited:
root@grossglockner:~\ pvesh get /nodes/grossglockner/lxc/100/config/net0
No 'get' handler defined for '/nodes/grossglockner/lxc/100/config/net0'
As shown here; pvesh get /nodes/{node}/lxc/{vmid}/config will return as objects the entire lxc config.

To look up just the net0 of that lxc, you would need to parse that output, something like this:
Code:
pvesh get /nodes/grossglockner/lxc/100/config/  --output-format=json | jq .net0

To use pvesh to set the lxc config for net0, you would do something like this:
Code:
pvesh set /nodes/grossglockner/lxc/100/config –net0 name=<string> [,bridge=<bridge>] [,firewall=<1|0>] [,gw=<GatewayIPv4>] [,gw6=<GatewayIPv6>] [,host-managed=<1|0>] [,hwaddr=<XX:XX:XX:XX:XX:XX>] [,ip=<(IPv4/CIDR|dhcp|manual)>] [,ip6=<(IPv6/CIDR|auto|dhcp|manual)>] [,link_down=<1|0>] [,mtu=<integer>] [,rate=<mbps>] [,tag=<integer>] [,trunks=<vlanid[;vlanid...]>] [,type=<veth>]