ETC
[Raspberry Pi/Ubuntu] 고정 IP 설정하기 (Ubuntu 22.04 LTS)
1984
2023. 5. 20. 12:16
wifi에 연결된 Raspberry Pi의 고정 IP를 설정한다.
1. /etc/netplan 디렉토리로 이동하여, 설정 파일을 확인한다.
파일 이름은 상이할 수 있다.
cd /etc/netplan
ls
2. 해당 파일을 vim 편집기로 연다.
vi 50-cloud-init.yaml
기존의 yaml 파일은 아래와 같다.
network:
version: 2
wifis:
renderer: networkd
wlan0:
access-points:
WIFI이름:
password: WIFI비밀번호
dhcp4: true
optional: true
3. [dhcp4]를 수정하고, [addresses]/[gateway4]/[nameservers] 항목을 추가한다.
변경 후 yaml 파일은 아래와 같다.
network:
version: 2
wifis:
renderer: networkd
wlan0:
access-points:
WIFI_NAME:
password: WIFI_PASSWORD
dhcp4: false # 내부 IP를 고정한다.
addresses: # 고정할 내부 IP 주소
- 192.168.0.100/24
routes: # 기본 게이트웨이 주소
- to: 0.0.0.0/0
via: 192.168.0.1
nameservers: # DNS 서버 주소
addresses:
- 8.8.8.8
- 8.8.4.4
optional: true
4. 아래 명령어를 사용하여, 변경사항을 적용한다.
netplan apply
5. 변경된 주소로 ssh 접속한다.
끝.
참고자료
https://www.lesstif.com/lpt/ubuntu-netplan-ip-static-ip-config-61899302.html
https://khstu-98.tistory.com/38
https://ansan-survivor.tistory.com/44
728x90