For configuring static IP Address in Ubuntu Server you need to make netplan configuration changes in /etc/netplan/ directory.
# cd /etc/netplan/
Now go and edit the configuration file there named "00-installer-config.yaml" and add below configuration for static IP address: (Bold are added lines)
# vi 00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
ens33:
dhcp4: no
addresses: [192.168.10.165/24]
gateway4: 192.168.10.2
nameservers:
addresses: [192.168.10.2]
version: 2
Apply added configurations:
# netplan apply
Verify your configuration using below command:
# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:28:f3:86 brd ff:ff:ff:ff:ff:ff
inet 192.168.10.165/24 brd 192.168.10.255 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe28:f386/64 scope link
valid_lft forever preferred_lft forever