2013년 11월 24일 일요일

Setting AP on Gentoo

1. Check AP support or not?
http://wireless.kernel.org/en/users/Drivers


2. Setting Kernel option
$ cd /usr/src/linux
$ make meunconfig


- Device Drivers >
Network Device Support >
Device Driver >
Network device support >
Ethernet (1000Mbit) >
Atheros xxx
Wireless LAN >
Atheros Wireless Cards >
Atheros 802.11n wireless cards support
Atheros ath9k PCI/PCIe bus support
Atheros ath9k AHB bus support
Atheros ath9k debugging
Atheros ath9k rate control
Linux Community AR9170 802.11n USB support
- Networking Support >
Networking Options >
802.1d Ethernet Bridging (Use Bridge case)
Wireless >
Generic IEEE 802.11 Networking Stack (mac80211)
3. Install
$ emerge hostapd
$ emerge dhcpcd
$ emerge dnsmasq
$ emerge iptables
$ //emerge bridge-utils (option : Bridge case)



4. WPA Supplicant connect 
<Ref : http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=4&chap=4>
$ emerge wpa_supplicant

4-1. Manage Mode
$ nano /etc/conf.d/net
modules="wpa_suplicant"
wpa_supplicant_eth0="-Dmadwifi"

$ wpa_passphrase ssid passwd >> /etc/wpa_supplicant/wpa_supplicant.conf
Ref : /usr/share/doc/wpa_supplicant-0.7.3-r2/wpa_supplicant.conf.bz2
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
ap_scan=1
---- wpa_passphrase result ----
# simple case: WPA-PSK, PSK as an ASCII passphrase, allow all valid ciphers
network={
ssid="simple"
psk="very secret passphrase"
priority=5
}
$ cd /etc/init.d
$ ln -s net.lo net.wlan0
$ ln -s net.lo net.br0
( Bridge case)

$ rc-update add net.wlan0 default
$ rc-update add net.br0 default
(Bridge case)
$ iptables -A INPUT -i br0 -p all -j ACCEPT
$ iptables -A FORWARD -i br0 -p all -j ACCEPT

$ /etc/init.d/net.wlan0 status
$ /etc/init.d/net.wlan0 start



4-2. Ad-Hoc Mode
< Ref : http://forums.gentoo.org/viewtopic-t-274790-highlight-adhoc+wireless.html >


4-2-1. Not using DHCP
$ nano /etc/conf.d/net
modules="iwconfig"
mode_wlan0="ad-hoc"
essid_wlan0="snet"
channel_wlan0="11"
config_wlan0="192.168.10.5 netmask 255.255.255.0 broadcast 164.125.10.255"
routes_wlan0="default via 192.168.10.1"
iwconfig wlan0 mode Ad-Hoc essid mynet channel 11
ifconfig wlan0 -promisc 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255


$ echo "1" > /proc/sys/net/ipv4/ip_forward

$ iptables -F
$ iptables -A FORWARD -i eth0 -o wlan0 -m state --state ESTABLISHED,RELATED -j ACCEPT
$ iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
$ iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE



4-3 Master Mode (Using Hostapd)
< Ref : http://en.gentoo-wiki.com/wiki/Wireless/Access_point >
< Ref : http://www.gentoo.org/doc/en/home-router-howto.xml >


4-3-1. Setting Network
$ vim /etc/conf.d/net
modules_wlan0="!iwconfig !wpa_supplicant"
config_eth0="164.125.68.92 netmask 255.255.255.0 broadcast 164.125.68.255"
routes_eth0="default via 164.125.68.1"
dns_servers_eth0="164.125.9.2"

modules_wlan0="!iwconfig !wpa_supplicant"
config_wlan0="192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255"

$ cd /etc/init.d
$ ln -s net.lo net.wlan0
$ rc-update add net.wlan0 default
$ /etc/init.d/net.wlan0 start



4-3-2. dnsmasq setting
$ nano /etc/dnsmasq.conf
dhcp-range=192.168.0.100,192.168.0.250,72h
interface=wlan0


$ rc-update add dnsmasq default
$ /etc/init.d/dnsmasq start



4-3-3. iptable Setting
$ iptables -F
$ iptables -t nat -F
$ iptables -A FORWARD -i wlan0 -s 192.168.0.0/255.255.0.0 -j ACCEPT
$ iptables -A FORWARD -i eth0 -d 192.168.0.0/255.255.0.0 -j ACCEPT
$ iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

$ echo 1 > /proc/sys/net/ipv4/ip_forward

$ /etc/init.d/iptables save
$ rc-update add iptables default



4-3-4. sysctl Setting 
$ nano /etc/sysctl.conf
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 1


4-3-5. hostapd Setting
$ nano /etc/hostapd/hostapd.conf
interface=wlan0
driver=nl80211
logger_syslog=-1
logger_syslog_level=2
logger_stdout=-1
logger_stdout_level=2
dump_file=/tmp/hostapd.dump
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
ssid=Tux
macaddr_acl=0
auth_algs=3
eap_server=0
eap_message=hello
eapol_key_index_workaround=0
own_ip_addr=127.0.0.1
wpa=3
ieee8021x=0
wpa_passphrase=secretpassword
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP TKIP
hw_mode=g
channel=8
# For 802.11n use this:
wme_enabled=1
ieee80211n=1
$ /etc/init.d/net.wlan0 restart

$ hostapd -dd /etc/hostapd/hostapd.conf
$ /etc/init.d/hostapd start
$ rc-update add hostapd default

댓글 없음:

댓글 쓰기