Assigning an ipv4 address to (LXD) linux containers

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I've got a home server running with a bunch of linux containers and they're all getting their ip addresses assigned automatically via dhcp on my router.



I'd like to be able to assign ip addresses manually to each container but I seem to be having a bit of trouble finding a working example of how to do that exactly.



I'm not the biggest networking expert so I'm about to butcher some terminology on this next part. I have my containers setup so that they're getting addresses that start with 192.168.1.xxx and are accessible by other devices on my network instead of the private? addresses (10.whatever) that the default LXD settings give.



An example of some of my containers (deluge is also connected to a vpn):



+------------+---------+--------------------------------+------+------------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------------+---------+--------------------------------+------+------------+-----------+
| deluge | RUNNING | 192.168.1.17 (eth0) | | PERSISTENT | 0 |
| | | 10.3.83.122 (tun0) | | | |
+------------+---------+--------------------------------+------+------------+-----------+
| emby | RUNNING | 192.168.1.19 (eth0) | | PERSISTENT | 0 |
+------------+---------+--------------------------------+------+------------+-----------+
| grocery | RUNNING | 192.168.1.52 (eth0) | | PERSISTENT | 0 |
+------------+---------+--------------------------------+------+------------+-----------+


One example tutorial I tried that didn't seem to work is this blog post on medium. I like the simplicity of his method but unfortunately, it seems to have 0 effect on my containers. His /etc/default/lxd-bridge file is slightly different than mine though. He has LXD_BRIDGE="" whereas mine is set to LXD_BRIDGE="br0".



Contents of my host /etc/network/interfaces



# this is empty
source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto br0
iface br0 inet dhcp
bridge_ports enp7s0

iface enp7s0 inet manual


Contents of my default lxc profile which is currently assigned to all containers:



config:
environment.http_proxy: ""
user.network_mode: ""
description: Default LXD profile
devices:
eth0:
name: eth0
nictype: bridged
parent: br0
type: nic
name: default
used_by:


All my containers are running recent versions of ubuntu.



LXD version 2.0.11



Please let me know if there's any more information that I can provide.







share|improve this question




















  • I've yet to try this myself, but have you tried 1) creating a config file with the static config under /etc/network/interfaces.d/, and 2) creating the /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the line network: config: disabled? My clean install of a 16.04-based container has the file /etc/network/interfaces.d/50-cloud-init.cfg and it has a comment with the info I just mentioned, which seems related to this issue and notes: Changes to it will not persist across an instance. To disable cloud-init's network configuration capabilities..., repeating the above.
    – code_dredd
    Apr 19 at 18:53











  • I tried out a few things, including the above, but so far, I can't get it to work. (The networking.service will exit with an error when you try to restart it to apply the changes.) I'll try a few more things to see if I manage to find a solution for it.
    – code_dredd
    Apr 19 at 21:44














up vote
1
down vote

favorite












I've got a home server running with a bunch of linux containers and they're all getting their ip addresses assigned automatically via dhcp on my router.



I'd like to be able to assign ip addresses manually to each container but I seem to be having a bit of trouble finding a working example of how to do that exactly.



I'm not the biggest networking expert so I'm about to butcher some terminology on this next part. I have my containers setup so that they're getting addresses that start with 192.168.1.xxx and are accessible by other devices on my network instead of the private? addresses (10.whatever) that the default LXD settings give.



An example of some of my containers (deluge is also connected to a vpn):



+------------+---------+--------------------------------+------+------------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------------+---------+--------------------------------+------+------------+-----------+
| deluge | RUNNING | 192.168.1.17 (eth0) | | PERSISTENT | 0 |
| | | 10.3.83.122 (tun0) | | | |
+------------+---------+--------------------------------+------+------------+-----------+
| emby | RUNNING | 192.168.1.19 (eth0) | | PERSISTENT | 0 |
+------------+---------+--------------------------------+------+------------+-----------+
| grocery | RUNNING | 192.168.1.52 (eth0) | | PERSISTENT | 0 |
+------------+---------+--------------------------------+------+------------+-----------+


One example tutorial I tried that didn't seem to work is this blog post on medium. I like the simplicity of his method but unfortunately, it seems to have 0 effect on my containers. His /etc/default/lxd-bridge file is slightly different than mine though. He has LXD_BRIDGE="" whereas mine is set to LXD_BRIDGE="br0".



