How To Set Static Ip Address On Ubuntu Server 22.04
How To Set Static Ip Address On Ubuntu Server 22.04
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
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
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
$ 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
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,
$ ip route show
···
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!
Gerald Brown
November 26, 2022 at 10:54 am
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
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
Reply
Leave a Comment
Name *
Email *
Post Comment
··· ···
Follow Us
© 2023 LinuxTechi