Cybersecurity Demystify How to set a static IP address in Ubuntu 22. 04 2 Methods

How to set a static IP address in Ubuntu 22. 04 2 Methods

First, find out your dynamic Ip address assigned by the DHCP. To do this, open the terminal, type ip -a and press enter. This gives you the information as shown in the screenshot below.

Cybersecurity Demystify How to set a static IP address in Ubuntu 22. 04 2 Methods

Click the Networking icon by the top left. Click Setting > Network, and click the setting icon next to the Connected -100Mb/s under the Wired.

Cybersecurity Demystify How to set a static IP address in Ubuntu 22. 04 2 Methods

Click the ipv4 tab. Change the IPv4 Method from Automatic(DHCP) to Manual

Cybersecurity Demystify How to set a static IP address in Ubuntu 22. 04 2 Methods

Enter your IP address, Netmask, Gateway, and DNS Server as shown in the screenshot below. You can use the Ip address noted earlier or use a new Ip address. Click the Apply button to save the changes. Toggle the button next to the Connected -100Mb/s under the Wired to turn it off and turn it back on.

Cybersecurity Demystify How to set a static IP address in Ubuntu 22. 04 2 Methods

To confirm the setting has been applied successfully, open your terminal. Type IP address show or ip -a. The scope global has changed from dynamic to noprefixroute.

Cybersecurity Demystify How to set a static IP address in Ubuntu 22. 04 2 Methods

Setting static IP address in Ubuntu 22.04 using the command line.

Open your terminal, type ip -a and press enter. Take note of your ens33 of your machine

Cybersecurity Demystify How to set a static IP address in Ubuntu 22. 04 2 Methods

In this version of Ubuntu, network-manager uses the YAML backend that is based on libnetplan. We need to edit /etc/netplan/01-network-manager-all.yaml to do this. Open your terminal, type sudo nano /etc/netplan/01-network-manager-all.yaml, and press enter. Enter your sudo password.

Cybersecurity Demystify How to set a static IP address in Ubuntu 22. 04 2 Methods
network:
  version: 2
  renderer: networked
  ethernet:
    ens33:
      addresses:
         – 192.xxx.xx.xx/xx
      dhcp4: no
      dhcp6: no
      nameservers:
        addresses:
          – 8.8.8.8
          – 8.8.4.4
       routes:
         – to: default

Click here to check if your command is a valid YAML. Copy and paste your command in and click the Go button as shown in the screenshot below.

Cybersecurity Demystify How to set a static IP address in Ubuntu 22. 04 2 Methods

Paste your command in as shown below. Press ctrl x to exit and save

Cybersecurity Demystify How to set a static IP address in Ubuntu 22. 04 2 Methods

Another way you can check to make sure you have a valid YAML is by typing netplan generate and pressing enter after saving the command.

Now type sudo netplan apply to apply the rule.

Type ip -a or ip address show and press enter to confirm the changes.

Cybersecurity Demystify How to set a static IP address in Ubuntu 22. 04 2 Methods

About The Author

Help someone out! Share this post with those who might need it.
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
CHAT