Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- oracle group by
- katalon 비교
- tomcat log
- 한국투자증권 해외주식 양도세
- katalon 자동화
- js 자동완성
- 국세청 해외주식 양도세 신고방식
- 해외증권 양도세 한국투자증권
- 테스트 자동화
- javascript 자동완성
- 피보나치 예제
- recursion example
- 재귀함수 예제
- java.sql.SQLSyntaxErrorException
- 최대공약수 예제
- Katalon Recorder 사용법
- 재귀 예제
- katalon xpath
- 톰캣 실시간 로그
- CSTS 폭포수 모델
- git 연동
- 해외주식 양도세 신고
- katalon
- bfs 미로탐색 java
- 피보나치함수 예제
- 한국투자증권 양도세 신고
- 피보나치함수
- 홈택스 해외주식 양도세
- katalon 사용법
- 주식 양도세 신고방법
Archives
- Today
- Total
엄지월드
[홈서버] DNS 자동 매핑 처리 본문
홈서버의 경우 고정 아이피가 아닌 경우가 대부분이라 아이피가 매번 바뀔 수 있기 때문에 DNS와 IP를 매칭시켜주어야 한다.
duckdns.org에 들어가서 domain을 생성한 후 token을 생성하고 아래와 같이 sh 파일을 만들어 스케줄러 돌리면 된다.
파일 생성
vi duck.sh
파일 내용
#!/bin/bash
#
# Simple shell script to run DuckDNS update
# Requires curl to be installed
#
# Configuration variables
# Set your domain or comma separated list of domains and subdomains
# (for example: mytestdomain.duckdns.org,other.duckdns.org)
DOMAIN="domain.duckdns.org"
# Set your token as per your account for example from the duckdns.org home page
TOKEN="111111-296e-4c07-9cab-222222"
# Check this file is actually being executed directly
[[ "$BASH_SOURCE" == "$0" ]] || return
# Check for root if using system-wide configuration
if [[ $EUID != 0 ]]
then
echo 'ERROR: Requires root privileges (sudo).'
exit 1
fi
# Check if curl is installed
if ! command -v curl &> /dev/null
then
echo "ERROR: 'curl' command not found. Please install curl."
exit 1
fi
# Get IP addresses, filter to current, filter to IPv4 & IPv6
WAN_IPS="$(ip -o -f inet addr | awk '{print $4}' | cut -d/ -f1)"
if [[ -z "$WAN_IPS" ]]
then
echo 'ERROR: No public IP address was found for WAN interface.'
exit 2
fi
for CURRENT_IP in $WAN_IPS
do
# Check IPv4 and IPv6
if [[ "$CURRENT_IP" == *.* ]] # Is this IPv4?
then
echo -n "Updating with IPv4 address ($CURRENT_IP)... "
URL="https://www.duckdns.org/update?domains=$DOMAIN&token=$TOKEN&ip=$CURRENT_IP"
RES="$(curl -s -L "$URL")"
elif [[ "$CURRENT_IP" == *:* ]] # Is this IPv6?
then
echo -n "Updating with IPv6 address ($CURRENT_IP)... "
URL="https://www.duckdns.org/update?domains=$DOMAIN&token=$TOKEN&ipv6=$CURRENT_IP"
RES="$(curl -s -L "$URL")"
fi
if [[ "$RES" == "OK" ]]
then
echo 'OK'
elif [[ "$RES" == "KO" ]]
then
echo 'ERROR: Server returned KO'
else
echo "ERROR: Unknown server response ($RES)"
fi
done
# Re-check server status for this IP to confirm changes
echo -n 'Checking server status... '
CHECK_URL="https://www.duckdns.org/update?domains=$DOMAIN&token=$TOKEN&check=true"
CHECK_RES="$(curl -s -L "$CHECK_URL")"
if [[ "$CHECK_RES" == *"$CURRENT_IP"* ]]
then
echo 'OK'
else
echo "ERROR: Could not verify that IP ($CURRENT_IP) has been updated."
fi
echo 'Done.'
crontab 설정 진입
sudo crontab -e
맨 아래에 아래 명령어 추가
0 * * * * /home/kingle/duckdns/duck.sh > /var/log/duckdns_hourly_update.log 2>&1
0 * * * *: "매 시간 0분(정각)에 실행"
첫 번째 0: 매 시 정각 (분)
두 번째 *: 매 시간 (시)
세 번째 *: 매일 (일)
네 번째 *: 매월 (월)
다섯 번째 *: 매 요일 (요일)
'Server&DevOps' 카테고리의 다른 글
| 재부팅 시 카프카 자동 실행(systemd) (0) | 2025.09.17 |
|---|---|
| 카프카 실행 명령어 (0) | 2025.09.17 |
| 우분투(Ubuntu) 노트북 덮개를 닫아도 절전모드가 안되도록 하기 (0) | 2025.09.14 |
| ubuntu 절전 모드 처리 (0) | 2025.09.14 |
| 웹서버 및 WAS 튜닝 예시 (1) | 2025.05.30 |
Comments