##
## 이해를 돕기 위해 eth0 NIC 포트에 IP address를 설정하는 예시를 들었다.
##
$ sudo -s
$ cat /etc/rc.local
#!/bin/bash
ifconfig eth0 10.10.2.5/24
route add -net 10.10.2.0/24 gw 10.10.2.1
exit 0
$ chmod +x /etc/rc.local
##
## rc-local.service 설정 파일의 마지막 줄에 [Install] 섹션을 추가한다.
##
$ cat /lib/systemd/system/rc-local.service
... 중간 생략 ...
[Install] ## 이 내용을 추가
WantedBy=multi-user.target ## 이 내용을 추가
$
##
## 위에서 변경한 내용을 반영하기 위해 데몬을 reload하고, rc-local 서비스를 기동한다.
##
$ systemctl daemon-reload
$ systemctl enable --now rc-local
$ systemctl status rc-local
##
## 잘 설정되었는지 확인하기 위해 OS를 reboot하고, eth0 포트의 IP address 값을 확인한다.
##
$ reboot
... 중간 생략 ...
$ hostname -I
10.10.2.5
$
CentOS 7.9 에서 rc.local 초기화 스크립트 활성화하기
CentOS의 rc.local 파일은 /etc/rc.d/rc.local 파일의 Symbolic Link라는 점에서 Ubuntu와 약간 차이가 있다.
이 부분만 주의해서 아래 예제를 따라하면 잘 동작한다.
##
## 이해를 돕기 위해 eth0 NIC 포트에 IP address를 설정하는 예시를 들었다.
##
$ sudo -s
$ cat /etc/rc.local
#!/bin/bash
ifconfig eth0 10.10.2.5/24
route add -net 10.10.2.0/24 gw 10.10.2.1
exit 0
$ chmod 755 /etc/rc.d/rc.local
##
## rc-local.service 설정 파일의 마지막 줄에 [Install] 섹션을 추가한다.
##
$ cat /lib/systemd/system/rc-local.service
... 중간 생략 ...
[Install]
WantedBy=multi-user.target
$
##
## 위에서 변경한 내용을 반영하기 위해 데몬을 reload하고, rc-local 서비스를 기동한다.
##
$ systemctl daemon-reload
$ systemctl enable --now rc-local
$ systemctl status rc-local
##
## 잘 설정되었는지 확인하기 위해 OS를 reboot하고, eth0 포트의 IP address 값을 확인한다.
##
$ reboot
... 중간 생략 ...
$ hostname -I
10.10.2.5
$
테스트한 날짜: 2024년 2월 15일 테스트 환경: Ubuntu 22.04 / Ubuntu 20.04 / Ubuntu 18.04 (이 3개 버전 모두 잘 동작했다)
BIND 설치에 관해 참고하면 좋은 문서: https://www.hiroom2.com/2018/05/06/ubuntu-1804-bind-en/
BIND(DNS) 설정, 운영에 관해 참고하면 좋은 문서: <-- 진짜 잘 만들어진 문서, 꼭 읽어볼 것 !! https://joungkyun.gitbook.io/annyung-3-user-guide/chapter5 - BIND 기본 설정 - 새 도메인 설정 - Slave DNS 구성 - Inverse domain 설정 - DNSSEC 설정 - GeoDNS 설정 - Domain 위임 - IDN
Install BIND pkg
##
## root 계정으로 아래 명령을 수행
##
$ apt update
$ apt install -y bind9
Configuration
파일명: /etc/bind/named.conf.options
options {
directory "/var/cache/bind";
}
참고: 원래 기본 설정이 위와 같기 때문에 수정할 내용은 없다.
파일명: /etc/bind/named.conf.local
zone "andrew.space" IN {
type master;
file "andrew.space.zone";
};
파일명: /var/cache/bind/andrew.space.zone
$TTL 86400
@ IN SOA andrew.space root.andrew.space (
2021090500
3600
900
604800
86400
)
A 10.10.9.11
@ IN NS ns1
IN NS ns2
ns1 IN A 10.10.2.3
ns1 IN A 10.10.9.3
www IN A 10.10.2.3
andrew IN A 10.10.9.71
Validation (설정 값 유효성 확인)
$ named-checkzone andrew.space /var/cache/bind/andrew.space.zone
zone andrew.space/IN: loaded serial 2021090500
OK
$ nslookup
##
## 방금 위에서 구성한 DNS 서버의 주소
##
> server 10.10.9.11
Default server: 10.10.9.11
Address: 10.10.9.11#53
##
## name zone db에 추가했던 domain name이 잘 resolution 되는 확인
##
> www.andrew.space
Server: 10.10.9.11
Address: 10.10.9.11#53
Name: www.andrew.space
Address: 10.10.2.3
>