Profile

생각정리..

Lunight

[라즈베리파이] AP 만들기



라즈베리파이 AP 만들기

_________________________________________________________ AP 만들기


$sudo apt-get install hostapd isc-dhcp-server


$sudo apt-get install iptables-persistent


$sudo nano /etc/dhcp/dhcpd.conf


주석처리

#option domain-name "example.org";

#option domain-name-servers ns1.example.org, ns2.example.org;


주석해제

authoritative;


추가 

subnet 10.10.5.0 netmask 255.255.255.0 {

range 10.10.5.100 10.10.5.200;

option broadcast-address 10.10.5.255;

option routers 10.10.5.1;

default-lease-time 600;

max-lease-time 7200;

option domain-name "local";

option domain-name-servers 8.8.8.8, 168.126.63.1;

}



$sudo nano /etc/default/isc-dhcp-server


수정

INTERFACESv4="wlan0"

INTERFACESv6=""


$sudo nano /etc/network/interfaces


추가

auto lo

iface lo inet loopback


# primary network interfaces

auto eth0

iface eth0 inet static

        address 192.168.1.18

        netmask 255.255.255.0

        network 192.168.1.0

        broadcast 192.168.1.255

        gateway 192.168.1.1

        dns-nameservers 168.126.63.1


# primary AP network interfaces

allow-hotplug wlan0


iface wlan0 inet static

        address 10.10.5.1

        netmask 255.255.255.0

        network 10.10.5.0

        broadcast 10.10.5.255

        gateway 10.10.5.1

        dns-nameservers 168.126.63.1


$sudo nano /etc/hostapd/hostapd.conf


추가

interface=wlan0

driver=nl80211

ssid=RASPi_AP

country_code=US

hw_mode=g

channel=6

macaddr_acl=0

auth_algs=1

ignore_broadcast_ssid=0

wpa=2

wpa_passphrase=01098906876

wpa_key_mgmt=WPA-PSK

wpa_pairwise=CCMP

wpa_group_rekey=86400

ieee80211n=1

wme_enabled=1



$sudo nano /etc/default/hostapd


수정

DAEMON_CONF="/etc/hostapd/hostapd.conf"




$sudo nano /etc/init.d/hostapd


수정

DAEMON_CONF=/etc/hostapd/hostapd.conf



$sudo nano /etc/sysctl.conf


주석해제

net.ipv4.ip_forward=1



적용

$sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE 

$sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT 

$sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT


$sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"


$sudo iptables -t nat -S

$sudo iptables -S


sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE 

sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT 

sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

sudo iptables -t nat -S

sudo iptables -S



$sudo reboot now


$sudo service hostapd start


$sudo service isc-dhcp-server start



hostapd 상태확인


$sudo service hostapd status


또는


$sudo service isc-dhcp-server status



AP 온/오프설정


$sudo update-rc.d hostapd enable or disable

$sudo update-rc.d isc-dhcp-server enable or disable



서비스 확인하기 

#$udo service --status-all


예 ) 

 [ - ]  alsa-utils

 [ - ]  avahi-daemon

 [ + ]  bluetooth

 [ - ]  console-setup.sh

 [ + ]  cron

 [ + ]  dbus

 [ - ]  dhcpcd

 [ + ]  dphys-swapfile

 [ + ]  fake-hwclock

 [ + ]  hostapd

 [ - ]  hwclock.sh

 [ + ]  isc-dhcp-server

 [ - ]  keyboard-setup.sh

 [ + ]  kmod

 [ + ]  lightdm

 [ + ]  netfilter-persistent

 [ + ]  networking

 [ - ]  nfs-common

 [ - ]  paxctld

 [ - ]  plymouth

 [ - ]  plymouth-log

 [ + ]  procps

 [ + ]  raspi-config

 [ - ]  rpcbind

 [ - ]  rsync

 [ + ]  rsyslog

 [ - ]  selinux-autorelabel

 [ + ]  ssh

 [ - ]  sudo

 [ + ]  triggerhappy

 [ + ]  udev

 [ - ]  x11-common



_________________________________________________________ vpn 라우팅 추가


$mkdir /home/luna/piset


$cd /home/luna/ipset


$sudo nano routeadd.sh


추가

#192.168.1.53 sslvpn developer

sudo route add -net 172.23.0.0 netmask 255.255.255.0 gw 192.168.1.53



$sudo chmod 755 routeadd.sh


$./routeadd.sh