Assigning an ipv4 address to (LXD) linux containers
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 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
networking lxc lxd
add a comment |
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 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
networking lxc lxd
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 linenetwork: {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 '18 at 18:53
I tried out a few things, including the above, but so far, I can't get it to work. (Thenetworking.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 '18 at 21:44
add a comment |
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 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
networking lxc lxd
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 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
networking lxc lxd
networking lxc lxd
edited 2 hours ago
Rui F Ribeiro
41.5k1483140
41.5k1483140
asked Mar 31 '18 at 12:57
eitoneiton
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 linenetwork: {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 '18 at 18:53
I tried out a few things, including the above, but so far, I can't get it to work. (Thenetworking.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 '18 at 21:44
add a comment |
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 linenetwork: {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 '18 at 18:53
I tried out a few things, including the above, but so far, I can't get it to work. (Thenetworking.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 '18 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 '18 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 '18 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 '18 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 '18 at 21:44
add a comment |
0
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',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
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 linenetwork: {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 '18 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 '18 at 21:44