configure_static_ip_address_ubuntu_server_22_04
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| configure_static_ip_address_ubuntu_server_22_04 [2023/06/20 11:47] – wikiadmin | configure_static_ip_address_ubuntu_server_22_04 [2023/06/20 14:42] (current) – wikiadmin | ||
|---|---|---|---|
| Line 4: | Line 4: | ||
| user@svr1: | 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 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 | ||
| - | user@svr1: | ||
| - | Usage: ip [ OPTIONS ] OBJECT { COMMAND | help } | ||
| - | 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]} | ||
| user@svr1: | user@svr1: | ||
| user@svr1:/ | user@svr1:/ | ||
| Line 45: | Line 29: | ||
| user@svr1:/ | 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 | ||
| + | </ | ||
| + | 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:/ | user@svr1:/ | ||
| ' | ' | ||
| Line 72: | Line 68: | ||
| 00-installer-config.yaml | 00-installer-config.yaml | ||
| user@svr1:/ | user@svr1:/ | ||
| + | </ | ||
| + | |||
| + | 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:/ | user@svr1:/ | ||
| user@svr1:/ | user@svr1:/ | ||
| 00-installer-config.yaml | 00-installer-config.yaml | ||
| + | </ | ||
| + | |||
| + | After Saving the new static configuration using Vim (:w :qs), then apply the changes to netplan as follows: | ||
| + | |||
| + | < | ||
| user@svr1:/ | user@svr1:/ | ||
| [sudo] password for user: | [sudo] password for user: | ||
| Line 81: | Line 138: | ||
| Falling back to a hard restart of systemd-networkd.service | Falling back to a hard restart of systemd-networkd.service | ||
| user@svr1:/ | user@svr1:/ | ||
| + | </ | ||
| + | |||
| + | 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:/ | 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. | ||
| Line 93: | Line 158: | ||
| rtt min/ | rtt min/ | ||
| user@svr1:/ | 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.1687261658.txt.gz · Last modified: 2023/06/20 11:47 by wikiadmin
