■ Ubuntu 고정 IP(Static)설정 방법(CLI)
■ Ubuntu 고정 IP(Static)설정 방법(CLI)
▶ 우분투(Ubuntu)라는 이름은 창업자 마크 셔틀워스의 고향 남아프리카 공화국의 건국 이념인 우분투 정신에서 유래했다고 합니다.(위키참고) 현재 세계적으로 가장 많이 사용되고 있는 리눅스 배포판입니다.
▶ Ubuntu의 IP설정, 그중에서 CLI 환경에서 고정IP(Static IP) 설정하는 부분에 대한 설명이며 Ubuntu의 버전에 따라 상이합니다.
▶ 인터페이스(ethernet)의 이름은 사전에 아래 명령어로 확인이 가능 합니다.
1) ifconfig
root@raonyn:~# ifconfig ens33: flags=4163<up,broadcast,running,multicast> mtu 1500</up,broadcast,running,multicast> inet 192.168.48.129 netmask 255.255.255.0 broadcast 192.168.48.255 inet6 fe80::20c:29ff:fef8:f866 prefixlen 64 scopeid 0x20 ether 00:0c:29:f8:f8:66 txqueuelen 1000 (Ethernet) |
2) ip address
root@raonyn:~# ip address ........... 2: ens33: <broadcast,multicast,up,lower_up> mtu 1500 qdisc fq_codel state UP group default qlen 1000</broadcast,multicast,up,lower_up> link/ether 00:0c:29:f8:f8:66 brd ff:ff:ff:ff:ff:ff altname enp2s1 inet 192.168.48.129/24 brd 192.168.48.255 scope global ens33 valid_lft forever preferred_lft forever |
▶ Ubuntu 16.04
1) 인터페이스 설정 파일 위치
: /etc/network/interfaces
2) 파일수정 (dhcp라는 부분이 있다면 '#'을 이용하여 주석처리)
iface ens33 inet static address 192.168.48.129 netmask 255.255.255.0 # Net Mask C class gateway 192.168.48.1 dns-nameservers 168.126.63.1 |
3) 적용
# sudo systemctl restart networking.service
▶ Ubuntu 18.04 ~ 20.04
1) 인터페이스 설정 파일 위치
: /etc/netplan/00-installer-config.yaml (여러개의 파일이 있을 수 있으나 보통 00으로 시작되며 원하는 interface name(예: ens33)이 들어간 파일을 편집 사용
2) 파일수정 (dhcp라는 부분은 no로 합니다.)
root@raonyn:/etc/netplan# vi 00-installer-config.yaml # This is the network config written by 'subiquity' network: version: 2 renderer: networkd ethernets: ens33: dhcp4: no dhcp6: no addresses: - 192.168.48.129/24 # 사용하고자 하는 IP 주소를 CIDR 표기법으로 기재. C-Class는 끝에 '/24' 기입. gateway4: 192.168.48.1 nameservers: addresses: [168.126.63.1] # 원하는 Name server 주소를 쉼표로 구분하여 순서대로 기재. |
3) 적용
root@raonyn:/etc/netplan# netplan apply
▶ Ubuntu 22.04
1) 인터페이스 설정 파일 위치
: /etc/netplan/00-installer-config.yaml (여러개의 파일이 있을 수 있으나 보통 00으로 시작되며 원하는 interface name(예: ens33)이 들어간 파일을 편집 사용
2) 파일수정 (dhcp라는 부분은 no로 합니다.)
root@raonyn:/etc/netplan# cat 00-installer-config.yaml # This is the network config written by 'subiquity' network: ethernets: ens33: # dhcp4: true dhcp4: no addresses : - 192.168.48.129/24 # 사용하고자 하는 IP 주소를 CIDR 표기법으로 기재. C-Class는 끝에 '/24' 기입. routes: - to: default via : 192.168.48.1 version: 2 |
3) 적용
root@raonyn:/etc/netplan# netplan apply
4) ubuntu 18,20과 달라진 점은 gateway 설정 부분에 routes를 사용한다는 것입니다. 기존처럼 사용은 가능하나 경고 메시지가 발생합니다.
root@raonyn:/etc/netplan# netplan apply ** (generate:8022): WARNING **: 14:22:11.888: `gateway4` has been deprecated, use default routes instead. See the 'Default routes' section of the documentation for more details. ** (process:8020): WARNING **: 14:22:12.136: `gateway4` has been deprecated, use default routes instead. See the 'Default routes' section of the documentation for more details. |
'Operating System > Linux & Unix' 카테고리의 다른 글
[AIX] 패스워드 정책 (0) | 2022.10.06 |
---|---|
[LINUX] 서버의 서비스 중인 프로세스 확인(netstat, ss) (0) | 2022.10.06 |
tcpdump (0) | 2010.11.30 |
fuser 사용하여 프로세스 ID 및 실행 프로그램 보기 (0) | 2010.11.30 |
시스템에서 프로세스가 오픈하고 있는 모든 파일과 상세 정보 (0) | 2010.11.30 |
댓글