티스토리 뷰

728x90

1. 개요

 hostapd를 이용하여 리눅스 기반 보드를 AP mode, 즉 공유기로 활용해 보자.



2. 설치

 우선 hostapd를 설치합니다.




3. 설정(1)

 Configure을 정의합니다. 

vi /etc/hostapd/hostapd.conf


내용은  어떤한 통신 프로토콜을 사용할 것인지, 암호체계는 어떤 것으로 할 것인지에 따라 다릅니다.


hostapd 홈페이지에는 다음과 같이 정리되어 있습니다.

802.11b/g/n with WPA2-PSK and CCMP

A simple but secure AP with maximal compatibility for current hardware:

FILE /etc/hostapd/hostapd.conf
interface=wlan0       # the interface used by the AP
hw_mode=g             # g simply means 2.4GHz band
channel=10            # the channel to use
ieee80211d=1          # limit the frequencies used to those allowed in the country
country_code=FR       # the country code
ieee80211n=1          # 802.11n support
wmm_enabled=1         # QoS support

ssid=somename         # the name of the AP
auth_algs=1           # 1=wpa, 2=wep, 3=both
wpa=2                 # WPA2 only
wpa_key_mgmt=WPA-PSK  
rsn_pairwise=CCMP
wpa_passphrase=somepassword

802.11a/n/ac with WPA2-PSK and CCMP

A simple but secure AP for recent hardware:

FILE /etc/hostapd/hostapd.conf
interface=wlan0       # the interface used by the AP
hw_mode=a             # a simply means 5GHz
channel=0             # the channel to use, 0 means the AP will search for the channel with the least interferences 
ieee80211d=1          # limit the frequencies used to those allowed in the country
country_code=FR       # the country code
ieee80211n=1          # 802.11n support
ieee80211ac=1         # 802.11ac support
wmm_enabled=1         # QoS support

ssid=somename         # the name of the AP
auth_algs=1           # 1=wpa, 2=wep, 3=both
wpa=2                 # WPA2 only
wpa_key_mgmt=WPA-PSK 
rsn_pairwise=CCMP
wpa_passphrase=somepassword

802.11b/g/n triple AP

Three APs on the same card, one with WPA2, one with WPA1, one without encryption.

Hostapd automatically creates new interfaces for the extra APs:

FILE /etc/hostapd/hostapd.conf
interface=wlan0       # the interface used by the AP
hw_mode=g             # g simply means 2.4GHz
channel=10            # the channel to use
ieee80211d=1          # limit the frequencies used to those allowed in the country
country_code=FR       # the country code
ieee80211n=1          # 802.11n support
wmm_enabled=1         # QoS support

# First AP
ssid=test1            # the name of the AP
auth_algs=1           # 1=wpa, 2=wep, 3=both
wpa=2                 # WPA2 only
wpa_key_mgmt=WPA-PSK 
rsn_pairwise=CCMP
wpa_passphrase=somepassword

# Seconf AP
bss=wlan1             # the name of the new interface hostapd will create to handle this AP 
ssid=test2            # the name of the AP
auth_algs=1           # 1=wpa, 2=wep, 3=both
wpa=1                 # WPA1 only
wpa_key_mgmt=WPA-PSK 
wpa_passphrase=someotherpassword

# Third AP
bss=wlan2             # the name of the new interface hostapd will create to handle this AP 
ssid=test3
# since there is no encryption defined, none will be used


그리고 아래는 제가 추가한 내용입니다.



4. 설정(2)

 DHCP에 관한 설정을 합니다. 

vi /etc/dnsmasq.conf


 내용중에서 bind-interfaces를 찾습니다. 그리고 주석을 풀고 아래와 같이 작성합니다.



5. 설정(3)

  기존 이더넷과 새로 생성할 WIFI와 연결하는 작업을 합니다.


우선 shell script를 작성합니다.

     vi aproute.sh




작성한 파일을 실행 파일로 권환을 줍니다.

     chmod 777 aproute.sh



6. 실행

  1. 우선 인터넷 혼선을 막기 위해 연결 관리자를 중지합니다.

systemctl stop connman


  2. IP와 같은 이더넷 특징을 가져옵니다.

ifconfig eth0 up

dhclient eth0


  3. 모드 변경을 위해 notwork driver를 재설정 합니다.

modprobe -r dhd

modprobe dhd op_mode=2


  4. Gateway IP 주소를 가져옵니다.

ifconfig wlan0 192.168.1.1 up


  5. 구성된 IP 주소 범위 내에서 호스트 이름 서비스를 시작하기 위해 dnsmasq를 시작합니다.

dnsmasq -C /etc/dnsmasq.conf


  6. 스크립트 파일을 실행하여 네트워크 주소 변환을 시작합니다.

./aproute.sh


  7. host AP 데몬을 실행합니다.

hostapd /etc/hostapd/hostapd.conf -B



7. 종료

 Shell scribe를 만들어 실행시킵니다. killall 같은 경우 OS 따라 command(ex. pkill)가 달라질 수 있다.


댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/03   »
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
글 보관함