Fix DNS resolution: Add fallback DNS for external domains

Problem:
- When --accept-dns=true is used, MagicDNS (100.100.100.100) becomes
  the only DNS resolver for systemd-resolved
- If MagicDNS fails to forward external queries, domains like
  google.com become unreachable
- This commonly occurs due to network latency or connectivity issues

Solution:
- Add configure_dns_fallback() function to quick-install.sh
- Create /etc/systemd/resolved.conf.d/headscale-fallback.conf
- Set FallbackDNS to 1.1.1.1, 8.8.8.8, 168.126.63.1 (Korea DNS)
- Add external DNS verification test in verify_connection()
- Support non-systemd systems via /etc/resolv.conf modification

Result:
- MagicDNS continues to work for *.headscale.local internal domains
- External domains resolve via fallback DNS when MagicDNS fails
- Installation script verifies DNS resolution before completion

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
PharmQ Admin
2026-01-20 11:10:27 +00:00
parent 41d3e7d946
commit 1ae707a985
2 changed files with 63 additions and 14 deletions

View File

@@ -415,22 +415,23 @@ def create_app(config_name=None):
# FARMQ 데이터베이스에 약국 생성
farmq_session = get_farmq_session()
try:
# pharmacy_code 자동 생성 (P001~P999)
last_pharmacy = farmq_session.query(PharmacyInfo)\
# pharmacy_code 자동 생성 (P0001~P9999)
# P + 4자리 숫자 형식만 필터링
all_pharmacies = farmq_session.query(PharmacyInfo)\
.filter(PharmacyInfo.pharmacy_code.like('P%'))\
.order_by(PharmacyInfo.pharmacy_code.desc())\
.first()
.all()
if last_pharmacy and last_pharmacy.pharmacy_code:
try:
last_num = int(last_pharmacy.pharmacy_code[1:])
new_num = last_num + 1
except:
new_num = 1
else:
new_num = 1
max_num = 0
for pharmacy in all_pharmacies:
code = pharmacy.pharmacy_code
# P + 정확히 4자리 숫자 형식만 체크 (P0001, P0002, P0003...)
if code and len(code) == 5 and code[0] == 'P' and code[1:].isdigit():
num = int(code[1:])
if num > max_num:
max_num = num
pharmacy_code = f"P{new_num:03d}" # P001, P002, ...
new_num = max_num + 1
pharmacy_code = f"P{new_num:04d}" # P0001, P0002, ...
new_pharmacy = PharmacyInfo(
pharmacy_code=pharmacy_code,
@@ -445,9 +446,11 @@ def create_app(config_name=None):
owner_license=data.get('owner_license', '').strip(),
owner_phone=data.get('owner_phone', '').strip(),
owner_email=data.get('owner_email', '').strip(),
institution_code=data.get('institution_code', '').strip() or None,
# 요양기관부호: hira_code 우선, 없으면 institution_code 사용
institution_code=(data.get('hira_code', '').strip() or data.get('institution_code', '').strip()) or None,
institution_type=data.get('institution_type', '').strip() or None,
api_port=data.get('api_port', 8082),
tailscale_ip=data.get('vpn_ip', '').strip() or None, # VPN IP (선택)
# 기존 필드
proxmox_host=data.get('proxmox_host', '').strip(),