extend docs/lxd_container_home_server_networking_for_dummies.md

This commit is contained in:
Trent Palmer 2018-02-20 22:19:29 +00:00
parent 15e26954a8
commit 3fbd17720f
5 changed files with 176 additions and 21 deletions

View File

@ -256,6 +256,47 @@ your home network, and a second interface *eth1* connected to a non-natted subne
a static ip on which it will be able to talk directly to the other containers and the host
machine.
### exposed profile with a regular linux br0 interface bridge
You can configure an Ubuntu server with a br0 interface
```conf
# /etc/network/interfaces
auto lo
iface lo inet loopback
# br0 bridge in dhcp configuration with ethernet
# port ens2 added to it.
auto br0
iface br0 inet dhcp
bridge_ports ens2
bridge_stp off
bridge_maxwait 0
```
and a cooresponding profile....
```yaml
config: {}
description: exposed LXD profile
devices:
eth0:
nictype: bridged
parent: br0
type: nic
eth1:
nictype: bridged
parent: lxdbr1
type: nic
root:
path: /
pool: default
type: disk
name: exposed
used_by: []
```
## Assign Containers to Profiles and configure them to connect correctly.
There are a lot of different ways that a Linux instance can solicit network services. So for
@ -306,6 +347,44 @@ iface eth1 inet static
network 10.151.18.0
```
### ubuntu:16.04 using only dhcp for two nics
So the example here is tested with eth0 and eth1 connected to
br0 and lxdbr1 respectively. You need post-up hooks for both eth0 and
eth1 inside the containers, in order to specify the default route, eth0 gets it's configuration
dynamically by default from cloud-init. So disable cloud-init by
creating the following file on the container.
```conf
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
network: {config: disabled}
```
Then, on the container describe the interfaces.
```conf
# /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth1
iface eth1 inet dhcp
post-up route del default dev eth1
auto eth0
iface eth0 inet dhcp
post-up route add default dev eth0 via 192.168.1.1
```
and delete /etc/network/interfaces.d/50-cloud-init.cfg
```bash
rm /etc/network/interfaces.d/50-cloud-init.cfg
```
The advantage to this scenario is now you can make copies of the container
without having to update the network descriptions, because both interfaces
will solicit addresses via dhcp.
### debian stretch
The configuration for a debian stretch container is the same, except the the file

View File

@ -261,5 +261,5 @@
<!--
MkDocs version : 0.17.2
Build Date UTC : 2018-02-18 11:34:12
Build Date UTC : 2018-02-20 22:19:04
-->

View File

@ -407,6 +407,41 @@ to a macvlan, addressable from your lan, just like any other arbitrary computer
your home network, and a second interface <em>eth1</em> connected to a non-natted subnet, with
a static ip on which it will be able to talk directly to the other containers and the host
machine.</p>
<h3 id="exposed-profile-with-a-regular-linux-br0-interface-bridge">exposed profile with a regular linux br0 interface bridge</h3>
<p>You can configure an Ubuntu server with a br0 interface</p>
<pre><code class="conf"># /etc/network/interfaces
auto lo
iface lo inet loopback
# br0 bridge in dhcp configuration with ethernet
# port ens2 added to it.
auto br0
iface br0 inet dhcp
bridge_ports ens2
bridge_stp off
bridge_maxwait 0
</code></pre>
<p>and a cooresponding profile....</p>
<pre><code class="yaml">config: {}
description: exposed LXD profile
devices:
eth0:
nictype: bridged
parent: br0
type: nic
eth1:
nictype: bridged
parent: lxdbr1
type: nic
root:
path: /
pool: default
type: disk
name: exposed
used_by: []
</code></pre>
<h2 id="assign-containers-to-profiles-and-configure-them-to-connect-correctly">Assign Containers to Profiles and configure them to connect correctly.</h2>
<p>There are a lot of different ways that a Linux instance can solicit network services. So for
now I will just describe a method that will work here for a lxc container from ubuntu:16.04, as
@ -447,6 +482,37 @@ iface eth1 inet static
network 10.151.18.0
</code></pre>
<h3 id="ubuntu1604-using-only-dhcp-for-two-nics">ubuntu:16.04 using only dhcp for two nics</h3>
<p>So the example here is tested with eth0 and eth1 connected to
br0 and lxdbr1 respectively. You need post-up hooks for both eth0 and
eth1 inside the containers, in order to specify the default route, eth0 gets it's configuration
dynamically by default from cloud-init. So disable cloud-init by
creating the following file on the container.</p>
<pre><code class="conf"># /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
network: {config: disabled}
</code></pre>
<p>Then, on the container describe the interfaces.</p>
<pre><code class="conf"># /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth1
iface eth1 inet dhcp
post-up route del default dev eth1
auto eth0
iface eth0 inet dhcp
post-up route add default dev eth0 via 192.168.1.1
</code></pre>
<p>and delete /etc/network/interfaces.d/50-cloud-init.cfg</p>
<pre><code class="bash">rm /etc/network/interfaces.d/50-cloud-init.cfg
</code></pre>
<p>The advantage to this scenario is now you can make copies of the container
without having to update the network descriptions, because both interfaces
will solicit addresses via dhcp.</p>
<h3 id="debian-stretch">debian stretch</h3>
<p>The configuration for a debian stretch container is the same, except the the file
<code>/etc/network/interfaces</code> will also describe eth0, but you only have to add the

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
<url>
<loc>/</loc>
<lastmod>2018-02-18</lastmod>
<lastmod>2018-02-20</lastmod>
<changefreq>daily</changefreq>
</url>
@ -12,7 +12,7 @@
<url>
<loc>/apt_pinning_artful_aardvark_packages_in_xenial_xerus/</loc>
<lastmod>2018-02-18</lastmod>
<lastmod>2018-02-20</lastmod>
<changefreq>daily</changefreq>
</url>
@ -20,7 +20,7 @@
<url>
<loc>/lxd_container_home_server_networking_for_dummies/</loc>
<lastmod>2018-02-18</lastmod>
<lastmod>2018-02-20</lastmod>
<changefreq>daily</changefreq>
</url>
@ -28,7 +28,7 @@
<url>
<loc>/lxd_container_foo/</loc>
<lastmod>2018-02-18</lastmod>
<lastmod>2018-02-20</lastmod>
<changefreq>daily</changefreq>
</url>
@ -36,7 +36,7 @@
<url>
<loc>/how_to_reassign_a_static_ip_address_with_dnsmasq/</loc>
<lastmod>2018-02-18</lastmod>
<lastmod>2018-02-20</lastmod>
<changefreq>daily</changefreq>
</url>
@ -44,7 +44,7 @@
<url>
<loc>/serve_and_share_apps_from_your_phone_with_fdroid/</loc>
<lastmod>2018-02-18</lastmod>
<lastmod>2018-02-20</lastmod>
<changefreq>daily</changefreq>
</url>
@ -52,7 +52,7 @@
<url>
<loc>/nspawn/</loc>
<lastmod>2018-02-18</lastmod>
<lastmod>2018-02-20</lastmod>
<changefreq>daily</changefreq>
</url>
@ -60,7 +60,7 @@
<url>
<loc>/gentoo_lxd_container/</loc>
<lastmod>2018-02-18</lastmod>
<lastmod>2018-02-20</lastmod>
<changefreq>daily</changefreq>
</url>
@ -68,7 +68,7 @@
<url>
<loc>/mastodon_on_arch/</loc>
<lastmod>2018-02-18</lastmod>
<lastmod>2018-02-20</lastmod>
<changefreq>daily</changefreq>
</url>
@ -76,7 +76,7 @@
<url>
<loc>/debian_nspawn_container_on_arch_for_testing_apache_configurations/</loc>
<lastmod>2018-02-18</lastmod>
<lastmod>2018-02-20</lastmod>
<changefreq>daily</changefreq>
</url>
@ -84,7 +84,7 @@
<url>
<loc>/dynamic_cacheing_nginx_reverse_proxy_for_pacman/</loc>
<lastmod>2018-02-18</lastmod>
<lastmod>2018-02-20</lastmod>
<changefreq>daily</changefreq>
</url>
@ -92,7 +92,7 @@
<url>
<loc>/freebsd_jails_on_freenas/</loc>
<lastmod>2018-02-18</lastmod>
<lastmod>2018-02-20</lastmod>
<changefreq>daily</changefreq>
</url>
@ -100,7 +100,7 @@
<url>
<loc>/arch_redis_nspawn/</loc>
<lastmod>2018-02-18</lastmod>
<lastmod>2018-02-20</lastmod>
<changefreq>daily</changefreq>
</url>
@ -108,7 +108,7 @@
<url>
<loc>/arch_postgresql_nspawn/</loc>
<lastmod>2018-02-18</lastmod>
<lastmod>2018-02-20</lastmod>
<changefreq>daily</changefreq>
</url>
@ -116,7 +116,7 @@
<url>
<loc>/misc_tips_troubleshooting/</loc>
<lastmod>2018-02-18</lastmod>
<lastmod>2018-02-20</lastmod>
<changefreq>daily</changefreq>
</url>
@ -124,7 +124,7 @@
<url>
<loc>/self_signed_certs/</loc>
<lastmod>2018-02-18</lastmod>
<lastmod>2018-02-20</lastmod>
<changefreq>daily</changefreq>
</url>
@ -132,7 +132,7 @@
<url>
<loc>/selfoss_on_centos7/</loc>
<lastmod>2018-02-18</lastmod>
<lastmod>2018-02-20</lastmod>
<changefreq>daily</changefreq>
</url>
@ -140,7 +140,7 @@
<url>
<loc>/stupid_package_manager_tricks/</loc>
<lastmod>2018-02-18</lastmod>
<lastmod>2018-02-20</lastmod>
<changefreq>daily</changefreq>
</url>
@ -148,7 +148,7 @@
<url>
<loc>/stupid_kvm_tricks/</loc>
<lastmod>2018-02-18</lastmod>
<lastmod>2018-02-20</lastmod>
<changefreq>daily</changefreq>
</url>