Set up static ip address for Ubuntu server

StoneHoo Lv4

Just installed Ubuntu server edition on my VMware, so I figured I need to access this VM using ssh, then I better set up the static ip address for this server. So I tried to ask ChatGPT, did not work out very well. Then googled this post and it helped me a lot:

Set Ubuntu Server Static Ip

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Using ip addr show to see the NIC, mine is eth33
ip addr show

# cd to /etc/netplan, you should see a file 00-installer-config.yaml
cd /etc/netplan
ls
edit the file:
sudo vim 00-installer-config.yaml
network:
renderer: networkd
ethernets:
ens33:
addresses:
- 192.168.1.127/24
nameservers:
addresses: [8.8.4.4,8.8.8.8]
routes:
- to: default
via: 192.168.1.254
version: 2

After editing the file, apply the changes, using this command

1
sudo netplan apply

In my case, there were some warnings popped out, but it did not matter.

Then verify the ip address:

1
2
ip addr show ens33
ip route show

Now You have successfully set up the static ip

  • Title: Set up static ip address for Ubuntu server
  • Author: StoneHoo
  • Created at : 2024-01-12 21:18:33
  • Updated at : 2024-04-08 19:17:02
  • Link: https://www.ozak.ca/2024/01/12/Set-up-static-ip-address-for-Ubuntu-server/
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments
On this page
Set up static ip address for Ubuntu server