<?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>netplan — LowEndSpirit</title>
        <link>https://staging.lowendspirit.com/index.php?p=/</link>
        <pubDate>Thu, 09 Apr 2026 08:58:26 +0000</pubDate>
        <language>en</language>
            <description>netplan — LowEndSpirit</description>
    <atom:link href="https://staging.lowendspirit.com/index.php?p=/discussions/tagged/netplan/feed.rss" rel="self" type="application/rss+xml"/>
    <item>
        <title>Disabling VNC in Virtualizor ⇒ Lost Connectivity?</title>
        <link>https://staging.lowendspirit.com/index.php?p=/discussion/2779/disabling-vnc-in-virtualizor-lost-connectivity</link>
        <pubDate>Sun, 11 Apr 2021 17:46:50 +0000</pubDate>
        <category>Technical</category>
        <dc:creator>yoursunny</dc:creator>
        <guid isPermaLink="false">2779@/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/2021/Virtualizor-VNC-netplan/" rel="nofollow">https://yoursunny.com/t/2021/Virtualizor-VNC-netplan/</a></p>
</div></blockquote>

<p>The KVM server hosting my website went offline last month.<br />
Thinking the server might have crashed, I went to Virtualizor, the VPS control panel, to reboot the VPS.<br />
It did not solve the problem, so I proceeded with my <a rel="nofollow" href="https://yoursunny.com/t/2021/disaster-recovery-no-tears/">disaster recovery plan</a>.</p>

<p>The hosting provider, <a rel="nofollow" href="https://spartanhost.org/">Spartan Host</a>, explained that it was a router bug.<br />
They <a rel="nofollow" href="https://status.spartanhost.net/incident/234">fixed the router</a> after 4 hours, but my server did not come online.</p>

<h2>Symptom</h2>

<p>To investigate what went wrong with my VPS, I came back to Virtualizor to enable VNC access.<br />
Having VNC access is like attaching a monitor and a keyboard to the server.<br />
It would allow me to see any error messages printed on the screen and login to check whether there are configuration errors.</p>

<p>I didn't see any error through VNC connection.<br />
Thinking it might be a routing problem, I logged in with username and password, and ran a <code>traceroute</code>.<br />
To my surprise, the <code>traceroute</code> was able to reach Internet destination.<br />
Moreover, I can SSH into this server again.</p>

<p>Seeing the problem went away, I disabled VNC access in Virtualizor.<br />
Then, I pressed the reboot button in Virtualizor, so that the hypervisor would apply the VNC settings; rebooting via SSH would not be effective.</p>

<p>Then, I started a <code>ping</code> to the server from my desktop, and eagerly waited.<br />
One minute, two minutes, &hellip;, the server did not come online.<br />
What went wrong again?</p>

<p>I repeated the process, re-enabled VNC access, and saw nothing wrong.<br />
I disabled VNC again, and the VPS lost connectivity again.<br />
Clearly, there's a correlation between the VNC toggle and network connectivity.</p>

<h2>Diagnostics Ⅰ</h2>

<p>Virtualizor is known to <a rel="nofollow" href="https://talk.lowendspirit.com/discussion/2439/virtualizor-updates-gives-vps-providers-grey-hair-and-sleep-deprevation/p1">push feature updates in patch releases</a> that sometimes breaks things, so I asked whether there was a Virtualizor update recently, but <a rel="nofollow" href="https://www.lowendtalk.com/discussion/comment/3217921/#Comment_3217921">the answer was no</a>.<br />
I couldn't figure out the problem, so I opened a support ticket with Spartan Host, and sent over the Netplan configuration file in this Ubuntu 20.04 server.</p>

<pre><code>network:
  version: 2
  ethernets:
    ens3:
      dhcp4: true
      addresses:
        - 2001:db8:2604:9cc0::1/64
        - 2001:db8:2604:9cc0::80/64:
            lifetime: 0
      routes:
        - to: ::/0
          via: 2001:db8:2604::1
          on-link: true
</code></pre>

<p>In this configuration:</p>

<ul>
<li>IPv4 address is acquired from DHCP, which is provided by the hypervisor.</li>
<li>IPv6 is statically configured.</li>
<li>NIC name <code>ens3</code> is hard-coded, because it never changes.</li>
</ul>

<p>I've been using similar Netplan configuration files in several other KVM servers, and never had a problem.</p>

<p><a rel="nofollow" href="https://www.linkedin.com/in/ryan-mccully-195b71101/">Ryan McCully</a>, the managing director at Spartan Host, performed some tests on my KVM.<br />
He found that, if VNC is disabled, the network interface on the VPS seems to be "completely dead", as there's no ARP or any other traffic seen at the hypervisor side.<br />
He was also puzzled why VNC would affect network interface, but offered an explanation of why my VPS was working in the past few months:</p>

<ul>
<li>As mentioned above, setting changes in Virtualizor are applied to the hypervisor only after the reboot button in Virtualizor is pressed.</li>
<li>Most likely, when I finished the initial setup, I disabled VNC but didn't reboot in Virtualizor.</li>
<li>In this case, VNC tabs are hidden in Virtualizor, but VNC is still enabled on the hypervisor.</li>
</ul>

<h2>Diagnostics Ⅱ</h2>

<p>Ryan spent a few more hours of extensive testing, and was able to reproduce this issue.<br />
It turned out that <strong>disabling VNC in Virtualizor changes the network interface name</strong>.</p>

<p>The KVM hypervisor realizes VNC through an emulated VGA monitor.<br />
Enabling VNC attaches a VGA controller to the virtual server, while disabling VNC detaches it.<br />
To see this effect, we can schedule to run <code>lspci</code> command <a rel="nofollow" href="https://phoenixnap.com/kb/crontab-reboot">upon reboot in crontab</a>, and look at the output file when we regain access.</p>

<pre><code>$ : VNC enabled
$ lspci
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:01.1 IDE interface: Intel Corporation 82371SB PIIX3 IDE [Natoma/Triton II]
00:01.2 USB controller: Intel Corporation 82371SB PIIX3 USB [Natoma/Triton II] (rev 01)
00:01.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 03)
00:02.0 VGA compatible controller: Cirrus Logic GD 5446
00:03.0 Ethernet controller: Red Hat, Inc. Virtio network device
00:04.0 Multimedia audio controller: Intel Corporation 82801AA AC'97 Audio Controller (rev 01)
00:05.0 SCSI storage controller: Red Hat, Inc. Virtio block device
00:06.0 Unclassified device [00ff]: Red Hat, Inc. Virtio memory balloon

$ : VNC disabled
$ lspci
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:01.1 IDE interface: Intel Corporation 82371SB PIIX3 IDE [Natoma/Triton II]
00:01.2 USB controller: Intel Corporation 82371SB PIIX3 USB [Natoma/Triton II] (rev 01)
00:01.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 03)
00:02.0 Ethernet controller: Red Hat, Inc. Virtio network device
00:03.0 Multimedia audio controller: Intel Corporation 82801AA AC'97 Audio Controller (rev 01)
00:04.0 SCSI storage controller: Red Hat, Inc. Virtio block device
00:05.0 Unclassified device [00ff]: Red Hat, Inc. Virtio memory balloon
</code></pre>

<p>More importantly, addition or removal of the VGA controller changes the PCI address of the Ethernet controller.<br />
This, in turn, changes the network interface name, because Ubuntu adopts <a rel="nofollow" href="https://en.wikipedia.org/wiki/Consistent_Network_Device_Naming">Consistent Network Device Naming</a>, in which the name of a network interface is derived from its PCI address.</p>

<table>
<thead>
<tr>
  <th>VNC</th>
  <th>PCI address</th>
  <th>interface name</th>
</tr>
</thead>
<tbody>
<tr>
  <td>enabled</td>
  <td>03:00.0</td>
  <td>ens3</td>
</tr>
<tr>
  <td>disabled</td>
  <td>02:00.0</td>
  <td>ens2</td>
</tr>
</tbody>
</table>

<p>Therefore, "consistent" network device naming scheme is consistent only if the PCI address doesn't change.<br />
However, PCI addresses aren't always stable.<br />
I've seen PCI address changing on a dedicated server when I configure PCI bifurcation in BIOS settings.<br />
Now I've seen PCI address changing on a KVM virtual server.</p>

<h2>Treatment</h2>

<p>My Netplan configuration assumes the Ethernet adapter on the KVM server is always "ens3".<br />
Disabling VNC changes the network interface name to "ens2", and Netplan would not bring up an interface that it doesn't know about.<br />
This caused the VPS to lose connectivity.</p>

<p>To solve this problem, the Netplan configuration should identify the network interface by its MAC address.<br />
MAC address can be considered a stable identifier of the network interface, because it's one of the outputs from <a rel="nofollow" href="https://www.virtualizor.com/docs/admin-api/create-vps/">Virtualizor's Create VPS API</a>.</p>

<p>Therefore, I changed Netplan configuration to this:</p>

<pre><code>network:
  version: 2
  ethernets:
    uplink:
      match:
        macaddress: 6a:ed:d6:3b:49:f4
      set-name: uplink
      dhcp4: true
      addresses:
        - 2001:db8:2604:9cc0::1/64
        - 2001:db8:2604:9cc0::80/64:
            lifetime: 0
      routes:
        - to: ::/0
          via: 2001:db8:2604::1
          on-link: true
</code></pre>

<p>Unless the VPS is deleted and re-created with a different MAC address, this should continue to work.<br />
I also <a rel="nofollow" href="https://yoursunny.com/t/2021/WiFi-rename/">renamed the network interface</a> to "uplink", so that I don't need to check whether it's "ens3" or "ens2" when I type commands.</p>

<h2>Elsewhere</h2>

<p>I checked the VNC situation on several other KVM servers that I have.</p>

<p>WebHorizon and Evolution Host both modified Virtualizor such that there isn't an option to disable VNC.<br />
This prevents the issue, but increases the risk of my VPS being compromised via VNC.</p>

<p>WebHosting24 kept the VNC option intact in Virtualizor.<br />
Disabling VNC would lead to changed network interface names, but my new Netplan configuration works.</p>

<p>SolusVM, the VPS control panel used at VirMach and Nexril, keeps the VGA controller attached at all times.<br />
Disabling VNC blocks the VNC port so that nobody can connect to it, but does not affect the KVM server itself.<br />
I think this is a better approach.</p>

<h2>Acknowledgement</h2>

<p>Kudos to Ryan McCully at <a rel="nofollow" href="https://spartanhost.org/">Spartan Host</a> for helping me hunt down this issue.<br />
I wouldn't have anticipated the root cause without his help.</p>
]]>
        </description>
    </item>
    <item>
        <title>How to Select Default IPv6 Source Address for Outbound Traffic with Netplan</title>
        <link>https://staging.lowendspirit.com/index.php?p=/discussion/2219/how-to-select-default-ipv6-source-address-for-outbound-traffic-with-netplan</link>
        <pubDate>Mon, 07 Dec 2020 02:20:03 +0000</pubDate>
        <category>Technical</category>
        <dc:creator>yoursunny</dc:creator>
        <guid isPermaLink="false">2219@/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-netplan/" rel="nofollow">https://yoursunny.com/t/2020/preferred-lft-netplan/</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 KVM virtualization technology, in which I installed Ubuntu 20.04 operating system manually from an ISO image.<br />
Unlike a template-based installation, an ISO-installed Ubuntu 20.04 system manages its networks using <a rel="nofollow" href="https://netplan.io/">Netplan</a>, a backend-agnostic network configuration utility that generates network configuration from YAML files.<br />
Most VPS control panels, including SolusVM and Virtualizer, are unable to generate the YAML files needed by Netplan.<br />
IPv4 works out of box via DHCP, but IPv6 has to be configured manually.<br />
To assign two IPv6 addresses to my server, I need to write the following in <code>/etc/netplan/01-netcfg.yaml</code>:</p>

<pre><code>network:
  version: 2
  ethernets:
    ens3:
      dhcp4: true
      addresses:
        - 2001:db8:30fa:5877::1/64
        - 2001:db8:30fa:5877::beef/64
      routes:
        - to: ::/0
          via: 2001:db8:30fa::1
          on-link: true
      nameservers:
        addresses:
        - 2001:4860:4860::8888
        - 2606:4700:4700::1111
</code></pre>

<p>I intend to host my secret beef recipes on its unique IPv6 address <code>2001:db8:30fa:5877::beef</code>, and use the other address <code>2001:db8:30fa:5877::1</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:57eb:8479::2

$ sudo tcpdump -n icmp6
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on venet0, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
00:44:48.704099 IP6 2001:db8:30fa:5877::beef &gt; 2001:db8:57eb:8479::2: ICMP6, echo request, seq 1, length 64
00:44:48.704188 IP6 2001:db8:57eb:8479::2 &gt; 2001:db8:30fa:5877::beef: ICMP6, echo reply, seq 1, length 64
00:44:49.704011 IP6 2001:db8:30fa:5877::beef &gt; 2001:db8:57eb:8479::2: ICMP6, echo request, seq 2, length 64
00:44:49.704099 IP6 2001:db8:57eb:8479::2 &gt; 2001:db8:30fa:5877::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:30fa:5877::1 2001:db8:57eb:8479::2</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>Currently, both addresses are "preferred" on my server:</p>

<pre><code>$ ip addr show dev ens3
2: ens3: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 92:b6:ab:eb:04:00 brd ff:ff:ff:ff:ff:ff
    inet 192.0.2.30/24 brd 192.0.2.255 scope global dynamic ens3
       valid_lft 21599977sec preferred_lft 21599977sec
    inet6 2001:db8:30fa:5877::1/64 scope global
       valid_lft forever preferred_lft forever
    inet6 2001:db8:30fa:5877::beef/64 scope global
       valid_lft forever preferred_lft forever
</code></pre>

<p>This means, both addresses are equally possible of being used as the default source address.<br />
If I can make <code>2001:db8:30fa:5877::1</code> "preferred" and all other addresses "deprecated", I would achieve my goal of making <code>2001:db8:30fa:5877::1</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>Netplan gained support for <code>preferred_lft</code> setting <a rel="nofollow" href="https://bugs.launchpad.net/netplan/+bug/1803203">very recently</a> since version <code>0.100-0ubuntu4</code>.<br />
The syntax to specify <code>preferred_lft</code> of an IPv6 address is:</p>

<pre><code>addresses:
  - 2001:db8:30fa:5877::1/64
  - 2001:db8:30fa:5877::beef/64:
      lifetime: 0
</code></pre>

<p>Notice that there is a colon (<code>:</code>) after the IPv6 address <code>2001:db8:30fa:5877::beef/64</code>, because it is syntactically a map key instead of a string value.<br />
The equivalent structure in JSON looks like:</p>

<pre><code>{
  "addresses": [
    "2001:db8:30fa:5877::1/64",
    {
      "2001:db8:30fa:5877::beef/64": {
        "lifetime": 0
      }
    }
  ]
}
</code></pre>

<p>After applying this change, the IPv6 address <code>2001:db8:30fa:5877::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:30fa:5877::beef</code> without worrying about others discovering this "deprecated" IPv6 address through my outbound network traffic.</p>

<pre><code>$ sudo netplan apply

$ ip addr show dev ens3
2: ens3: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 92:b6:ab:eb:04:00 brd ff:ff:ff:ff:ff:ff
    inet 192.0.2.30/24 brd 192.0.2.255 scope global dynamic ens3
       valid_lft 21598263sec preferred_lft 21598263sec
    inet6 2001:db8:30fa:5877::1/64 scope global
       valid_lft forever preferred_lft forever
    inet6 2001:db8:30fa:5877::beef/64 scope global deprecated
       valid_lft forever preferred_lft 0sec

$ ping 2001:db8:57eb:8479::2

$ sudo tcpdump -n icmp6
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on venet0, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
00:44:48.704099 IP6 2001:db8:30fa:5877::1 &gt; 2001:db8:57eb:8479::2: ICMP6, echo request, seq 1, length 64
00:44:48.704188 IP6 2001:db8:57eb:8479::2 &gt; 2001:db8:30fa:5877::1: ICMP6, echo reply, seq 1, length 64
00:44:49.704011 IP6 2001:db8:30fa:5877::1 &gt; 2001:db8:57eb:8479::2: ICMP6, echo request, seq 2, length 64
00:44:49.704099 IP6 2001:db8:57eb:8479::2 &gt; 2001:db8:30fa:5877::1: 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 Netplan.<br />
The described technique works in KVM and Ubuntu 20.04, and has been tested in a VPS provided by Spartan Host.<br />
If you are using a OpenVZ 7 container, check out <a rel="nofollow" href="https://yoursunny.com/t/2020/preferred-lft-vz7/">How to Select Default IPv6 Source Address for Outbound Traffic in OpenVZ 7</a>.</p>
]]>
        </description>
    </item>
   </channel>
</rss>