Contents of my host /etc/network/interfaces



# this is empty
source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto br0
iface br0 inet dhcp
bridge_ports enp7s0

iface enp7s0 inet manual


Contents of my default lxc profile which is currently assigned to all containers:



config:
environment.http_proxy: ""
user.network_mode: ""
description: Default LXD profile
devices:
eth0:
name: eth0
nictype: bridged
parent: br0
type: nic
name: default
used_by:


All my containers are running recent versions of ubuntu.



LXD version 2.0.11



Please let me know if there's any more information that I can provide.







share|improve this question




















  • I've yet to try this myself, but have you tried 1) creating a config file with the static config under /etc/network/interfaces.d/, and 2) creating the /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the line network: config: disabled? My clean install of a 16.04-based container has the file /etc/network/interfaces.d/50-cloud-init.cfg and it has a comment with the info I just mentioned, which seems related to this issue and notes: Changes to it will not persist across an instance. To disable cloud-init's network configuration capabilities..., repeating the above.
    – code_dredd
    Apr 19 at 18:53











  • I tried out a few things, including the above, but so far, I can't get it to work. (The networking.service will exit with an error when you try to restart it to apply the changes.) I'll try a few more things to see if I manage to find a solution for it.
    – code_dredd
    Apr 19 at 21:44












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I've got a home server running with a bunch of linux containers and they're all getting their ip addresses assigned automatically via dhcp on my router.



I'd like to be able to assign ip addresses manually to each container but I seem to be having a bit of trouble finding a working example of how to do that exactly.



I'm not the biggest networking expert so I'm about to butcher some terminology on this next part. I have my containers setup so that they're getting addresses that start with 192.168.1.xxx and are accessible by other devices on my network instead of the private? addresses (10.whatever) that the default LXD settings give.



An example of some of my containers (deluge is also connected to a vpn):



+------------+---------+--------------------------------+------+------------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------------+---------+--------------------------------+------+------------+-----------+
| deluge | RUNNING | 192.168.1.17 (eth0) | | PERSISTENT | 0 |
| | | 10.3.83.122 (tun0) | | | |
+------------+---------+--------------------------------+------+------------+-----------+
| emby | RUNNING | 192.168.1.19 (eth0) | | PERSISTENT | 0 |
+------------+---------+--------------------------------+------+------------+-----------+
| grocery | RUNNING | 192.168.1.52 (eth0) | | PERSISTENT | 0 |
+------------+---------+--------------------------------+------+------------+-----------+


One example tutorial I tried that didn't seem to work is this blog post on medium. I like the simplicity of his method but unfortunately, it seems to have 0 effect on my containers. His /etc/default/lxd-bridge file is slightly different than mine though. He has LXD_BRIDGE="" whereas mine is set to LXD_BRIDGE="br0".



Contents of my host /etc/network/interfaces



# this is empty
source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto br0
iface br0 inet dhcp
bridge_ports enp7s0

iface enp7s0 inet manual


Contents of my default lxc profile which is currently assigned to all containers:



config:
environment.http_proxy: ""
user.network_mode: ""
description: Default LXD profile
devices:
eth0:
name: eth0
nictype: bridged
parent: br0
type: nic
name: default
used_by:


All my containers are running recent versions of ubuntu.



LXD version 2.0.11



Please let me know if there's any more information that I can provide.







share|improve this question












I've got a home server running with a bunch of linux containers and they're all getting their ip addresses assigned automatically via dhcp on my router.



I'd like to be able to assign ip addresses manually to each container but I seem to be having a bit of trouble finding a working example of how to do that exactly.



I'm not the biggest networking expert so I'm about to butcher some terminology on this next part. I have my containers setup so that they're getting addresses that start with 192.168.1.xxx and are accessible by other devices on my network instead of the private? addresses (10.whatever) that the default LXD settings give.



An example of some of my containers (deluge is also connected to a vpn):



+------------+---------+--------------------------------+------+------------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------------+---------+--------------------------------+------+------------+-----------+
| deluge | RUNNING | 192.168.1.17 (eth0) | | PERSISTENT | 0 |
| | | 10.3.83.122 (tun0) | | | |
+------------+---------+--------------------------------+------+------------+-----------+
| emby | RUNNING | 192.168.1.19 (eth0) | | PERSISTENT | 0 |
+------------+---------+--------------------------------+------+------------+-----------+
| grocery | RUNNING | 192.168.1.52 (eth0) | | PERSISTENT | 0 |
+------------+---------+--------------------------------+------+------------+-----------+


