Install Config Wiki

All about installing, configuring and troubleshooting

User Tools

Site Tools


configure_static_ip_address_ubuntu_server_22_04

This is an old revision of the document!


Configure Static IP Address on Ubuntu Server 22.04

user@svr1:~$ ifconfig
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.106  netmask 255.255.255.0  broadcast 192.168.2.255
        inet6 fe80::d6ae:52ff:fecd:3bf8  prefixlen 64  scopeid 0x20<link>
        ether d4:ae:52:cd:3b:f8  txqueuelen 1000  (Ethernet)
        RX packets 156399  bytes 144274804 (144.2 MB)
        RX errors 0  dropped 85  overruns 0  frame 0
        TX packets 43997  bytes 7998011 (7.9 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 288  bytes 29450 (29.4 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 288  bytes 29450 (29.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

user@svr1:~$ ip
Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }
       ip [ -force ] -batch filename
where  OBJECT := { address | addrlabel | fou | help | ila | ioam | l2tp | link |
                   macsec | maddress | monitor | mptcp | mroute | mrule |
                   neighbor | neighbour | netconf | netns | nexthop | ntable |
                   ntbl | route | rule | sr | tap | tcpmetrics |
                   token | tunnel | tuntap | vrf | xfrm }
       OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |
                    -h[uman-readable] | -iec | -j[son] | -p[retty] |
                    -f[amily] { inet | inet6 | mpls | bridge | link } |
                    -4 | -6 | -M | -B | -0 |
                    -l[oops] { maximum-addr-flush-attempts } | -br[ief] |
                    -o[neline] | -t[imestamp] | -ts[hort] | -b[atch] [filename] |
                    -rc[vbuf] [size] | -n[etns] name | -N[umeric] | -a[ll] |
                    -c[olor]}
user@svr1:~$ cd /etc/netplan/
user@svr1:/etc/netplan$ ls -l
total 4
-rw-r--r-- 1 root root 115 Jun 18 18:43 00-installer-config.yaml
user@svr1:/etc/netplan$ vim 00-installer-config.yaml
user@svr1:/etc/netplan$ ifconfig -a
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.106  netmask 255.255.255.0  broadcast 192.168.2.255
        inet6 fe80::d6ae:52ff:fecd:3bf8  prefixlen 64  scopeid 0x20<link>
        ether d4:ae:52:cd:3b:f8  txqueuelen 1000  (Ethernet)
        RX packets 157795  bytes 144372089 (144.3 MB)
        RX errors 0  dropped 85  overruns 0  frame 0
        TX packets 44136  bytes 8018251 (8.0 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 288  bytes 29450 (29.4 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 288  bytes 29450 (29.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

user@svr1:/etc/netplan$ cp -v 00-installer-config.yaml 00-installer-config.bak
'00-installer-config.yaml' -> '00-installer-config.bak'
cp: cannot create regular file '00-installer-config.bak': Permission denied
user@svr1:/etc/netplan$ sudo cp -v 00-installer-config.yaml 00-installer-config.yaml-bak
[sudo] password for user:
'00-installer-config.yaml' -> '00-installer-config.yaml-bak'
user@svr1:/etc/netplan$ ls
00-installer-config.yaml  00-installer-config.yaml-bak
user@svr1:/etc/netplan$ sudo vim 00-installer-config.yaml
user@svr1:/etc/netplan$ vim 00-installer-config.yaml
user@svr1:/etc/netplan$ 
user@svr1:/etc/netplan$ ls
00-installer-config.yaml  00-installer-config.yaml-bak
user@svr1:/etc/netplan$ sudo netplan apply
[sudo] password for user:
Failed to reload network settings: No such file or directory
Falling back to a hard restart of systemd-networkd.service
user@svr1:/etc/netplan$ sudo netplan apply
user@svr1:/etc/netplan$ ping -c 5 www.google.com
PING www.google.com (142.250.217.228) 56(84) bytes of data.
64 bytes from mia07s62-in-f4.1e100.net (142.250.217.228): icmp_seq=1 ttl=117 time=11.8 ms
64 bytes from mia07s62-in-f4.1e100.net (142.250.217.228): icmp_seq=2 ttl=117 time=13.2 ms
64 bytes from mia07s62-in-f4.1e100.net (142.250.217.228): icmp_seq=3 ttl=117 time=11.4 ms
64 bytes from mia07s62-in-f4.1e100.net (142.250.217.228): icmp_seq=4 ttl=117 time=12.2 ms
64 bytes from mia07s62-in-f4.1e100.net (142.250.217.228): icmp_seq=5 ttl=117 time=12.9 ms

--- www.google.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4006ms
rtt min/avg/max/mdev = 11.387/12.302/13.216/0.674 ms
user@svr1:/etc/netplan$
configure_static_ip_address_ubuntu_server_22_04.1687261658.txt.gz · Last modified: 2023/06/20 11:47 by wikiadmin