<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Debian — LowEndSpirit</title>
        <link>https://staging.lowendspirit.com/index.php?p=/</link>
        <pubDate>Thu, 09 Apr 2026 07:30:14 +0000</pubDate>
        <language>en</language>
            <description>Debian — LowEndSpirit</description>
    <atom:link href="https://staging.lowendspirit.com/index.php?p=/discussions/tagged/debian/feed.rss" rel="self" type="application/rss+xml"/>
    <item>
        <title>Intel iGPU VAAPI in Unprivileged LXC 4.0 Container</title>
        <link>https://staging.lowendspirit.com/index.php?p=/discussion/3782/intel-igpu-vaapi-in-unprivileged-lxc-4-0-container</link>
        <pubDate>Wed, 16 Feb 2022 05:35:57 +0000</pubDate>
        <category>Technical</category>
        <dc:creator>yoursunny</dc:creator>
        <guid isPermaLink="false">3782@/index.php?p=/discussions</guid>
        <description><![CDATA[<blockquote><div>
  <p>This article is originally published on yoursunny.com blog <a href="https://yoursunny.com/t/2022/lxc-vaapi/" rel="nofollow">https://yoursunny.com/t/2022/lxc-vaapi/</a></p>
</div></blockquote>

<h2>Background</h2>

<p>I recently bought a DELL OptiPlex 7040 Micro desktop computer and wanted to operate it as a dedicated server.<br />
I installed Debian 11 on the computer, and placed it into the closet to be accessed over SSH only.<br />
To keep the host machine stable, I decide to run most workloads in <a rel="nofollow" href="https://wiki.debian.org/LXC">LXC</a> containers, which are said to be Fast-as-Metal.<br />
Since I <a rel="nofollow" href="https://yoursunny.com/t/2021/NDN-video-ndn6/">operate my own video streaming website</a>, I have an LXC container for encoding the videos.</p>

<p>The computer comes with an <a rel="nofollow" href="https://ark.intel.com/content/www/us/en/ark/products/88183/intel-core-i56500t-processor-6m-cache-up-to-3-10-ghz.html">Intel Core i5-6500T</a> processor.<br />
It has 4 hardware cores running at 2.50GHz frequency, and belongs to the Skylake family.<br />
FFmpeg is happily encoding my videos on this CPU.</p>

<p>As I read through the processor specification, I noticed this section:</p>

<ul>
<li><p>Processor Graphics: Intel&reg; HD Graphics 530</p>

<ul>
<li>Processor Graphics indicates graphics processing circuitry integrated into the processor, providing the graphics, compute, media, and display capabilities.</li>
</ul></li>
<li><p>Intel&reg; Quick Sync Video: Yes</p>

<ul>
<li>Intel&reg; Quick Sync Video delivers fast conversion of video for portable media players, online sharing, and video editing and authoring.</li>
</ul></li>
</ul>

<p>It seems that I have a GPU!<br />
Can I make use of this Intel GPU and accelerate video encoding workloads?</p>

<h2>Story</h2>

<blockquote><div>
  <p>If you just want the solution, skip to the <strong>TL;DR Steps to Enable VAAPI in LXC</strong> section at the end.</p>
</div></blockquote>

<h3>Testing VAAPI with Docker</h3>

<p>I read FFmpeg <a rel="nofollow" href="https://trac.ffmpeg.org/wiki/HWAccelIntro">HWAccelIntro</a> and <a rel="nofollow" href="https://trac.ffmpeg.org/wiki/Hardware/QuickSync">QuickSync</a> pages, and learned:</p>

<ul>
<li>FFmpeg supports hardware acceleration on various GPU brands including Intel, AMD, and NVIDIA.</li>
<li>Hardware encoders typically generate outputs of significantly lower quality than good software encoders, but are generally faster and do not use much CPU resource.</li>
<li><p>On Linux, FFmpeg may access Intel GPU through libmfx, OpenCL, or VAAPI.<br />
Among these, encoding is possible with libmfx or VAAPI.</p></li>
<li><p>Each generation Intel processors has different video encoding capabilities.<br />
For the Skylake family that I have, the integrated GPU can encode to H.264, MPEG-2, VP8, and H.265 formats.</p></li>
</ul>

<p>I decided to experiment with VAAPI, because it has the shortest name 🤪.<br />
I quickly found <a rel="nofollow" href="https://hub.docker.com/r/jrottenberg/ffmpeg">jrottenberg/ffmpeg</a> Docker image.<br />
Following the example commands on <a rel="nofollow" href="https://trac.ffmpeg.org/wiki/Hardware/VAAPI">FFmpeg VAAPI</a> page, I verified that my GPU can successfully encode videos to H264 format:</p>

<pre><code>docker run \
    --device /dev/dri \
    -v $(pwd):/data -w /data \
  jrottenberg/ffmpeg:4.1-vaapi \
    -loglevel info -stats \
    -vaapi_device /dev/dri/renderD128 \
    -i input.mov \
    -vf 'hwupload,scale_vaapi=w=640:h=480:format=nv12' \
    -preset ultrafast \
    -c:v h264_vaapi \
    -f mp4 output.mp4
</code></pre>

<h3>The renderD128 Device</h3>

<p>This above <code>docker run</code> command tells me that the <code>/dev/dri/renderD128</code> device is likely the key of getting Intel GPU to work in an LXC container.<br />
It is a character device with major number 226 and minor number 128.</p>

<pre><code>sunny@sunnyD:~$ ls -l /dev/dri
total 0
drwxr-xr-x 2 root root         80 Jan 22 11:04 by-path
crw-rw---- 1 root video  226,   0 Jan 22 11:04 card0
crw-rw---- 1 root render 226, 128 Jan 22 11:04 renderD128
</code></pre>

<p>Inside the container, this device does not exist.<br />
Naively, I tried <code>mknod</code>, but it returns an "operation not permitted" error:</p>

<pre><code>ubuntu@video:~$ ls -l /dev/dri
ls: cannot access '/dev/dri': No such file or directory

ubuntu@video:~$ sudo mkdir /dev/dri

ubuntu@video:~$ sudo mknod /dev/dri/renderD128 c 226 128
mknod: /dev/dri/renderD128: Operation not permitted
</code></pre>

<p>I searched for this problem over several weeks, found several articles regarding how to get <a rel="nofollow" href="https://forums.plex.tv/t/pms-installation-guide-when-using-a-proxmox-5-1-lxc-container/219728">Plex</a> or <a rel="nofollow" href="https://emby.media/community/index.php?/topic/49680-howto-vaapi-transcoding-inside-lxc-container/">Emby</a> media server to use VAAPI hardware encoding from LXC containers, but they are either using <a rel="nofollow" href="https://forum.proxmox.com/threads/lxc-no-permission-to-use-vaapi.91536/">Proxmox</a> or <a rel="nofollow" href="https://linuxcontainers.org/lxd/">LXD</a> (unavailable on Debian), both differ from the plain LXC that I'm trying to use.<br />
From these articles, I gathered enough hints on what's needed:</p>

<ul>
<li>LXC container cannot <code>mknod</code> arbitrary devices for security reasons.</li>
<li><p>To have a device inode in an LXC container, the container config must:</p>

<ul>
<li>grant permission with <code>lxc.cgroup.devices.allow</code> directive, and</li>
<li>mount the device with <code>lxc.mount.entry</code> directory.</li>
</ul></li>
<li><p>In addition to <code>ffmpeg</code>, it's necessary to install <code>vainfo i965-va-driver</code> packages (available on both Debian and Ubuntu).</p></li>
</ul>

<h3>nobody:nogroup</h3>

<p>With these configs in place, the device showed up in the container, but it does not work:</p>

<pre><code>ubuntu@video:~$ ls -l /dev/dri
total 0
crw-rw---- 1 nobody nogroup 226, 128 Jan 22 16:04 renderD128
ubuntu@video:~$ vainfo
error: can't connect to X server!
error: failed to initialize display
ubuntu@video:~$ sudo vainfo
error: XDG_RUNTIME_DIR not set in the environment.
error: can't connect to X server!
error: failed to initialize display
</code></pre>

<p>One suspicious thing is the <code>nobody:nogroup</code> owner on the renderD128 device.<br />
It differs from the <code>root:render</code> owner as seen on the host machine.<br />
Naively, I tried <code>chown</code>, but it returns an "invalid argument" error and has no effect:</p>

<pre><code>ubuntu@video:~$ sudo chown root:render /dev/dri/renderD128
chown: changing ownership of '/dev/dri/renderD128': Invalid argument

ubuntu@video:~$ ls -l /dev/dri
total 0
crw-rw---- 1 nobody nogroup 226, 128 Jan 22 16:04 renderD128
</code></pre>

<p><a rel="nofollow" href="https://www.reddit.com/r/Proxmox/comments/ii3u2c/comment/g36l72j/">A Reddit post</a> claims that running <code>chmod 0666 /dev/dri/renderD128</code> from the host machine would solve this problem.<br />
I gave it a try and it was indeed effective.<br />
However, I know this isn't a <em>proper</em> solution because you are not supposed to change permission on device inodes.<br />
So I continued searching.</p>

<h3>idmap</h3>

<p>The last piece of the puzzle lies in <a rel="nofollow" href="https://man7.org/linux/man-pages/man7/user_namespaces.7.html">user and group ID mappings</a>.<br />
In an unprivileged LXC container, user and group IDs are shifted, so that the root user (UID 0) inside the container would not gain root privilege on the host machine.<br />
<code>lxc.idmap</code> directive in the container config controls these mappings.<br />
In my container, the relevant config was:</p>

<pre><code># map container UID 0~65535 to host UID 100000~165535
lxc.idmap = u 0 100000 65536
# map container GID 0~65535 to host GID 100000~165535
lxc.idmap = g 0 100000 65536
</code></pre>

<p>Notably, the <code>root</code> user (UID 0) and <code>render</code> group (GID 107) on the host user aren't mapped to anything in the container.<br />
The kernel <a rel="nofollow" href="https://discuss.linuxcontainers.org/t/strange-nobody-nogroup-ownership-in-unprivileged-lxc/1705/2">uses 65534 to represent a UID/GID which is outside the container's map</a>.<br />
Hence, the renderD128 device, when mounted into the container, has owner UID and GID being 65534:</p>

<pre><code>ubuntu@video:~$ ls -ln /dev/dri
total 0
crw-rw---- 1 65534 65534 226, 128 Jan 22 16:04 renderD128
</code></pre>

<p>65534 is the UID of <code>nobody</code> and the GID of <code>nogroup</code>, which is why this device appears to be owned by <code>nobody:nogroup</code>.</p>

<p>To make the renderD128 owned by <code>render</code> group, the correct solution is mapping the <code>render</code> group inside the container to the <code>render</code> group on the host.<br />
This, in turn, requires two ingredients:</p>

<ul>
<li><a rel="nofollow" href="https://man7.org/linux/man-pages/man5/subgid.5.html"><code>/etc/subgid</code></a> must authorize the host user who starts the container to map the GID of the host's <code>render</code> group into child namespaces.</li>
<li>The container config should have an <code>lxc.idmap</code> directive that maps the GID of the container's <code>render</code> group to the GID of the host's <code>render</code> group.</li>
</ul>

<p>So I added <code>lxc:107:1</code> to <code>/etc/subgid</code>, in which <code>lxc</code> is the ordinary user on the host machine that starts the containers, and <code>107</code> is the GID of <code>render</code> group on the host machine.<br />
Then I modified the container config as:</p>

<pre><code># map container UID 0-65535 to host UID 100000-165535
lxc.idmap = u 0 100000 65536
# map container GID 0-65535 to host GID 100000-165535
lxc.idmap = g 0 100000 65536
# map container GID 109 to host GID 107
lxc.idmap = g 109 107 1
</code></pre>

<p>However, the container fails to start:</p>

<pre><code>lxc@sunnyD:~$ lxc-unpriv-start -F video
Running scope as unit: run-r611f1778b87645918a2255d44073b86b.scope
lxc-start: video: conf.c: lxc_map_ids: 2865 newgidmap failed to write mapping "newgidmap: write to gid_map failed: Invalid argument": newgidmap 5297 0 100000 65536 109 107 1
             lxc-start: video: start.c: lxc_spawn: 1726 Failed to set up id mapping.
</code></pre>

<p>Re-reading <a rel="nofollow" href="https://man7.org/linux/man-pages/man7/user_namespaces.7.html">user&#95;namespaces(7)</a> manpage reveals the reason:</p>

<blockquote><div>
  <p>Defining user and group ID mappings: writing to uid_map and gid_map</p>
  
  <ul>
  <li>The range of user IDs (group IDs) specified in each line cannot overlap with the ranges in any other lines.</li>
  </ul>
</div></blockquote>

<p>The above container config defines two group ID mappings that overlaps at the GID 109, which causes the failure.<br />
Instead, it must be split to three ranges: 0-108 mapped to 100000-100108, 109 mapped to 107, 110-65535 mapped to 100110-165535.</p>

<p>Another idea I had, changing the GID of the <code>render</code> group to a large number greater than 65535 and thus dodge the overlap, turns out to be a bad idea, as it causes an error during system upgrades:</p>

<pre><code>ubuntu@video:~$ sudo apt full-upgrade
Setting up udev (245.4-4ubuntu3.15) ...
The group `render' already exists and is not a system group. Exiting.
dpkg: error processing package udev (--configure):
 installed udev package post-installation script subprocess returned error exit status 1
</code></pre>

<p>Hence, I must carefully calculate the GID ranges and write three GID mapping entries.<br />
With this final piece in place, success!</p>

<pre><code>ubuntu@video:~$ vainfo 2&gt;/dev/null | head -10
vainfo: VA-API version: 1.7 (libva 2.6.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Skylake - 2.4.0
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
</code></pre>

<p>Encoding speed comparison on one of my videos:</p>

<ul>
<li><p>h264, ultrafast, 640x480 resolution</p></li>
<li><p>Intel GPU VAAPI encoding:</p>

<pre><code>frame= 2900 fps=201 q=-0.0 Lsize=   18208kB time=00:01:36.78 bitrate=1541.2kbits/s speed=6.71x
video:16583kB audio:1528kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.533910%
</code></pre></li>
<li><p>Skylake CPU encoding:</p>

<pre><code>frame= 2900 fps=171 q=-1.0 Lsize=   18786kB time=00:01:36.78 bitrate=1590.1kbits/s speed=5.71x
video:17177kB audio:1528kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.434900%
</code></pre></li>
<li><p>GPU encoding was 17.5% faster than CPU encoding.</p></li>
</ul>

<h2>TL;DR Steps to Enable VAAPI in LXC</h2>

<ol>
<li><p>Confirm that the <code>/dev/dri/renderD128</code> device exists on the host machine.</p>

<pre><code>lxc@sunnyD:~$ ls -l /dev/dri/renderD128
crw-rw---- 1 root render 226, 128 Jan 22 11:04 /dev/dri/renderD128
</code></pre>

<p>If the device does not exist, you do not have an Intel GPU or it is not recognized by the kernel.<br />
You must resolve this issue before proceeding to the next step.</p></li>
<li><p>Find the GID of the <code>render</code> group on the host machine:</p>

<pre><code>lxc@sunnyD:~$ getent group render
render:x:107:
</code></pre>

<p>On my computer, the GID is 107.</p></li>
<li><p>Authorize the host user who starts LXC containers to map the GID to child namespaces.</p>

<ol>
<li><p>Run <code>sudoedit /etc/subgid</code> to open the editor.</p></li>
<li><p>Append a line:</p>

<pre><code>lxc:107:1
</code></pre></li>
</ol>

<p>Explanation:</p>

<ul>
<li><code>lxc</code> refers to the host user account.</li>
<li><code>107</code> is the GID of the <code>render</code> group, as seen in step 2.</li>
<li><code>1</code> means authorizing just one GID.</li>
</ul></li>
<li><p>Create and start an LXC container, and find out the GID of the container's <code>render</code> group.<br />
I'm using a Ubuntu 20.04 template, but the same procedure is applicable to other templates.</p>

<pre><code>lxc@sunnyD:~$ export DOWNLOAD_KEYSERVER=keyserver.ubuntu.com

lxc@sunnyD:~$ lxc-create -n video -t download -- -d ubuntu -r focal -a amd64
Using image from local cache
Unpacking the rootfs

You just created an Ubuntu focal amd64 (20211228_07:42) container.

To enable SSH, run: apt install openssh-server
No default root or user password are set by LXC.

lxc@sunnyD:~$ lxc-unpriv-start video
Running scope as unit: run-re7a88541bd5d42ab92c9ea6d4cd2a19f.scope

lxc@sunnyD:~$ lxc-unpriv-attach video getent group render
Running scope as unit: run-reaad3e4a549a420bacb160fd8cbc87a8.scope
render:x:109:
</code></pre></li>
<li><p>Edit the container config.</p>

<ol>
<li><p>Run <code>editor ~/.local/share/lxc/video/config</code> to open the editor.</p></li>
<li><p>Delete existing lines that start with <code>lxc.idmap = g</code>.</p>

<p>However, do not delete lines that start with <code>lxc.idmap = u</code>.</p></li>
<li><p>Append these lines:</p>

<pre><code>lxc.idmap = g 0 100000 109
lxc.idmap = g 109 107 1
lxc.idmap = g 110 100110 65426
lxc.cgroup.devices.allow = c 226:128 rwm
lxc.mount.entry = /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file
</code></pre></li>
</ol>

<p>Explanation:</p>

<ul>
<li><p>The <code>lxc.idmap = g</code> directive defines a group ID mapping.</p>

<ul>
<li><code>109</code> is the GID of the container's <code>render</code> group, as seen instep 4.</li>
<li><code>107</code> is the GID of the host's <code>render</code> group, as seen in step 2.</li>
</ul></li>
<li><p>The <code>lxc.cgroup.devices.allow</code> directive exposes a device to the container.</p>

<ul>
<li><code>226:127</code> is the major number and minor number of the renderD128 device, as seen in step 1.</li>
</ul></li>
<li><p>The <code>lxc.mount.entry</code> directive mounts the host's renderD128 device into the container.</p></li>
</ul>

<p>You may use this handy idmap calculator to generate the <code>lxc.idmap</code> directives:<br />
(read original article <a href="https://yoursunny.com/t/2022/lxc-vaapi/" rel="nofollow">https://yoursunny.com/t/2022/lxc-vaapi/</a> to use the JavaScript calculator)</p></li>
<li><p>Restart the container and attach to its console.</p>

<pre><code>lxc@sunnyD:~$ lxc-stop video

lxc@sunnyD:~$ lxc-unpriv-start video
Running scope as unit: run-r77f46b8ba5b24254a99c1ef9cb6384c3.scope

lxc@sunnyD:~$ lxc-unpriv-attach video
Running scope as unit: run-r11cf863c81e74fcfa1615e89902b1284.scope
</code></pre></li>
<li><p>Install FFmpeg and VAAPI packages in the container.</p>

<pre><code>root@video:/# apt update

root@video:/# apt install --no-install-recommends ffmpeg vainfo i965-va-driver
0 upgraded, 148 newly installed, 0 to remove and 15 not upgraded.
Need to get 79.2 MB of archives.
After this operation, 583 MB of additional disk space will be used.
Do you want to continue? [Y/n]
</code></pre></li>
<li><p>Confirm that the <code>/dev/dri/renderD128</code> device exists in the container and is owned by <code>render</code> group.</p>

<pre><code>root@video:/# ls -l /dev/dri/renderD128
crw-rw---- 1 nobody render 226, 128 Jan 22 16:04 /dev/dri/renderD128
</code></pre>

<p>It's normal for the owner user to show as <code>nobody</code>.<br />
This does not affect operation as long as the calling user is a member of the <code>render</code> group.<br />
The only implication is that, the container's <code>root</code> user cannot access the renderD128 unless it is added to the <code>render</code> group.</p></li>
<li><p>Add container's user account(s) to <code>render</code> group.<br />
These users will have access to the GPU.</p>

<pre><code>root@video:/# /sbin/adduser ubuntu render
Adding user `ubuntu' to group `render' ...
Adding user ubuntu to group render
Done.
</code></pre></li>
<li><p>Become one of these users, and verify the Intel iGPU is operational in the LXC container.</p>

<pre><code>root@video:/# sudo -iu ubuntu

ubuntu@video:~$ vainfo
error: XDG_RUNTIME_DIR not set in the environment.
error: can't connect to X server!
libva info: VA-API version 1.7.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: va_openDriver() returns -1
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_6
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.7 (libva 2.6.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Skylake - 2.4.0
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileH264ConstrainedBaseline: VAEntrypointFEI
      VAProfileH264ConstrainedBaseline: VAEntrypointStats
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointEncSliceLP
      VAProfileH264Main               : VAEntrypointFEI
      VAProfileH264Main               : VAEntrypointStats
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointEncSliceLP
      VAProfileH264High               : VAEntrypointFEI
      VAProfileH264High               : VAEntrypointStats
      VAProfileH264MultiviewHigh      : VAEntrypointVLD
      VAProfileH264MultiviewHigh      : VAEntrypointEncSlice
      VAProfileH264StereoHigh         : VAEntrypointVLD
      VAProfileH264StereoHigh         : VAEntrypointEncSlice
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileVP8Version0_3          : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
</code></pre></li>
</ol>

<h2>Conclusion</h2>

<p>This article explores how to make use of Intel processor's integrated GPU in an unprivileged LXC 4.0 container, on Debian 11 bullseye host machine without Proxmox or LXD.<br />
The key points include mounting the renderD128 device into the container, configuring idmap for the <code>render</code> group, and verifying the setup with <code>vainfo</code> command.<br />
The result is an LXC container that can encode videos to H.264 and other formats in the GPU with Intel Quick Sync Video feature, which is 17.5% faster than CPU encoding.</p>
]]>
        </description>
    </item>
    <item>
        <title>How to Create and Setup a Debian KVM VPS with Proxmox VE 6 -- Part III -- Network Configuration</title>
        <link>https://staging.lowendspirit.com/index.php?p=/discussion/3933/how-to-create-and-setup-a-debian-kvm-vps-with-proxmox-ve-6-part-iii-network-configuration</link>
        <pubDate>Fri, 23 Jul 2021 12:00:00 +0000</pubDate>
        <category>LES Talk</category>
        <dc:creator>Not_Oles</dc:creator>
        <guid isPermaLink="false">3933@/index.php?p=/discussions</guid>
        <description><![CDATA[<p><em>Written by <a href="https://staging.lowendspirit.com/index.php?p=/profile/Not_Oles" rel="nofollow">@Not_Oles</a>, 23 Jul 2021</em><br />
<small>Article was migrated from WordPress to Vanilla in March 2022</small></p>

<p>
  <img src="https://talk.lowendspirit.com/uploads/editor/n9/cixat1djj0ag.png" alt="image" />
</p>

<h2>I. Before We Start</h2>

<p>We need to obtain our basic network configuration from our provider. Or, if we are running our own host node, we need to assign basic network configuration to ourselves. Our basic network configuration might look something like this:</p>

<table>
<thead>
<tr>
  <th><strong>Item</strong></th>
  <th><strong>Value</strong></th>
</tr>
</thead>
<tbody>
<tr>
  <td>IPv4 address</td>
  <td>172.16.165.97/28</td>
</tr>
<tr>
  <td>Netmask</td>
  <td>255.255.255.240</td>
</tr>
<tr>
  <td>Broadcast</td>
  <td>172.16.165.111</td>
</tr>
<tr>
  <td>Gateway</td>
  <td>172.16.164.1</td>
</tr>
</tbody>
</table>

<p>For IPv6, one might expect something like:</p>

<table>
<thead>
<tr>
  <th><strong>Item</strong></th>
  <th><strong>Value</strong></th>
</tr>
</thead>
<tbody>
<tr>
  <td>IPv6 address</td>
  <td>fe80::/64</td>
</tr>
</tbody>
</table>

<p>But occasionally, IPv6 could be something like:</p>

<table>
<thead>
<tr>
  <th><strong>Item</strong></th>
  <th><strong>Value</strong></th>
</tr>
</thead>
<tbody>
<tr>
  <td>IPv6 address</td>
  <td>fe80:xxxx:xxxx:xxxx::97/128</td>
</tr>
<tr>
  <td>Gateway6</td>
  <td>fe80:xxxx:xxxx:xxxx::3</td>
</tr>
</tbody>
</table>

<p>Notes:</p>

<ul>
<li>The /28 in the IPv4 address and the longer netmask are <a rel="nofollow" href="https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#:~:text=CIDR%20notation%20is%20a%20compact,bits%20in%20the%20network%20mask.">different ways of providing the same information about the size of the local, directly connected network.</a> It suffices for us to have this information in one format or the other. We don't need both formats because the information is the same. Also, the broadcast IP might not be provided, since it isn't strictly necessary.</li>
<li>For the second format of the IPv6 address, <strong>what happened to the /64</strong>? 😱 The /128 in the second form of the IPv6 address might seem <strong><em>clueless</em></strong> to IPv6 fans expecting a /64. Also, the second format of the IPv6 address includes a gateway6 address. The gateway6 address might seem strange to some IPv6 fans, but we need the gateway6 for our minimal, static configuration. More on all this below.</li>
</ul>

<h2>II. Introduction</h2>

<p>In <a rel="nofollow" href="https://lowendspirit.com/how-to-create-and-setup-a-debian-kvm-vps-with-proxmox-ve-6-part-ii-debian-install/">the previous post of this series</a> we finished using the Proxmox web GUI to install our new Debian KVM VPS via the <a rel="nofollow" href="https://www.debian.org/CD/netinst/">Debian netinst installer iso image.</a> The final step in Part II was removing the netinst install iso image from the emulated cdrom and then reooting our new VM, which came up from its own internal filesystem:</p>

<p><img src="https://talk.lowendspirit.com/uploads/editor/hs/2qx8afaew937.png" alt="" title="" /></p>

<p>In today's post, we continue from this exact place where we left Part II -- connected to our newly installed and newly rebooted KVM via the Proxmox web GUI. In this post, we will accomplish the networking configuration which was skipped in Part II because the <a rel="nofollow" href="https://talk.lowendspirit.com/discussion/comment/63101/#Comment_63101">Debian netinst iso doesn't automatically configure out of band IP addresses.</a></p>

<p>There are three network configuration and related tasks we will accomplish today:</p>

<ul>
<li>First, we go "inside" our VM through the Proxmox web GUI's emulated "physical" console connection and set up networking. In Debian, networking setup requires that we adjust the file /etc/network/interfaces to tell our VM its network address and the address of its gateway to the internet.</li>
<li>Second, we edit the file /etc/resolv.conf to tell our VM the numerical addresses of <a rel="nofollow" href="https://en.wikipedia.org/wiki/Domain_Name_System">Domain Name System ("DNS")</a> servers it can use to translate human readable <a rel="nofollow" href="https://en.wikipedia.org/wiki/Uniform_Resource_Identifier">Uniform Resource Identifiers (URI)</a> into numerical <a rel="nofollow" href="https://en.wikipedia.org/wiki/IP_address">Internet Protocaol ("IP") addresses.</a></li>
<li>Third, we set up /etc/apt/sources.list to tell our system's <a rel="nofollow" href="https://www.debian.org/doc/manuals/debian-faq/uptodate.en.html">Aptitude software package manager ("APT")</a> where to get software updates and the additional software packages we will want to install.</li>
</ul>

<p>Section III, Quick Setup, runs quickly through all three of today's tasks in "recipe style."</p>

<p>Section IV offers additional context on our setup environment.</p>

<p>Sections V, VI, and VII provide additional details on today's three setup tasks.</p>

<p>Section VIII discusses security.</p>

<p>Section IX discusses backup.</p>

<p>When we finish the Quick Setup, our new Debian KVM VPS should be connected to the internet, DNS should work, and we should be able to use the Debian package system to add whatever additional software we want.</p>

<p>When we finish all of today's post, we should have reasonable context within which to understand our Debian VM's networking setup.</p>

<h2>III. Quick Setup</h2>

<p>Logged into our VM through the Proxmox web GUI, we run the command <code>ip link show</code>. This command will give us the name of our network interface, probably something like "ens18."</p>

<p>As root or with <code>sudo</code>, we edit the text of the file /etc/network/interfaces so that it contains the minimum necessary information:</p>

<pre><code>auto ens18
iface ens18 inet static
  address IPv4_ADDRESS/CIDR
  gateway GATEWAY_ADDRESS

iface ens18 inet6 static
  address IPv6_ADDRESS/CIDR
  gateway GATEWAY6_ADDRESS
</code></pre>

<p>Using our example network configuration, our minimal /etc/network/interfaces looks like this:</p>

<pre><code>auto ens18
iface ens18 inet static
  address 172.16.165.97/28
  gateway 172.16.164.1

iface ens18 inet6 static
  address fe80:xxxx:xxxx:xxxx::97/128
  gateway fe80:xxxx:xxxx:xxxx::3
</code></pre>

<p>Second, we edit the /etc/resolv.conf file so that it looks like this:</p>

<pre><code>nameserver 1.1.1.1
nameserver 8.8.8.8
nameserver 2606:4700:4700::1111
nameserver 2001:4860:4860::8888
</code></pre>

<p>Third, we edit /etc/apt/sources.list so that it looks like this:</p>

<pre><code>deb http://deb.debian.org/debian buster main contrib non-free

deb http://deb.debian.org/debian-security/ buster/updates main contrib non-free

deb http://deb.debian.org/debian buster-updates main contrib non-free
</code></pre>

<p>Finally, we restart networking so that our new configuration takes effect:</p>

<pre><code>systemctl restart networking
</code></pre>

<p>At this point, we should have both IPv4 and IPv6 connectivity, and DNS and APT both should work.</p>

<h2>IV. More Context</h2>

<ul>
<li><strong>Virtualized Console Connection</strong></li>
</ul>

<p>The Proxmox web GUI virtualizes a wired console connection. In other words, our web browser does connect over the internet to our Proxmox server, but, the view from inside our new KVM is the same as though a wired connection was attached. Our new KVM thinks it's talking over a wired connection to a physical console. From inside our new KVM, there is, as yet, no network connection.</p>

<p>By default, the Proxmox web GUI works via <a rel="nofollow" href="https://en.wikipedia.org/wiki/Virtual_Network_Computing">VNC.</a> <a rel="nofollow" href="https://pve.proxmox.com/wiki/Serial_Terminal">In the Proxmox wiki on serial terminal</a> Proxmox warns that VNC might</p>

<blockquote><div>
  <p>not have the features you need (i.e. easy copy/paste between other terminals)</p>
</div></blockquote>

<p>or it might be</p>

<blockquote><div>
  <p>impossible to capture all &#91;kernel messages, standard output, or error&#93; messages on &#91;the&#93; VNC screen.</p>
</div></blockquote>

<p>Yep, copy / paste commands <a rel="nofollow" href="https://forum.proxmox.com/threads/copy-paste-keys-commands-for-ct-kvm-vnc-console.28037/">do not seem to work in the Proxmox KVM virtual console.</a></p>

<p>Also, if you enjoy using the vi editor, you might find what looks like a "Send-Esc" button among the set of choices within the set exposed by the top button on the console VNC control bar. Use of the real keyboard Escape key results in exiting full screen. However, a second real Esc seems to produce the expected mode change, despite that maybe we no longer can see too well without returning to full screen.</p>

<ul>
<li><strong>No DHCP, No SLAAC</strong></li>
</ul>

<p>These days most network setups use <a rel="nofollow" href="https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol">Dynamic Host Configuration Protocol (DHCP)</a> to autoconfigure IPv4 networking. The machine on which networking is to be configured asks for and receives from a DHCP server all the needed information for the networking setup.</p>

<p>It is possible to configure DHCP so that it always returns the same IP address to each VM, but, since our entire Proxmox network is static, it may be simpler to set up networking manually--the traditional way for servers.</p>

<p><a rel="nofollow" href="https://en.wikipedia.org/wiki/IPv6#Stateless_address_autoconfiguration_(SLAAC)">Stateless Address Autoconfiguration ("SLAAC")</a> provides automatic configuration of IPv6 addresses. SLAAC requires a /64, which is why people say, for IPv6, that a /64 is expected and that less than a /64 is <em>clueless.</em> However, it remains possible to hand configure a single static IPv6 address, as we are doing here.</p>

<p>What if, for whatever reason, we simply do not want to use SLAAC? What if our provider doesn't receive enough IPv6 addresses from <em>his</em> provider to allow passing on to each VPS its own /64? What if our provider's provider charges an extra fee for extra IPv6 addresses, but we do not want to pay our provider's pass through of his provider's extra fee? What if we simply choose to use single, static IPs as is traditional for servers?</p>

<ul>
<li><strong>No Cloud-Init</strong></li>
</ul>

<p>As mentioned in <a rel="nofollow" href="https://lowendspirit.com/how-to-create-and-setup-a-debian-kvm-vps-with-proxmox-ve-6-part-ii-debian-install/">the previous post of this series,</a> most VM network setups these days are done with <a rel="nofollow" href="https://github.com/canonical/cloud-init">Cloud-Init.</a> Proxmox <a rel="nofollow" href="https://pve.proxmox.com/wiki/Cloud-Init_Support">supports Cloud-Init,</a> which enables both networking and ssh access to virtual machines to be set up on the Proxmox hypervisor and outside of the VM. Cloud-init can use DHCP. Here, however, we have chosen the simplest possible manual configuration with static IPs.</p>

<ul>
<li><strong>Our Static, Routed Configuration And Out of Band Gateway From Our Provider's Provider</strong></li>
</ul>

<p>Here, our single, static IPv4 and single, static IPv6 are each derived from a <a rel="nofollow" href="https://en.wikipedia.org/wiki/Routing">routed subnet</a> assigned to our server node. However, our internet gateway IPv4 address is not included among our server's routed group of IPv4s. This is called an "out of band" gateway.</p>

<p>Besides routed subnets, it also is possible for a datacenter to assign to servers non-routed, individual IP addresses. Data for these non-routed IPs moves between the datacenter switch and server nodes via <a rel="nofollow" href="https://en.wikipedia.org/wiki/Network_layer">the "link layer."</a> Hetzner has a <a rel="nofollow" href="https://docs.hetzner.com/robot/dedicated-server/network/net-config-debian/">tutorial on Debian network configuration</a> which includes discussion of "bridged configuration" for non-routed IPs.</p>

<ul>
<li><strong>Systemd in Debian Networking</strong></li>
</ul>

<p><a rel="nofollow" href="https://lwn.net/Articles/585319/">Since about 2014,</a> networking is setup on Debian with <a rel="nofollow" href="https://en.wikipedia.org/wiki/Systemd">systemd.</a> The choice of systemd <a rel="nofollow" href="https://lwn.net/Articles/585363/">initially was</a> and <a rel="nofollow" href="https://www.howtogeek.com/675569/why-linuxs-systemd-is-still-divisive-after-all-these-years/">has continued to be divisive.</a> Nevertheless systemd has remained as the Debian default.</p>

<p>There are at least two basic variations of Debian's systemd network arrangement. The first--which seems to be the default variation for Debian systemd network configuration--at least with the netinst iso--is using systemd's networking.service. For example, by using <code>systemctl</code>, we can confirm that networking.service is what is being used on our Node:</p>

<pre><code>root@Proxmox-VE ~ # systemctl status networking.service
● networking.service - Raise network interfaces
   Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: 
   Active: active (exited) since Wed 2021-06-02 19:13:13 UTC; 1 weeks 2 days ago
     Docs: man:interfaces(5)
 Main PID: 791 (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 4915)
   Memory: 0B
   CGroup: /system.slice/networking.service

 [ . . . ]
root@Proxmox-VE ~ # 
</code></pre>

<p>Our test KVM also seems to think its networking is controlled by systemd:</p>

<pre><code>root@debian-kvm:~# systemctl status networking
● networking.service - Raise network interfaces
   Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
   Active: active (exited) since Wed 2021-06-16 01:20:45 UTC; 4min 51s ago
     Docs: man:interfaces(5)
  Process: 448 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=0/SUCCESS)
 Main PID: 448 (code=exited, status=0/SUCCESS)

Jun 16 01:20:45 debian-kvm systemd[1]: Starting Raise network interfaces...
Jun 16 01:20:45 debian-kvm systemd[1]: Started Raise network interfaces.
root@debian-kvm:~#
</code></pre>

<p>As we can see, systemd networking.service calls the traditional debian <code>ifup</code> and <code>ifdown</code>.</p>

<pre><code>root@debian-kvm:~# cat /lib/systemd/system/networking.service
[Unit]
Description=Raise network interfaces
Documentation=man:interfaces(5)
DefaultDependencies=no
Requires=ifupdown-pre.service
Wants=network.target
After=local-fs.target network-pre.target apparmor.service systemd-sysctl.service systemd-modules-load.service ifupdown-pre.service
Before=network.target shutdown.target network-online.target
Conflicts=shutdown.target

[Install]
WantedBy=multi-user.target
WantedBy=network-online.target

[Service]
Type=oneshot
EnvironmentFile=-/etc/default/networking
ExecStart=/sbin/ifup -a --read-environment
ExecStop=/sbin/ifdown -a --read-environment --exclude=lo
RemainAfterExit=true
TimeoutStartSec=5min
root@debian-kvm:~# 
</code></pre>

<p>The second Debian systemd possibility--not the default on Debian netinst.iso and not used here--is systemd-networkd. Sahitya Maruvada has a simple, clear, Debian systemd-networkd introduction, <a rel="nofollow" href="https://medium.com/100-days-of-linux/working-with-systemd-networkd-e461cfe80e6d">Working with systemd-networkd.</a> The <a rel="nofollow" href="https://wiki.debian.org/SystemdNetworkd">systemd-networkd wiki page</a> and the <a rel="nofollow" href="https://manpages.debian.org/buster/systemd/systemd.network.5.en.html">systemd.network manpage</a> also are available.</p>

<ul>
<li><strong>Official Debian Network Setup Instructions</strong></li>
</ul>

<p>Official Debian network setup instructions include the <a rel="nofollow" href="https://wiki.debian.org/NetworkConfiguration">Wiki,</a> the <a rel="nofollow" href="https://www.debian.org/doc/manuals/debian-reference/ch05.en.html">Handbook,</a> manual pages such as <code>man interfaces</code>, /etc/network/interfaces examples <a rel="nofollow" href="https://salsa.debian.org/debian/ifupdown/-/blob/master/examples/network-interfaces">online,</a> and sometimes locally:</p>

<pre><code># less /usr/share/doc/ifupdown/examples/network-interfaces
</code></pre>

<ul>
<li><strong>The <code>ip</code> Command Usually Is Available Even Though Networking Setup Varies Among Linux Distributions</strong></li>
</ul>

<p>Setting up networking, DNS name resolution, and software package management is very different in different Linux distributions. Therefore, we should not assume that the steps taken below would be exactly the same with a different Linux distribution than Debian.</p>

<p>Nevertheless, despite the different distributions' differing network setup systems, the <code>ip</code> command, <a rel="nofollow" href="https://en.wikipedia.org/wiki/Iproute2">supplied by the iproute2 collection,</a> usually is available these days. Please see also Red Hat's <a rel="nofollow" href="https://access.redhat.com/sites/default/files/attachments/rh_ip_command_cheatsheet_1214_jcs_print.pdf">IP Command Cheat Sheet</a></p>

<p>Because the <code>ip</code> command often is available, networking can be configured in many distributions, including Debian, by running a sequence of <code>ip</code> commands. The net effect <img src="https://staging.lowendspirit.com/plugins/emojiextender/emoji/twitter/smile.png" title=":)" alt=":)" height="18" /> of the sequence of <code>ip</code> commands can be to get the network functioning on most distributions without touching that individual distribution's network setup scheme.</p>

<p>Here's <a rel="nofollow" href="https://talk.lowendspirit.com/discussion/comment/63067/#Comment_63067">an example</a> of the <code>ip</code> command used in the context of an <a rel="nofollow" href="https://en.wikipedia.org/wiki/IPXE">iPXE boot.</a> Note that the first command in the linked example requires knowledge of the name of the interface. We can list the names of the interfaces on our system by running the <code>ip link show</code> command.</p>

<p>One issue with using a sequence of <code>ip</code> commands is that the network setup fails to persist across reboots. However, we can place the <code>ip</code> command sequence inside a script which will be run automagically every time the server reboots. The sequence of <code>ip</code> commands in a script reminds us of the days before systemd, when scripts controlled all parts of the boot process including network setup.</p>

<p>Our KVM VPS's internal network configuration that we will be using below is similar to <a rel="nofollow" href="https://lowendspirit.com/creating-our-first-lxc-vps-with-proxmox-ve-6-2-at-soyoustart/">how LXC containers are configured in Proxmox.</a> As will be seen below, Proxmox's LXC containers' network configuration adopts a variant of the "scripted <code>ip</code> command" approach, which also works inside Proxmox's KVM VPSes.</p>

<h2>V. Our VM's Network Setup</h2>

<ul>
<li><strong>Interfaces</strong></li>
</ul>

<p>Our original /etc/network/interfaces file, the one installed by the netinst.iso, might look like this:</p>

<pre><code>debian@debian-kvm:~$ cd /etc/network
debian@debian-kvm:/etc/network$ cat interfaces.original
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback
debian@debian-kvm:/etc/network$ 
</code></pre>

<p>Note that, in the default from the netinst.iso, /etc/network/interfaces.d is empty, so sourcing its files does nothing to the configuration.</p>

<pre><code>debian@debian-kvm:/etc/network$ ls interfaces.d
debian@debian-kvm:/etc/network$ 
</code></pre>

<p>Now, let's edit /etc/network/interfaces to match our example network information from the above Before We Start section.</p>

<pre><code>debian@debian-kvm:/etc/network$ cat interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto ens18
iface ens18 inet static
  address 172.16.165.97/28
  gateway 172.16.164.1

iface ens18 inet6 static
  address fe80:xxxx:xxxx:xxxx::97/128
  gateway fe80:xxxx:xxxx:xxxx::3

debian@debian-kvm:/etc/network$ 
</code></pre>

<p>The minimum required information does not include comments (lines beginning with <code>#</code>). Maybe we can make the rash and short-sighted assumption that we are not going to install anything which will want a file included from interfaces.d. The loopback interface might no longer be required <a rel="nofollow" href="https://salsa.debian.org/debian/ifupdown/-/blob/master/examples/network-interfaces">(please see lines 17 and 18 in this file from Debian sources).</a> Thus, for our example setup, the minimum /etc/network/interfaces might be:</p>

<pre><code>debian@debian-kvm:/etc/network$ cat interfaces

auto ens18
iface ens18 inet static
  address 172.16.165.97/28
  gateway 172.16.164.1

iface ens18 inet6 static
  address fe80:xxxx:xxxx:xxxx::97/128
  gateway fe80:xxxx:xxxx:xxxx::3

debian@debian-kvm:/etc/network$ 
</code></pre>

<p>When configuring Debian LXC containers, Proxmox configures their /etc/network/interfaces files using added post-up and pre-down routes. Similarly, just for fun, instead of giving the gateway addresses in our /etc/network/interfaces,, we can manually add routes. Except for the initial <code>post-up</code> and <code>pre-down</code> these added lines mirror <a rel="nofollow" href="https://talk.lowendspirit.com/discussion/comment/63067/#Comment_63067"><code>ip route</code> commands that we could run manually</a> to set up or take down networking without touching the /etc/network/interfaces file.</p>

<pre><code>debian@debian-kvm:/etc/network$ cat interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto ens18
iface ens18 inet static
  address 172.16.165.97/28
     post-up ip route add 172.16.164.1 dev ens18
     post-up ip route add default via 172.16.164.1 dev ens18
     pre-down ip route del default via 172.16.164.1 dev ens18
     pre-down ip route del 172.16.164.1 dev ens18

iface ens18 inet6 static
  address fe80:xxxx:xxxx:xxxx::97/128
     post-up ip route add fe80:xxxx:xxxx:xxxx::3  dev ens18
     post-up ip route add default via fe80:xxxx:xxxx:xxxx::3  dev ens18
     pre-down ip route del default via fe80:xxxx:xxxx:xxxx::3  dev ens18
     pre-down ip route del fe80:xxxx:xxxx:xxxx::3  dev ens18

debian@debian-kvm:/etc/network$ 
</code></pre>

<h2>VI. Our VM's DNS</h2>

<p>We might want to add more or different nameservers to /etc/resolv.conf. Our Quick Setup configuration, above, includes <a rel="nofollow" href="https://blog.cloudflare.com/dns-resolver-1-1-1-1/">IPs from Cloudflare</a> and <a rel="nofollow" href="https://developers.google.com/speed/public-dns">from Google.</a></p>

<h2>VII. Our VM's Apt Setup</h2>

<p>The Debian wiki instructions for configuring apt are at <a rel="nofollow" href="https://wiki.debian.org/SourcesList">https://wiki.debian.org/SourcesList.</a> There also is a <a rel="nofollow" href="https://manpages.debian.org/buster/apt/sources.list.5.en.html">man page.</a> The configuration shown above, in Section III Quick Setup, is from the <a rel="nofollow" href="https://wiki.debian.org/SourcesList">SourcesList Debian wiki page.</a></p>

<p>The Debian <a rel="nofollow" href="https://www.debian.org/security/">Security Information page</a> says:</p>

<blockquote><div>
  <p>You can use apt to easily get the latest security updates. This requires a line such as<br />
  deb <a href="http://security.debian.org/debian-security" rel="nofollow">http://security.debian.org/debian-security</a> buster/updates main contrib non-free</p>
</div></blockquote>

<p>Many of the larger providers offer Debian mirrors. For example, Debian packages and security updates are available from the <a rel="nofollow" href="https://docs.hetzner.com/robot/dedicated-server/operating-systems/hetzner-aptitude-mirror/">Hetzner Debian Mirror</a></p>

<p>After /etc/sources.list is edited, we update our system's package repositories as follows:</p>

<pre><code>apt-get upgrade &amp;&amp; apt-get dist-upgrade -y
</code></pre>

<p>We can see exactly which packages are installed by looking at the logs in /var/log/apt.</p>

<p>We may wish to install openssh-server so that we can connect to our VM via ssh in addition to our Proxmox VNC connection. With ssh we regain cut and paste functionality while enjoying lower apparent latency!</p>

<pre><code>apt-get install openssh-server
</code></pre>

<p>The <a rel="nofollow" href="https://aboutbryan.com/2013/03/03/my-first-5-minutes-on-a-server-or-essential-security-for-linux-servers/">Kennedy article,</a> mentioned below in Section VII, has some good tips for ssh server configuration.</p>

<h2>VIII. Security</h2>

<p><a rel="nofollow" href="https://www.google.com">Google</a> suggests its <a rel="nofollow" href="https://aboutbryan.com/2013/03/03/my-first-5-minutes-on-a-server-or-essential-security-for-linux-servers/">first choice among essential server security articles.</a> This article from 2013, by Bryan Kennedy, seems to provide still-good advice, except that, nowadays, many people prefer to use <a rel="nofollow" href="https://en.wikipedia.org/wiki/EdDSA">ed25519 keys</a></p>

<h2>IX. Backup</h2>

<p>After all this work, we certainly want to make an offline backup of our new VM. We can <a rel="nofollow" href="https://pve.proxmox.com/wiki/Backup_and_Restore">use Proxmox to make the backup</a> and then download a a copy from the host node's /var/lib/vz/dump directory.</p>
]]>
        </description>
    </item>
    <item>
        <title>How to Create and Setup a Debian KVM VPS with Proxmox VE 6 — Part II — Debian Install</title>
        <link>https://staging.lowendspirit.com/index.php?p=/discussion/3917/how-to-create-and-setup-a-debian-kvm-vps-with-proxmox-ve-6-part-ii-debian-install</link>
        <pubDate>Mon, 21 Mar 2022 19:40:48 +0000</pubDate>
        <category>LES Talk</category>
        <dc:creator>Not_Oles</dc:creator>
        <guid isPermaLink="false">3917@/index.php?p=/discussions</guid>
        <description><![CDATA[<p><em>Written by <a href="https://staging.lowendspirit.com/index.php?p=/profile/Not_Oles" rel="nofollow">@Not_Oles</a>, 21 Apr 2021</em><br />
<small>Article was migrated from WordPress to Vanilla in March 2022</small></p>

<p>
  <img src="https://talk.lowendspirit.com/uploads/editor/n9/cixat1djj0ag.png" alt="image" />
</p>

<p><strong>Introduction</strong></p>

<p>In <a rel="nofollow" href="https://lowendspirit.com/how-to-create-and-setup-a-debian-kvm-vps-with-proxmox-ve-6-part-i-creation">Part I of this series</a>, we downloaded the <a rel="nofollow" href="https://www.debian.org/CD/netinst/">Debian netinst install iso</a>. We then created a KVM VPS with the iso attached, and, finally, we successfully booted the iso.</p>

<p>In today's post, we're going to install our KVM with Debian 10 from the newly booted iso. But first, a bit of context on installing.</p>

<p><strong>Context</strong></p>

<ul>
<li><strong>Why the Debian minimal netinst iso?</strong></li>
</ul>

<p>Debian themselves say, <a rel="nofollow" href="https://www.debian.org/CD/netinst/">"we think that in many cases the minimal CD image is better — above all, you only download the packages that you selected for installation on your machine. . . ."</a></p>

<p>What we gain from this series is a well-proven, widely used, minimal, highly extensible, open-source server operating system.</p>

<ul>
<li><strong>What about networking?</strong></li>
</ul>

<p>The biggest difference between installing on our VPS and installing on our personal laptop or desktop might be network configuration. On personal devices, we are used to automatic network configuration happening behind the scenes via <a rel="nofollow" href="https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol">Dynamic Host Configuration Protocol (DHCP)</a>. We turn on our device, it gets its own IP address and internet connection without our having to do much.</p>

<p>On servers, however, the server's IP address and internet connection sometimes are set by hand instead of automatically via DHCP. Traditionally, server network settings are done from a console physically connected to the running server. Obviously, however, if our server is at a remote location, we cannot have a wired connection. Also, since networking hasn't yet been set up inside the server, we can't connect directly to our remote server over the internet, either.</p>

<p>As might be expected, the Debian minimal netinst iso is set up to configure networking automatically via DHCP. Thus, when we try the networking step of the install, that step will fail. The netinst iso will succeed, however, in installing a minimal Debian system without networking. In Part III of this series, covering Post Install Configuration, we will use the Proxmox web GUI and VNC to go inside our minimal system and set up networking by hand.</p>

<ul>
<li><strong>Alternative installation methods</strong></li>
</ul>

<p>It might be worth mentioning a few of the many other excellent methods of server installation which, although frequently used, are not selected here because they might be even more complex than our "simple" <img src="images/smile.png" alt=":)" title=":)" /> method.</p>

<ul>
<li>First, <a rel="nofollow" href="https://lowendspirit.com/debian-unattended-installation-using-a-preseed-file">Debian unattended Installation using a preseed file</a> will not work here because no networking is set up to use for obtaining the preseed file.</li>
<li>Cloud-init is <a rel="nofollow" href="https://github.com/canonical/cloud-init">"the <em>industry standard</em> multi-distribution method for cross-platform cloud instance initialization."</a> However, the <a rel="nofollow" href="https://pve.proxmox.com/wiki/Cloud-Init_Support">Proxmox Cloud-Init Support wiki article</a> says, despite the convenience of ready-made images, "we usually recommended to prepare the images by yourself," because "you will know exactly what you have installed." Also, for a special perspective on Cloud-Init, you might enjoy watching <a rel="nofollow" href="https://www.hashicorp.com/resources/cloudinit-the-good-parts">Cloud-Init: The Good Parts.</a></li>
<li>Proxmox supports <a rel="nofollow" href="https://pve.proxmox.com/wiki/VM_Templates_and_Clones">Templates.</a> It's possible to create templates with <a rel="nofollow" href="https://www.packer.io/">Packer.</a> If interested, you can check <a rel="nofollow" href="https://dev.to/aaronktberry/creating-proxmox-templates-with-packer-1b35">Creating proxmox templates with packer.</a></li>
</ul>

<p><strong>Before We Start</strong></p>

<p>We need to begin today at <a rel="nofollow" href="https://lowendspirit.com/how-to-create-and-setup-a-debian-kvm-vps-with-proxmox-ve-6-part-i-creation">the exact stage where we left Part I.</a> Our Debian Installer should be booted and running on our VPS.</p>

<p>We also will need the server's hostname (which can be Debian) plus the username (which also can be Debian) and the real name for the user account which the installer will create. It's also convenient to have on hand two <a rel="nofollow" href="https://passwords-generator.org/">previously generated good passwords,</a> one for the root account and another for the new user account.</p>

<p><strong>Debian Installer Steps</strong></p>

<ul>
<li><strong>Select Install</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/h2/9s2boinm789t.png" alt="" title="" /></p>

<ul>
<li><strong>Language</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/oi/jyzq11ay2z2c.png" alt="" title="" /></p>

<ul>
<li><strong>Location</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/d8/4ogce6eln8c9.png" alt="" title="" /></p>

<ul>
<li><strong>Keyboard</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/10/ws7jw1dfl4uk.png" alt="" title="" /></p>

<ul>
<li><strong>DHCP Tries and Fails</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/00/qbxl1icecoc6.png" alt="" title="" /></p>

<p><img src="https://talk.lowendspirit.com/uploads/editor/dz/csnojjtvtggb.png" alt="" title="" /></p>

<ul>
<li><strong>Select "Do Not Configure Network at this Time"</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/9e/73uzhwy2lvp4.png" alt="" title="" /></p>

<ul>
<li><strong>Hostname</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/il/445y6j7140ya.png" alt="" title="" /></p>

<ul>
<li><strong>Enter and Confirm the Root Password</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/7n/9pzj9y6y9qtf.png" alt="" title="" /></p>

<p><img src="https://talk.lowendspirit.com/uploads/editor/ya/jymedyyrhi6x.png" alt="" title="" /></p>

<ul>
<li><strong>User's Real Name</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/o5/bbaqkg91187q.png" alt="" title="" /></p>

<ul>
<li><strong>Username</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/p7/a0ccap5kqxff.png" alt="" title="" /></p>

<ul>
<li><strong>User Password</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/40/9mkk3s6d1qzk.png" alt="" title="" /></p>

<p><img src="https://talk.lowendspirit.com/uploads/editor/od/sh8bx3s7ht09.png" alt="" title="" /></p>

<ul>
<li><strong>Time Zone</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/tq/1qgateac02jk.png" alt="" title="" /></p>

<ul>
<li><strong>Partitioning Method</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/3h/gxc2wxgj9mfk.png" alt="" title="" /></p>

<ul>
<li><strong>Disk to Partition</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/os/uvqci3hbc4vy.png" alt="" title="" /></p>

<ul>
<li><strong>Partitioning Scheme</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/pl/31wn8e92ka2o.png" alt="" title="" /></p>

<ul>
<li><strong>Confirm Partitioning</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/9l/hh5ah0wha62m.png" alt="" title="" /></p>

<ul>
<li><strong>Write Changes to Disks</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/io/55x6c3zhihri.png" alt="" title="" /></p>

<ul>
<li><strong>Confirm No Additional Install Media</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/n4/b8zo11jrg9vz.png" alt="" title="" /></p>

<ul>
<li><strong>Confirm No Network Mirror</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/tj/riw8uqbklrhr.png" alt="" title="" /></p>

<ul>
<li><strong>Package Usage Survey</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/nl/brp3sp93qayg.png" alt="" title="" /></p>

<ul>
<li><strong>Choose Additional Software</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/8p/vtuzuhlsub2p.png" alt="" title="" /></p>

<ul>
<li><strong>Dual Boot</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/ad/vzsroraic1ds.png" alt="" title="" /></p>

<ul>
<li><strong>Grub</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/rf/a825mn0s7p30.png" alt="" title="" /></p>

<ul>
<li><strong>Installation Complete</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/3g/q96cfykeh2zm.png" alt="" title="" /></p>

<p>In the Proxmox web GUI, we select VPS &gt; Hardware &gt; CD/DVD Drive. Press edit and select "Do not use any media." Then, we return to our "Installation Complete" screen by selecting Console, which should reappear just as we left it. Finally, we click the "Continue" button, which should reboot the VPS.</p>

<p>In <a rel="nofollow" href="https://lowendspirit.com/how-to-create-and-setup-a-debian-kvm-vps-with-proxmox-ve-6-part-i-creation">Part I</a>, we did not install Qemu Agent. Therefore, rebooting from the Proxmox web GUI (outside our VPS) as opposed to rebooting from the console (inside our VPS) might not work. However, if it is necessary to stop the server from the web GUI, we can use the web GUI's Stop command found on the drop-down menu of the Shutdown button.</p>

<ul>
<li><strong>Successful Reboot</strong></li>
</ul>

<p><img src="https://talk.lowendspirit.com/uploads/editor/yi/5qiz1u3nginb.png" alt="" title="" /></p>
]]>
        </description>
    </item>
    <item>
        <title>Another Panel or cPanel alternative discussion...</title>
        <link>https://staging.lowendspirit.com/index.php?p=/discussion/2399/another-panel-or-cpanel-alternative-discussion</link>
        <pubDate>Mon, 11 Jan 2021 04:53:29 +0000</pubDate>
        <category>Help</category>
        <dc:creator>TigersWay</dc:creator>
        <guid isPermaLink="false">2399@/index.php?p=/discussions</guid>
        <description><![CDATA[<p>Hi,<br />
I'm an happy new customer of Nexus Bytes, with a VPS I intend to share (a little) with 2 customers/friends. For the first time in my life I am asking myself if I would need a panel and of course which one  <img src="https://staging.lowendspirit.com/plugins/emojiextender/emoji/twitter/tongue.png" title=":p" alt=":p" height="18" /></p>

<p>Would you mind sharing advice?<br />
Which one(s) should I try first?</p>

<ul>
<li>Free is preferred of course but I'm okay to make them pay  <img src="https://staging.lowendspirit.com/plugins/emojiextender/emoji/twitter/smiley.png" title="=)" alt="=)" height="18" /></li>
<li>VPS is and always will be under Debian.</li>
</ul>

<p>Thanks</p>
]]>
        </description>
    </item>
    <item>
        <title>Any Direct Admin Backup Plugins that supports Debian</title>
        <link>https://staging.lowendspirit.com/index.php?p=/discussion/2343/any-direct-admin-backup-plugins-that-supports-debian</link>
        <pubDate>Wed, 30 Dec 2020 13:40:29 +0000</pubDate>
        <category>General</category>
        <dc:creator>sweatbar</dc:creator>
        <guid isPermaLink="false">2343@/index.php?p=/discussions</guid>
        <description><![CDATA[<p>Hello folks,</p>

<p>Do you know any backup plugins for Direct Admin that supports FTP Backups which runs on Debian 10 ?<br />
JetBackup - Not Supported<br />
Dabackup- No remote ftp backup</p>
]]>
        </description>
    </item>
    <item>
        <title>How to Select Default IPv6 Source Address for Outbound Traffic in OpenVZ 7</title>
        <link>https://staging.lowendspirit.com/index.php?p=/discussion/2249/how-to-select-default-ipv6-source-address-for-outbound-traffic-in-openvz-7</link>
        <pubDate>Sun, 13 Dec 2020 23:45:31 +0000</pubDate>
        <category>Technical</category>
        <dc:creator>yoursunny</dc:creator>
        <guid isPermaLink="false">2249@/index.php?p=/discussions</guid>
        <description><![CDATA[<blockquote><div>
  <p>This post is originally published on yoursunny.com blog <a href="https://yoursunny.com/t/2020/preferred-lft-vz7/" rel="nofollow">https://yoursunny.com/t/2020/preferred-lft-vz7/</a></p>
</div></blockquote>

<p>I bought a few Virtual Private Servers (VPS) on Black Friday, and have been busy setting them up.<br />
Nowadays, most VPS comes with an IPv6 <em>subnet</em> that contains millions of possible addresses.<br />
Initially, only one IPv6 address is assigned to the server, but the user can assign additional addresses as desired.<br />
Given that I plan to run multiple services within a server, I added a few more IPv6 addresses so that each service can have a unique IPv6 address.</p>

<p>One of my servers is using OpenVZ 7 virtualization technology, in which I installed Debian 10 operating system.<br />
Commonly, OpenVZ 7 uses <a rel="nofollow" href="https://wiki.openvz.org/Virtual_network_device">virtual network device (<em>venet</em>)</a> that does not have a MAC address.<br />
<em>venet</em> devices are <a rel="nofollow" href="https://wiki.openvz.org/IPv6">not fully IPv6 compliant</a>, but still works if you statically assign IPv6 addresses.<br />
Moreover, every IP address used in a container must be configured from the host node, because <em>venet</em> would drop ip-packets from the container with a source address, and in the container with the destination address, which is not corresponding to an ip-address of the container.<br />
Therefore, I must use the VPS control panel, in this case SolusVM, to assign IPv6 addresses to my server:</p>

<p><img src="https://yoursunny.com/t/2020/preferred-lft-vz7/SolusVM-IPv6.png" alt="IPv6 Subnet management in SolusVM" /></p>

<p>In the <em>Add IP</em> section, the IPv6 subnet prefix <code>2001:db8:f1c1:8454:0964:</code> is already shown.<br />
Notice that I am putting a colon (<code>:</code>) in front of the suffix <code>beef</code>, so that they concatenate to the full address <code>2001:db8:f1c1:8454:0964::beef</code>.<br />
Forgetting this colon would cause "Invalid Entry" error.</p>

<p>After making this change in the SolusVM control panel, the <code>/etc/network/interface</code> file on my server is updated automatically:</p>

<pre><code># This configuration file is auto-generated.
# WARNING: Do not edit this file, otherwise your changes will be lost.
# Please edit template /etc/network/interfaces.template instead.
auto lo
iface lo inet loopback
# Auto generated venet0 interfaces
auto venet0
iface venet0 inet static
        address 127.0.0.1
        netmask 255.255.255.255
        broadcast 0.0.0.0
        up route add default dev venet0
iface venet0 inet6 static
        address ::2
        netmask 128
        up ip -6 r a default dev venet0
        up ip addr add 2001:db8:f1c1:8454:0964::2/80 dev venet0
        up ip addr add 2001:db8:f1c1:8454:0964::beef/80 dev venet0
auto venet0:0
iface venet0:0 inet static
        address 10.10.23.159
        netmask 255.255.255.255
</code></pre>

<p>I'm also seeing two IPv6 addresses:</p>

<pre><code>$ ip addr
1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: venet0: &lt;BROADCAST,POINTOPOINT,NOARP,UP,LOWER_UP&gt; mtu 1500 qdisc noqueue state UNKNOWN group default
    link/void
    inet 127.0.0.1/32 scope host venet0
       valid_lft forever preferred_lft forever
    inet 192.0.2.30/32 brd 192.0.2.30 scope global venet0:0
       valid_lft forever preferred_lft forever
    inet6 2001:db8:f1c1:8454:0964::beef/80 scope global
       valid_lft forever preferred_lft forever
    inet6 2001:db8:f1c1:8454:0964::2/80 scope global
       valid_lft forever preferred_lft forever
    inet6 ::2/128 scope global
       valid_lft forever preferred_lft forever
</code></pre>

<p>I intend to host my secret beef recipes on its unique IPv6 address <code>2001:db8:f1c1:8454:0964::beef</code>, and use the other address <code>2001:db8:f1c1:8454:0964::2</code> for outbound traffic such as pings and traceroutes.<br />
However, I noticed that the wrong address is being selected for outgoing packets:</p>

<pre><code>$ ping 2001:db8:9f16:8fc7::9

$ sudo tcpdump -n icmp6
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ens3, link-type EN10MB (Ethernet), capture size 262144 bytes
10:25:18.264905 IP6 2001:db8:f1c1:8454:0964::beef &gt; 2001:db8:9f16:8fc7::9: ICMP6, echo request, seq 1, length 64
10:25:18.265014 IP6 2001:db8:9f16:8fc7::9 &gt; 2001:db8:f1c1:8454:0964::beef: ICMP6, echo reply, seq 1, length 64
10:25:19.264939 IP6 2001:db8:f1c1:8454:0964::beef &gt; 2001:db8:9f16:8fc7::9: ICMP6, echo request, seq 2, length 64
10:25:19.265013 IP6 2001:db8:9f16:8fc7::9 &gt; 2001:db8:f1c1:8454:0964::beef: ICMP6, echo reply, seq 2, length 64
</code></pre>

<p>I started searching for a solution, and learned that:</p>

<ul>
<li><a rel="nofollow" href="https://tools.ietf.org/html/rfc3484">Default Address Selection for Internet Protocol version 6 (IPv6)</a> is a very complicated topic.</li>
<li><p>An application can explicitly specify a source address.<br />
For example, I can invoke <code>ping -I 2001:db8:f1c1:8454:0964::2 2001:db8:9f16:8fc7::9</code> to use the desired source address.</p></li>
<li><p>Each local IPv6 address can be either "preferred" or "deprecated".<br />
If the application does not specify a source address, the system would prefer to use a "preferred" address instead of a "deprecated" address.</p></li>
</ul>

<p>As shown in the <code>ip addr</code> output above, currently both addresses are "preferred" on my server.<br />
This means, both addresses are equally possible of being used as the default source address.<br />
If I can make <code>2001:db8:f1c1:8454:0964::2</code> "preferred" and all other addresses "deprecated", I would achieve my goal of making <code>2001:db8:f1c1:8454:0964::2</code> the default source address for outbound traffic.</p>

<p>How can I set an IPv6 address as "deprecated"?<br />
After some digging, I found that it is controlled by the <code>preferred_lft</code> (preferred lifetime) attribute.<br />
This attribute indicates the remaining time an IP address is to remain "preferred".<br />
Unless it is set to "forever", <code>preferred_lft</code> counts down every second, and the IP address becomes "deprecated" when it reaches zero.<br />
If the IP address was added with <code>preferred_lft</code> set to zero, it would be "deprecated" since the beginning.</p>

<p>The command to change <code>preferred_lft</code> of an existing IPv6 address is:</p>

<pre><code>sudo ip addr change 2001:db8:f1c1:8454:0964::beef/80 dev venet0 preferred_lft 0
</code></pre>

<p>This change takes effect immediately, and outgoing packets start using <code>2001:db8:f1c1:8454:0964::2</code> as source address, as I wanted.<br />
However, after a reboot, both IPv6 addresses would become "preferred" again.</p>

<p>As we have seen, the <code>/etc/network/interfaces</code> file is adding IPv6 addresses in a <a rel="nofollow" href="https://manpages.debian.org/stretch/ifupdown/interfaces.5.en.html"><strong>post-up</strong> command</a> that runs after <code>ifupdown</code> package brings the interface up.<br />
Can we change this command and set <code>preferred_lft</code> to zero?</p>

<p>So I modified the <code>/etc/network/interfaces</code> file, changing that line to:</p>

<pre><code>up ip addr add 2001:db8:f1c1:8454:0964::beef/80 dev venet0 preferred_lft 0
</code></pre>

<p>However, modifying <code>/etc/network/interfaces</code> in an OpenVZ 7 container would not work.<br />
Although I can see the modification right away, after a reboot, the file is automatically restored to the default state, reverting any changes.</p>

<p>After poking around for a while, I figured out the solution: create a systemd service to change the <code>preferred_lft</code> attribute.<br />
The following commands will do the magic:</p>

<pre><code>sudo apt install -y jq
sudo mkdir -p /usr/local/bin

sudo tee /usr/local/bin/network-preferredlft.sh &gt; /dev/null &lt;&lt;'EOT'
#!/bin/bash
set -e
set -o pipefail

ip -j addr show dev $IFACE \
  | jq -r '
    .[] | select(.addr_info) | .addr_info[] |
    select(.family=="inet6" and .scope=="global") |
    select(.local | (endswith(":1") or endswith(":2")) | not) |
    "ip addr change "+.local+"/"+(.prefixlen|tostring)+" dev "+env.IFACE+" preferred_lft 0"' \
  | sh
EOT

sudo chmod +x /usr/local/bin/network-preferredlft.sh

sudo tee /etc/systemd/system/network-preferredlft.service &gt; /dev/null &lt;&lt;'EOT'
[Unit]
Description=Change preferred_lft
Documentation=https://yoursunny.com/t/2020/preferred-lft-vz7/
After=network-online.target
Wants=network-online.target

[Service]
Environment="IFACE=venet0"
Type=oneshot
ExecStart=/usr/local/bin/network-preferredlft.sh

[Install]
WantedBy=multi-user.target
EOT

sudo systemctl daemon-reload
sudo systemctl enable network-preferredlft
</code></pre>

<p>The script <code>/usr/local/bin/network-preferredlft.sh</code> retrieves a list of IP addresses assigned to the network interface specified by the environment variable <code>$IFACE</code>.<br />
For each global-scope IPv6 address that does not end with <code>:1</code> or <code>:2</code>, the <code>preferred_lft</code> attribute is changed to zero.</p>

<p>After executing the above command and rebooting, I can see that the IPv6 address <code>2001:db8:f1c1:8454:0964::beef</code> is correctly marked as "deprecated" and no longer selected as the default source address.<br />
Now I can securely host my secret beef recipes on <code>2001:db8:f1c1:8454:0964::beef</code> without worrying about others discovering this "deprecated" IPv6 address through my outbound network traffic.</p>

<pre><code>$ ip addr show dev venet0
2: venet0: &lt;BROADCAST,POINTOPOINT,NOARP,UP,LOWER_UP&gt; mtu 1500 qdisc noqueue state UNKNOWN group default
    link/void
    inet 127.0.0.1/32 scope host venet0
       valid_lft forever preferred_lft forever
    inet 192.0.2.30/32 brd 192.0.2.30 scope global venet0:0
       valid_lft forever preferred_lft forever
    inet6 2001:db8:f1c1:8454:0964::beef/80 scope global deprecated
       valid_lft forever preferred_lft 0sec
    inet6 2001:db8:f1c1:8454:0964::2/80 scope global
       valid_lft forever preferred_lft forever
    inet6 ::2/128 scope global
       valid_lft forever preferred_lft forever

$ ping 2001:db8:9f16:8fc7::9

$ sudo tcpdump -n icmp6
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ens3, link-type EN10MB (Ethernet), capture size 262144 bytes
11:03:40.185496 IP6 2001:db8:f1c1:8454:0964::2 &gt; 2001:db8:9f16:8fc7::9: ICMP6, echo request, seq 1, length 64
11:03:40.185598 IP6 2001:db8:9f16:8fc7::9 &gt; 2001:db8:f1c1:8454:0964::2: ICMP6, echo reply, seq 1, length 64
11:03:41.187229 IP6 2001:db8:f1c1:8454:0964::2 &gt; 2001:db8:9f16:8fc7::9: ICMP6, echo request, seq 2, length 64
11:03:41.187273 IP6 2001:db8:9f16:8fc7::9 &gt; 2001:db8:f1c1:8454:0964::2: ICMP6, echo reply, seq 2, length 64
</code></pre>

<p>This article explained how to change default IPv6 source address selection by marking an IPv6 address "deprecated" via a systemd service that invokes <code>ip addr</code> command after ifupdown brings up the network interface.<br />
The described technique works in OpenVZ 7 and Debian 10, and has been tested in a VPS provided by Gullo's Hosting.<br />
If you are using KVM and Ubuntu 20.04, check out <a rel="nofollow" href="https://yoursunny.com/t/2020/preferred-lft-netplan/">How to Select Default IPv6 Source Address for Outbound Traffic with Netplan</a>.</p>
]]>
        </description>
    </item>
    <item>
        <title>Need help with WebDAV on a DirectAdmin server</title>
        <link>https://staging.lowendspirit.com/index.php?p=/discussion/2073/need-help-with-webdav-on-a-directadmin-server</link>
        <pubDate>Mon, 16 Nov 2020 12:42:21 +0000</pubDate>
        <category>Help</category>
        <dc:creator>Amitz</dc:creator>
        <guid isPermaLink="false">2073@/index.php?p=/discussions</guid>
        <description><![CDATA[<p>Hey folks!</p>

<p>I would need your kind help. I have a DirectAdmin server here and would like to make WebDAV available securely to one user account. I have searched the DirectAdmin forums and the Interwebs, but most threads/instructions that I find are either horribly outdated or somehow unresolved and I, myself, have no experience with WebDAV besides using it from a client perspective.</p>

<p>Is there anybody here with a bit of experience to explain it to me or a link to a good and recent HowTo?<br />
I am running DirectAdmin on a Linux/Debian 9 system...</p>

<p>Thank you so much in advance &amp; kind regards<br />
Amitz</p>
]]>
        </description>
    </item>
    <item>
        <title>Anyone tested EasyEngine?</title>
        <link>https://staging.lowendspirit.com/index.php?p=/discussion/336/anyone-tested-easyengine</link>
        <pubDate>Mon, 16 Dec 2019 19:27:34 +0000</pubDate>
        <category>Technical</category>
        <dc:creator>flips</dc:creator>
        <guid isPermaLink="false">336@/index.php?p=/discussions</guid>
        <description><![CDATA[<p>Just stumbled upon <a href="https://easyengine.io/" rel="nofollow">https://easyengine.io/</a><br />
I was looking to see if there's some small scripts etc. available, like centminmod or even leaner, for Debian, for setting up nice defaults for web server and database and easily adding vhosts,  etc.</p>

<p>EasyEngine looks interesting, but I'm always a bit cautious when it comes to scripts to be downloaded and piped to a root shell.<br />
I might just look at the source and see what it does ... <img src="https://staging.lowendspirit.com/plugins/emojiextender/emoji/twitter/smile.png" title=":)" alt=":)" height="18" /></p>

<p>Maybe any of you are using EasyEngine?<br />
(Or tried and dropped it? If so, why?)  <img src="https://staging.lowendspirit.com/plugins/emojiextender/emoji/twitter/sunglasses.png" title="B)" alt="B)" height="18" /></p>
]]>
        </description>
    </item>
    <item>
        <title>Are distribution upgrades in OVZ7 generally supported?</title>
        <link>https://staging.lowendspirit.com/index.php?p=/discussion/909/are-distribution-upgrades-in-ovz7-generally-supported</link>
        <pubDate>Fri, 17 Apr 2020 09:29:35 +0000</pubDate>
        <category>Technical</category>
        <dc:creator>andreipoe</dc:creator>
        <guid isPermaLink="false">909@/index.php?p=/discussions</guid>
        <description><![CDATA[<p>Hello,</p>

<p>For anyone running Debian or Ubuntu in OpenVZ 7 containers, what has your experience been upgrading between OS versions, <em>à la</em> <code>dist-upgrade</code>/<code>do-release-upgrade</code>? Is it safe to assume it works these days, or would you rather reinstall a provided template?</p>

<p><a href="https://staging.lowendspirit.com/index.php?p=/profile/AnthonySmith" rel="nofollow">@AnthonySmith</a> At InceptionHosting in particular, is it safe to upgrade my servers without reinstalling?</p>

<p>Thanks.</p>
]]>
        </description>
    </item>
    <item>
        <title>Install LXDE with VNC in Debian server</title>
        <link>https://staging.lowendspirit.com/index.php?p=/discussion/874/install-lxde-with-vnc-in-debian-server</link>
        <pubDate>Wed, 08 Apr 2020 03:51:36 +0000</pubDate>
        <category>Technical</category>
        <dc:creator>quangthang</dc:creator>
        <guid isPermaLink="false">874@/index.php?p=/discussions</guid>
        <description><![CDATA[<p>As everyone knows, Linux / Unix server is used by more people as a server than Windows server because it is lighter and faster. Moreover, Linux / Unix server is mostly open source, large community, easy to customize. But for newbies, working with the command line is not an easy challenge. So in this article, I will guide you to install LXDE desktop environment and VNC.</p>

<p>Note 1: If you really need the GUI (interface), you can follow this article. I do not recommend installing GUI for large web servers. Once you've decided to use Linux / Unix based, you should learn to use about the command line.</p>

<p>Note 2: This tutorial is only for Debian OS and some Debian-based OS like Ubuntu. It works well inside an unprivileged LXC container VPS</p>

<h2># A little conceptual.</h2>

<p>If you are wondering what the desktop environment is, you can simply think of it as the interface, which is what you see on the screen instead of just the command line. It makes it possible to run applications that require graphical user interfaces, or GUIs in short.</p>

<p>Read more about the <a rel="nofollow" href="https://en.wikipedia.org/wiki/Desktop_environment" title="Wikipedia">Desktop environment</a> at Wikipedia</p>

<p>VNC is a GUI sharing method for anyone to control your computer anywhere. That is, when someone has been granted access to our VNC server, the data (event) from that person's keyboard and mouse will transfer to our computer. Through that update the user interface on both sides.</p>

<p>Find out more at <a rel="nofollow" href="https://en.wikipedia.org/wiki/Virtual_Network_Computing" title="Wikipedia">Wikipedia</a></p>

<h2># Install the LXDE desktop environment</h2>

<p>In this section, I will show you the two most common ways to install LXDE. Before starting, you should update the system with the following command:</p>

<pre><code>sudo apt update &amp;&amp; sudo apt upgrade
</code></pre>

<h3>1. Use Tasksel</h3>

<p>Tasksel is a pre-written tool to help users install Desktop Environment, web server more quickly. To install Tasksel, run the following  command:</p>

<pre><code>sudo apt install tasksel
</code></pre>

<p>Next we install LXDE as follows:</p>

<pre><code>sudo tasksel install lubuntu-core
</code></pre>

<h3>2. Use APT</h3>

<p>APT is a package management tool built into most Debian-based OS. When installing a package, run the following command:</p>

<pre><code>apt install &lt;package name&gt;
</code></pre>

<p>Same as above, with LXDE we install with the following command:</p>

<pre><code>apt install lxde
</code></pre>

<h2># Installing VNC Server</h2>

<p>There are many vnc servers, but in this section I will install tightvncserver:</p>

<pre><code>sudo apt install tightvncserver
</code></pre>

<p>Next, we will initialize vncserver for the first time:</p>

<pre><code>vncserver
</code></pre>

<p>To proceed with configuring vnc server with LXDE, we need to kill the session on:</p>

<pre><code>vncserver -kill: 1
</code></pre>

<p>Edit the VNC configuration to start the VNC Server will start the lXDE session, run the following command to edit the vnc configuration file:</p>

<pre><code>nano ~/.vnc/xstartup
</code></pre>

<p>Edit the file to the following content:</p>

<pre><code>#!/bin /bash
xrdb $HOME/.Xresources
exec startlxde &amp;
</code></pre>

<p>Save the file and then restart vncserver.</p>

<pre><code>vncserver
</code></pre>

<h2># Connecting with VNC Client</h2>

<p>You need to have a VNC Client to connect to VNC Server. You can download the RealVNC Viewer <a rel="nofollow" href="https://www.realvnc.com/en/connect/download/viewer/" title="here">here</a>. Open VNC CLient to connect with the host:</p>

<pre><code>&lt;server IP&gt; : &lt;Port number&gt;
</code></pre>

<p>The port number here is usually 5901. And here is the result:<br />
<img src="https://images.ctfassets.net/r6gjx5nkeyks/1bHNMFAmr3bgHFqHljreet/97ad168eadc212c0a97b2f68427750b8/result.PNG" alt="" title="" /></p>

<p>Good luck!<br />
<em>Thanks <a href="https://staging.lowendspirit.com/index.php?p=/profile/Not_Oles" rel="nofollow">@Not_Oles</a> for helping me</em></p>
]]>
        </description>
    </item>
    <item>
        <title>Debian 10 footprint</title>
        <link>https://staging.lowendspirit.com/index.php?p=/discussion/114/debian-10-footprint</link>
        <pubDate>Wed, 20 Nov 2019 22:14:37 +0000</pubDate>
        <category>Technical</category>
        <dc:creator>flips</dc:creator>
        <guid isPermaLink="false">114@/index.php?p=/discussions</guid>
        <description><![CDATA[<p>Debian used be quite small after a base install. This is a plain new VPS, think I installed debian10 from the template in Virtualizor.<br />
Then I did an <code>apt update &amp;&amp; apt -fu dist-upgrade</code> and installed tmux, sudo, vim and htop.<br />
And it uses 1.3 GB of space.<br />
1.1 GB for /usr (most in libs iirc)<br />
364 packages installed.<br />
I did run <code>apt clean</code>.</p>

<p>Wonder if there was a bit more than I expected in the default template, or if I didn't pay attention when upgrading/installing. (Some CLI utils triggers weird deps sometimes.)<br />
Or is Debian just becoming a large base install by default?<br />
(Almost tempted to go for Alpine, but been a Debian user for so long.)</p>
]]>
        </description>
    </item>
   </channel>
</rss>
