configure_static_ip_address_ubuntu_server_22_04
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
configure_static_ip_address_ubuntu_server_22_04 [2023/06/20 11:43] – created wikiadmin | configure_static_ip_address_ubuntu_server_22_04 [2023/06/20 14:42] (current) – wikiadmin | ||
---|---|---|---|
Line 2: | Line 2: | ||
< | < | ||
- | frank@nc3:~$ ifconfig | + | user@svr1:~$ ifconfig |
eno1: flags=4163< | eno1: flags=4163< | ||
- | inet 192.168.2.106 | + | inet 192.168.1.95 |
inet6 fe80:: | inet6 fe80:: | ||
ether d4: | ether d4: | ||
Line 22: | Line 22: | ||
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 | TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 | ||
- | frank@nc3:~$ ip | + | user@svr1:~$ cd / |
- | Usage: ip [ OPTIONS ] OBJECT { COMMAND | help } | + | user@svr1:/ |
- | ip [ -force ] -batch filename | + | |
- | where OBJECT := { address | addrlabel | fou | help | ila | ioam | l2tp | link | | + | |
- | | + | |
- | | + | |
- | ntbl | route | rule | sr | tap | tcpmetrics | | + | |
- | token | tunnel | tuntap | vrf | xfrm } | + | |
- | | + | |
- | -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]} | + | |
- | frank@nc3:~$ cd / | + | |
- | frank@nc3:/ | + | |
total 4 | total 4 | ||
-rw-r--r-- 1 root root 115 Jun 18 18:43 00-installer-config.yaml | -rw-r--r-- 1 root root 115 Jun 18 18:43 00-installer-config.yaml | ||
- | frank@nc3:/ | + | user@svr1:/ |
- | frank@nc3:/ | + | user@svr1:/ |
eno1: flags=4163< | eno1: flags=4163< | ||
- | inet 192.168.2.106 | + | inet 192.168.1.95 |
inet6 fe80:: | inet6 fe80:: | ||
ether d4: | ether d4: | ||
Line 62: | Line 46: | ||
TX packets 288 bytes 29450 (29.4 KB) | TX packets 288 bytes 29450 (29.4 KB) | ||
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 | TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 | ||
+ | </ | ||
- | frank@nc3:/ | + | Let's switch to / |
+ | |||
+ | < | ||
+ | user@svr1:$ cd / | ||
+ | user@svr1:/ | ||
+ | user@svr1:/ | ||
+ | </ | ||
+ | |||
+ | Then, before we edit the network configuration file, let's make a backup of the ' | ||
+ | |||
+ | < | ||
+ | user@svr1:/ | ||
' | ' | ||
cp: cannot create regular file ' | cp: cannot create regular file ' | ||
- | frank@nc3:/ | + | user@svr1:/ |
- | [sudo] password for frank: | + | [sudo] password for user: |
' | ' | ||
- | frank@nc3:/ | + | user@svr1:/ |
00-installer-config.yaml | 00-installer-config.yaml | ||
- | frank@nc3:/ | + | user@svr1:/ |
- | frank@nc3:/ | + | </ |
- | frank@nc3:/ | + | |
+ | Here is the original dhcp configuration for eno1. | ||
+ | |||
+ | < | ||
+ | # This is the network config written by ' | ||
+ | network: | ||
+ | ethernets: | ||
+ | eno1: | ||
+ | dhcp4: true | ||
+ | version: 2 | ||
+ | </ | ||
+ | |||
+ | Using Vim editor, here is how to configure the static IP. | ||
+ | |||
+ | < | ||
+ | $ sudo vi 00-installer-config.yaml | ||
+ | </ | ||
+ | |||
+ | While within Vim, to the preceding lines of the original configuration, | ||
+ | |||
+ | < | ||
+ | network: | ||
+ | ethernets: | ||
+ | en01: | ||
+ | addresses: | ||
+ | - 192.168.1.95/ | ||
+ | routes: | ||
+ | - to: default | ||
+ | via: 192.168.1.1 | ||
+ | nameservers: | ||
+ | addresses: [8.8.8.8, | ||
+ | dhcp4: no | ||
+ | version: 2 | ||
+ | </ | ||
+ | |||
+ | Another author instead inserts the following content which varies only by two lines (renderer: networkd) and (nameservers): | ||
+ | |||
+ | < | ||
+ | $ sudo vi 00-installer-config.yaml | ||
+ | # This is the network config written by ' | ||
+ | network: | ||
+ | renderer: networkd | ||
+ | ethernets: | ||
+ | ens33: | ||
+ | addresses: | ||
+ | - 192.168.1.95/ | ||
+ | nameservers: | ||
+ | addresses: [4.2.2.2, 8.8.8.8] | ||
+ | routes: | ||
+ | - to: default | ||
+ | via: 192.168.1.1 | ||
+ | version: 2 | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | user@svr1:/ | ||
+ | user@svr1:/ | ||
+ | user@svr1:/ | ||
00-installer-config.yaml | 00-installer-config.yaml | ||
- | frank@nc3:/ | + | </ |
- | [sudo] password for frank: | + | |
+ | After Saving the new static configuration using Vim (:w :qs), then apply the changes to netplan as follows: | ||
+ | |||
+ | < | ||
+ | user@svr1:/ | ||
+ | [sudo] password for user: | ||
Failed to reload network settings: No such file or directory | Failed to reload network settings: No such file or directory | ||
Falling back to a hard restart of systemd-networkd.service | Falling back to a hard restart of systemd-networkd.service | ||
- | frank@nc3:/ | + | user@svr1:/ |
- | frank@nc3:/ | + | </ |
+ | |||
+ | Notice that there was an error (failed to load, then the system auto-performed a hard restart of systemd-neworkd.service). This may be the result of using the first example above rather than the second (containing the line ' | ||
+ | |||
+ | |||
+ | Now test the static configuration by running ping, or whatever else may be useful. | ||
+ | |||
+ | < | ||
+ | user@svr1:/ | ||
PING www.google.com (142.250.217.228) 56(84) bytes of data. | 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): | 64 bytes from mia07s62-in-f4.1e100.net (142.250.217.228): | ||
Line 91: | Line 157: | ||
5 packets transmitted, | 5 packets transmitted, | ||
rtt min/ | rtt min/ | ||
- | frank@nc3:/ | + | user@svr1:/ |
+ | </ | ||
+ | |||
+ | Run ifconfig: | ||
+ | |||
+ | < | ||
+ | $ ifconfig | ||
+ | eno1: flags=4163< | ||
+ | inet 192.168.1.95 | ||
+ | inet6 fe80:: | ||
+ | ether d4: | ||
+ | RX packets 183111 | ||
+ | RX errors 0 dropped 88 overruns 0 frame 0 | ||
+ | TX packets 47132 bytes 8346015 (8.3 MB) | ||
+ | TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 | ||
+ | device interrupt 16 | ||
+ | |||
+ | lo: flags=73< | ||
+ | inet 127.0.0.1 | ||
+ | inet6 ::1 prefixlen 128 scopeid 0x10< | ||
+ | loop txqueuelen 1000 (Local Loopback) | ||
+ | RX packets 374 bytes 38261 (38.2 KB) | ||
+ | RX errors 0 dropped 0 overruns 0 frame 0 | ||
+ | TX packets 374 bytes 38261 (38.2 KB) | ||
+ | TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 | ||
</ | </ |
configure_static_ip_address_ubuntu_server_22_04.1687261382.txt.gz · Last modified: 2023/06/20 11:43 by wikiadmin