본문 바로가기

Computer Science/Embedded System

라즈베리 파이를 이용한 무선 AP 만들기

반응형

0. 다음과 같은 에러가 나는경우

$ sudo hostapd /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
nl80211: 'nl80211' generic netlink not found
Failed to initialize driver 'nl80211'
rmdir[ctrl_interface]: No such file or directory

http://jenssegers.be/blog/43/Realtek-RTL8188-based-access-point-on-Raspberry-Pi



1. 패키지 업데이트 및 설치

sudo apt-get update

sudo apt-get upgrade

sudo apt-get install rfkill hostapd hostap-utils iw dnsmasq

 

2. 네트워크 정보 수정

sudo vi /etc/network/interfaces

allow-hotplug wlan0
iface wlan0 inet static
address 192.168.1.1
netmask 255.255.255.0

 

3. 무선 랜카드 설정 적용

sudo ifdown wlan0

sudo ifup wlan0

 

4. 무선 랜카드(wlan0) 아이피 정보 확인

ifconfig


 

5. hostap 데몬 설정 (AP 기능 설정)

sudo vi /etc/hostapd/hostap.conf

interface=wlan0
ssid=piap
channel=1

 

6. hostap 데몬 재실행 (AP 기능 적용)

pi@raspberrypi ~ $ sudo service hostapd restart

 

7. DHCP 서버 설정

pi@raspberrypi ~ $ sudo vi /etc/dnsmasq.conf

* 내용추가

domain-needed

interface=wlan0

dhcp-range=192.168.1.2,192.168.1.254,255.255.0,12h

 

8. DHCP 서버 재실행

sudo service dnsmasq restart

 

9. 네트워크 라우팅 설정

pi@raspberrypi ~ $ sudo vi /etc/sysctl.conf +33

# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1

 

pi@raspberrypi ~ $ sudo iptables -t nat -A POSTROUTING -j MASQUERADE

 

10. 재실행될때마다 AP로 동작하도록 쉘파일 만들기

pi@raspberrypi ~ $ sudo vi /etc/init.d/piap


sudo iptables -t nat -A POSTROUTING -j MASQUERADE 입력

반응형