One example tutorial I tried that didn't seem to work is this blog post on medium. I like the simplicity of his method but unfortunately, it seems to have 0 effect on my containers. His /etc/default/lxd-bridge file is slightly different than mine though. He has LXD_BRIDGE="" whereas mine is set to LXD_BRIDGE="br0".



Contents of my host /etc/network/interfaces



# this is empty
source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto br0
iface br0 inet dhcp
bridge_ports enp7s0

iface enp7s0 inet manual


Contents of my default lxc profile which is currently assigned to all containers:



config:
environment.http_proxy: ""
user.network_mode: ""
description: Default LXD profile
devices:
eth0:
name: eth0
nictype: bridged
parent: br0
type: nic
name: default
used_by:


All my containers are running recent versions of ubuntu.



LXD version 2.0.11



Please let me know if there's any more information that I can provide.









share|improve this question











share|improve this question




share|improve this question










asked Mar 31 at 12:57









eiton

62




62











  • I've yet to try this myself, but have you tried 1) creating a config file with the static config under /etc/network/interfaces.d/, and 2) creating the /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the line network: config: disabled? My clean install of a 16.04-based container has the file /etc/network/interfaces.d/50-cloud-init.cfg and it has a comment with the info I just mentioned, which seems related to this issue and notes: Changes to it will not persist across an instance. To disable cloud-init's network configuration capabilities..., repeating the above.
    – code_dredd
    Apr 19 at 18:53











  • I tried out a few things, including the above, but so far, I can't get it to work. (The networking.service will exit with an error when you try to restart it to apply the changes.) I'll try a few more things to see if I manage to find a solution for it.
    – code_dredd
    Apr 19 at 21:44
















  • I've yet to try this myself, but have you tried 1) creating a config file with the static config under /etc/network/interfaces.d/, and 2) creating the /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the line network: config: disabled? My clean install of a 16.04-based container has the file /etc/network/interfaces.d/50-cloud-init.cfg and it has a comment with the info I just mentioned, which seems related to this issue and notes: Changes to it will not persist across an instance. To disable cloud-init's network configuration capabilities..., repeating the above.
    – code_dredd
    Apr 19 at 18:53











  • I tried out a few things, including the above, but so far, I can't get it to work. (The networking.service will exit with an error when you try to restart it to apply the changes.) I'll try a few more things to see if I manage to find a solution for it.
    – code_dredd
    Apr 19 at 21:44















I've yet to try this myself, but have you tried 1) creating a config file with the static config under /etc/network/interfaces.d/, and 2) creating the /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the line network: config: disabled? My clean install of a 16.04-based container has the file /etc/network/interfaces.d/50-cloud-init.cfg and it has a comment with the info I just mentioned, which seems related to this issue and notes: Changes to it will not persist across an instance. To disable cloud-init's network configuration capabilities..., repeating the above.
– code_dredd
Apr 19 at 18:53





I've yet to try this myself, but have you tried 1) creating a config file with the static config under /etc/network/interfaces.d/, and 2) creating the /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the line network: config: disabled? My clean install of a 16.04-based container has the file /etc/network/interfaces.d/50-cloud-init.cfg and it has a comment with the info I just mentioned, which seems related to this issue and notes: Changes to it will not persist across an instance. To disable cloud-init's network configuration capabilities..., repeating the above.
– code_dredd
Apr 19 at 18:53













I tried out a few things, including the above, but so far, I can't get it to work. (The networking.service will exit with an error when you try to restart it to apply the changes.) I'll try a few more things to see if I manage to find a solution for it.
– code_dredd
Apr 19 at 21:44




I tried out a few things, including the above, but so far, I can't get it to work. (The networking.service will exit with an error when you try to restart it to apply the changes.) I'll try a few more things to see if I manage to find a solution for it.
– code_dredd
Apr 19 at 21:44















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f434668%2fassigning-an-ipv4-address-to-lxd-linux-containers%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f434668%2fassigning-an-ipv4-address-to-lxd-linux-containers%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay