<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[nirmal blog]]></title><description><![CDATA[nirmal blog]]></description><link>https://blog.nirmal-tamang.com.np</link><generator>RSS for Node</generator><lastBuildDate>Sat, 25 Apr 2026 00:40:22 GMT</lastBuildDate><atom:link href="https://blog.nirmal-tamang.com.np/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Step-by-Step Guide to Configuring a Static IP on Ubuntu Server]]></title><description><![CDATA[Overview
Goal: Assign a static IP to the Ubuntu server so it remains the same across reboots, allowing consistent SSH access from other devices. Problem: router DHC, Ubuntu server uses cloud-init, which can override the manual network settings after ...]]></description><link>https://blog.nirmal-tamang.com.np/step-by-step-guide-to-configuring-a-static-ip-on-ubuntu-server</link><guid isPermaLink="true">https://blog.nirmal-tamang.com.np/step-by-step-guide-to-configuring-a-static-ip-on-ubuntu-server</guid><category><![CDATA[Linux]]></category><category><![CDATA[networking]]></category><category><![CDATA[Ubuntu]]></category><category><![CDATA[netplan]]></category><category><![CDATA[cloud-init]]></category><category><![CDATA[ssh]]></category><dc:creator><![CDATA[Nirmal Tamang]]></dc:creator><pubDate>Mon, 01 Sep 2025 04:30:34 GMT</pubDate><content:encoded><![CDATA[<h2 id="heading-overview">Overview</h2>
<p>Goal: Assign a <strong>static IP</strong> to the Ubuntu server so it <strong>remains the same across reboots</strong>, allowing consistent SSH access from other devices. Problem: router DHC, Ubuntu server uses <strong>cloud-init</strong>, which can override the manual network settings after reboot.</p>
<ol>
<li>Check Network Interface</li>
</ol>
<pre><code class="lang-plaintext">ip a
</code></pre>
<ul>
<li><p>Find the Ethernet interface connected to your router</p>
</li>
<li><p>Example output</p>
</li>
</ul>
<pre><code class="lang-plaintext">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 noprefixroute valid_lft forever preferred_lft forever 
2: ens33: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:e0:4c:64:d4:90 brd ff:ff:ff:ff:ff:ff altname enp3s0 inet 192.168.1.*/24 metric 100 brd 192.168.1.255 scope global dynamic ens33 valid_lft 86151sec preferred_lft 86151sec inet6 2400:1a00:b030:29c2:2e0:4cff:fe64:d490/64 scope global dynamic mngtmpaddr noprefixroute valid_lft 949sec preferred_lft 949sec inet6 fe80::2e0:4cff:fe64:d490/64 scope link valid_lft forever preferred_lft forever
</code></pre>
<p>✅Interface name to use: ens33</p>
<ol start="2">
<li><p>Disable Cloud-init Network management</p>
<p> Cloud-init may reset network changes on reboot. Disable it permanently:</p>
</li>
</ol>
<pre><code class="lang-plaintext">sudo bash -c 'echo "network: {config: disabled}" &gt; /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg'
</code></pre>
<ol start="3">
<li><p>Configure Static IP with Netplan</p>
<ol>
<li><p>Open Netplan config file Netplan configuration file location is set to /etc/netplan/ directory. Depending on your Ubuntu installation Netplan configuration file can take one of the following three forms:</p>
<ul>
<li><p>01-netcfg.yaml</p>
</li>
<li><p>01-network-manager-all.yaml</p>
</li>
<li><p>50-cloud-init.yaml Now, open your configuration file:</p>
</li>
</ul>
</li>
</ol>
</li>
</ol>
<pre><code class="lang-plaintext">        sudo vim /etc/netplan/50-cloud-init.yaml
</code></pre>
<ol start="2">
<li>Replace the content with:</li>
</ol>
<pre><code class="lang-plaintext">    network:
        version: 2
        ethernets:
        ens33:
            dhcp4: false
            dhcp6: false
            addresses:
            - 192.168.1.*/24
            routes:
            - to: default
              via: 192.168.1.254
            nameservers:
                addresses: [8.8.8.8, 1.1.1.1]
</code></pre>
<ul>
<li><p>Replace:</p>
<ul>
<li><p>ens33: your interface name</p>
</li>
<li><p>192.168.1.* -&gt; desired static IP (outside router DHCP range)</p>
</li>
<li><p>192.168.1.254 -&gt; your router's gateway IP</p>
</li>
</ul>
</li>
</ul>
<ol start="4">
<li>Apply the configuration</li>
</ol>
<pre><code class="lang-plaintext">sudo netplan apply
</code></pre>
<ul>
<li><p>If using SSH, be aware that your connection may drop when IP changes.</p>
</li>
<li><p>Verify new IP:</p>
</li>
</ul>
<pre><code class="lang-plaintext">ip a
ping -c 4 8.8.8.8
</code></pre>
<ol start="5">
<li>Test SSH access from another device:</li>
</ol>
<pre><code class="lang-plaintext">ssh &lt;username&gt;@192.168.1.*
</code></pre>
<ul>
<li>Confirm you can connect with the new static IP</li>
</ul>
<ol start="6">
<li>Verify Persistence</li>
</ol>
<ul>
<li>Reboot server</li>
</ul>
<pre><code class="lang-plaintext">sudo reboot
</code></pre>
<ul>
<li>Check that the static IP is still active</li>
</ul>
<pre><code class="lang-plaintext">ip a
</code></pre>
<ol start="7">
<li>Tips / Notes</li>
</ol>
<ul>
<li><p>Always pick a static IP outside your router's DHCP range to avoid conflicts</p>
</li>
<li><p>Using cloud-init disable ensures <strong>manual network config is persistent.</strong></p>
</li>
<li><p>You can also add <strong>extra DNS servers</strong> if needed.</p>
</li>
</ul>
]]></content:encoded></item></channel></rss>