Mac dnsmasq를 이용하여 DNS 서버 구축하기

* 호스트(Mac PC)와 내부망을 연결하고 와이파이를 공유하여 게이트웨이 역할을 하도록 합니다

호스트(Mac PC)에 dnsmasq 를 설치하여 DNS 서버를 구축합니다

* 그러면 단말기는 호스트(Mac PC)에 와이파이로 붙어서 도메인을 사용하여 내부망과 통신할 수 있습니다



1. Homebrew 설치하기

다음 명령어를 입력합니다

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

* 사이트 : https://brew.sh/index_ko



2. dnsmasq 설치하기

다음 명령어를 입력합니다

brew install dnsmasq

 

 

3. dnsmasq 설정하기

설정 디렉토리를 만듭니다

mkdir -pv $(brew --prefix)/etc/

* 디렉토리 경로를 알고 싶으면 다음 명령어를 입력합니다

  echo $(brew --prefix)/etc/ 


*.dev

$(brew --prefix)/etc/dnsmasq.conf 를 vi 에디터로 열어서 'address=/.dev/127.0.0.1' 를 추가합니다

 

자동

sudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons/

sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist


nameserver를 resolver에 추가

sudo mkdir -v /etc/resolver

/etc/resolver/dev 를 vi 에디터로 열어서 'nameserver 127.0.0.1' 를 추가합니다

 

dnsmasq service 재시작

sudo launchctl stop homebrew.mxcl.dnsmasq

sudo launchctl start homebrew.mxcl.dnsmasq

 

 

4. Mac의 인터넷 공유를 시작합니다.

인터넷 공유 링크 : 



5. /etc/hosts 파일에 도메인과 ip주소를 입력하고 dnsmasq 서비스를 재시작합니다

1
2
3
4
5
6
7
8
9
10
11
12
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1    localhost
255.255.255.255    broadcasthost
::1             localhost
 
 
192.168.2.1 lottodr.com
cs
 
 

6. 다른 디바이스MAC에 Wi-Fi로 붙은 후 도메인을 이용하여 접속합니다


+ Recent posts