0% found this document useful (0 votes)
37 views

How To Set Static Ip Address On Ubuntu Server 22.04

Uploaded by

wahyudi lestari
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

How To Set Static Ip Address On Ubuntu Server 22.04

Uploaded by

wahyudi lestari
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Home How To Commands Linux Desktop Shell Scripting Monitoring Tools Linux Interview Subscribe

How to Set Static IP Address on Ubuntu Server 22.04 Search … 

Published on: October 12, 2022 by Pradeep Kumar

In this post, we will cover how to set static ip address on Ubuntu server 22.04.

It is highly recommended to have a static ip on linux server because it would be persistent across the reboot.
Static IP plays an important role for servers like Mail Server, Web Server and File server etc.

Now Playing

How to Configure Static IP…

Prerequisites
Minimal Installed Ubuntu Server 22.04
Regular User with sudo admin rights

In Ubuntu server 22.04, networking is controlled by netplan utility, so we will use netplan to configure static
ip address on Ubuntu server.

···

Recent Posts

How to Install Squid Proxy Server on


Ubuntu 22.04

How to Install GitLab Runner on Ubuntu


22.04

How to Install Kubernetes Cluster Using


Note: we cannot use nmcli utiltity as it is not the part of default installation on Ubuntu server. K3s on RHEL 9 | 8

How to Install Terraform on Debian 12


Setting up Static IP address on Ubuntu Server 22.04 How to Install VMware Workstation on
Login to your Ubuntu server 22.04, look for the netplan configuration file. It is located under /etc/netplan Linux Mint 21
directory. How to Install Latest Python on Linux

How to Install Docker on Linux Mint 21


$ cd /etc/netplan/ Step-by-Step
$ ls -l
total 4 How to Install MySQL on Ubuntu 22.04
-rw-r--r-- 1 root root 116 Oct 12 04:03 00-installer-config.yaml Step-by-Step
$
How to Install VirtualBox on Linux Mint
21 Step-by-Step
Run below cat command to view the contents of ‘00-installer-config.yaml’
How to Install VirtualBox Guest

Note: Name of configuration file may differ as your per setup. As it is an yaml file, so make sure to maintain Additions on Linux Mint 21

the indentation and syntax while editing.

$ cat 00-installer-config.yaml

Output,

As per above output, it says that we have ens33 interface and it is getting ip from dhcp server. Alternate way
to view interface name is via ip command.

Now, to configure static ip in place of dhcp, edit netplan configuration file using vi or nano editor and add the
following content.

$ sudo vi 00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
renderer: networkd
ethernets:
ens33:
addresses:
- 192.168.1.247/24
nameservers:
addresses: [4.2.2.2, 8.8.8.8]
routes:
- to: default
via: 192.168.1.1
version: 2

save and close the file.


In the above file we have used following,

ens33 is the interface name


addresses are used to set the static ip

nameservers used to specify the DNS server ips


routes used to specify the default gateway

Note: Change the IP details and interface name as per your environment.

To make above changes into the effect the apply these changes using following netplan command,

$ sudo netplan apply

Run following ip command to view the ip address on interface,

$ ip addr show ens33

To view the default route, run

$ ip route show

Output of above commands,

···
Perfect, above commands’ output confirms that static ip and route has been configured successfully.

···

That’s all from this post. Kindly do post your queries and feedback in below comments section.

Share Now!

11 thoughts on “How to Set Static IP Address on Ubuntu


Server 22.04”

Gerald Brown
November 26, 2022 at 10:54 am

How do I use Netplan to set up a static IP address on WIFI?

Reply

Aaron
November 27, 2022 at 5:31 pm

change the network device “ens33” to something else, it will be listed when you run “ip a”;
it;s probably wlan0 but that’s not guaranteed.

Reply

ronssm
December 4, 2022 at 2:34 am

there will be a config file for the wifi interface. look for something like 00-installer-config-
wifi.yaml
Reply

David Pinos
December 19, 2022 at 8:56 pm

Hey! thanks I had problems before setting up the DNS and none config would work!
This one did and you made this post really simple to follow!

Reply

Surf40
April 2, 2023 at 9:24 pm

Your text for configuring a static IP address does not work in my Ubuntu 20.04.5 server’s NIC. No
matter how I space or tab the indentations, I get “Ivalid YAML: inconsistent indentation: addresses:

I’ve been at the problem for a couple of weeks, with no fix in site; no spacing or tabbing change I
make fixes it. Can anyone please advise me? Thanks.

Reply

choc
May 31, 2023 at 1:59 pm

try paste the YAML into here ‘https://www.yamllint.com/’

Reply

Viet
August 9, 2023 at 3:16 pm

Copy paste not work here, you should try typing instead or if you paste, try to delete all the
space before each line and tab key until the same format

Reply

Mikael
December 10, 2023 at 5:39 am

The spacing must be done with the space key. If you try to make spaces in a yaml file with the
tab key it will not work.
Also you should let yamllint.com correct the file for you

Reply

sylva
June 27, 2023 at 9:59 am

Your article is quite nice and clear! but after followed, following error occurred when ping
google.com:
“temporary failure in name resolution”, meanwhile localhost can be visited. Is anyone facing this
issue as well? I’ll quite appreciate it if can get some advise.
Reply

ganesh
July 2, 2023 at 6:27 am

can we use default DHCP ip configuration along with another static ip in ubuntu 22.04 ?
i already have ens33 then i added eth0 as static ip , netplan apply did not thrown any errors but
unable to see my static ip , when i do ifconfig
even after reboot its not applying, any suggestions..

Reply

Wiilliam
August 5, 2023 at 9:36 am

i successfully set up my static ip but I cant ping to 192.168.1.1 why

Reply

Leave a Comment

Name *

Email *

Post Comment

··· ···

HTML Sitemap Privacy Policy Contact Us About Us Write For LinuxTechi

Follow Us

© 2023 LinuxTechi

You might also like