From 26637442385e4cf0d2ebb14f46a081b6ed7a1640 Mon Sep 17 00:00:00 2001 From: Yik Teng Hie Date: Wed, 15 Feb 2023 17:05:56 +0800 Subject: [PATCH] set static ip --- ubuntu.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/ubuntu.md b/ubuntu.md index 011a401..90b97a0 100644 --- a/ubuntu.md +++ b/ubuntu.md @@ -24,4 +24,49 @@ $ sudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv # resize filesystem $ sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv +``` + +## Set static IP + +- [Reference](https://learnubuntu.com/set-static-ip) + + +```bash +# check cloud-init if disable / present +$ apt-cache pkgnames | grep cloud-init + +# edit the file to disable clound-init +$ sudo nano /etc/cloud/cloud.cfg.d/99-disable-cloud-init.cfg +$ sudo reboot +``` + +```txt +network: {config: disabled} +``` + +- update the file + +```bash +$ /etc/netplan/00-installer-config.yaml +``` + +```txt +network: + ethernets: + enp1s0: + dhcp4: no + addresses: + - 10.0.0.129/24 + gateway4: 10.0.0.2 + nameservers: + addresses: [8.8.8.8, 10.0.0.2] + version: 2 +``` + +```bash +# apply the new ip config +$ sudo netplan apply + +# wait a few seconds, check the updated IP +$ hostname -I ``` \ No newline at end of file