<?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[Set Static IP Address on Ubuntu Server]]></title><description><![CDATA[<p dir="auto">To set a static IP address, we are going to use <code>netplan</code>.</p>
<hr />
<p dir="auto">First make sure that it is installed using this command:</p>
<pre><code class="language-bash">sudo apt install openvswitch-switch-dpdk
</code></pre>
<hr />
<p dir="auto">Next we need to figure out what interface our server is using. To do that we need to run:</p>
<pre><code class="language-bash">ip route show
</code></pre>
<p dir="auto">After we run the command we are looking for the interface. When I ran it, I got this:</p>
<pre><code>default via 192.168.1.1 dev ens18 proto dhcp src 192.168.1.110 metric 100
192.168.1.0/24 dev ens18 proto kernel scope link src 192.168.1.110 metric 100
192.168.1.1 dev ens18 proto dhcp scope link src 192.168.1.110 metric 100
</code></pre>
<p dir="auto">We need to find the line with <code>192.168.1.0/24</code>. So my interface is going to be <code>ens18</code></p>
<hr />
<p dir="auto">Next we need to make the configuration file. I am going to use <code>nano</code> to do this.</p>
<pre><code class="language-bash">sudo nano /etc/netplan/99_config.yaml
</code></pre>
<p dir="auto">In the configuration file we need to add this:</p>
<pre><code class="language-yaml">network:
  version: 2
  renderer: networkd
  ethernets:
    ens18:
      dhcp4: no
      addresses:
        -  192.168.1.5/24
      routes:
        - to: default
          via: 192.168.1.1
      nameservers:
          addresses: [192.168.1.1, 8.8.8.8, 8.8.4.4]
</code></pre>
<p dir="auto">Be sure to change the line under <code>ethernets</code> to your interface like I have here. Under addresses, this is where we are going to put the IP address we want to use: <code>192.168.1.5/24</code>. If you are using nano, press <code>Ctrl+X</code> then <code>Enter</code> to save the file.</p>
<hr />
<p dir="auto">After we make the configuration file, we need to set the permissions for the file. To do that we use this command:</p>
<pre><code class="language-bash">sudo chmod 600 /etc/netplan/*
</code></pre>
<p dir="auto">This will set all the configuration files in that directory to have the correct permissions.</p>
<hr />
<p dir="auto">Now all we need to do is run this command:</p>
<pre><code class="language-bash">sudo netplan apply
</code></pre>
<p dir="auto">This will apply the configuration, now your IP address is set.</p>
<hr />
<p dir="auto">One last thing that I like to do, is to remove this <code>192.168.1.1 dev ens18 proto dhcp scope link src 192.168.1.110 metric 100</code> configuration. To do that we need to run:</p>
<pre><code class="language-bash">sudo ip route del 192.168.1.1
</code></pre>
<p dir="auto">This will delete that configuration. Now everything should be set.</p>
]]></description><link>https://forum.sumisu.xyz/topic/41/set-static-ip-address-on-ubuntu-server</link><generator>RSS for Node</generator><lastBuildDate>Sat, 30 May 2026 23:20:34 GMT</lastBuildDate><atom:link href="https://forum.sumisu.xyz/topic/41.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 30 Nov 2024 05:08:12 GMT</pubDate><ttl>60</ttl></channel></rss>