mirror of
https://github.com/lakinduakash/linux-wifi-hotspot.git
synced 2024-11-21 11:30:09 +00:00
Initial commit
This commit is contained in:
commit
71782efdfb
23
LICENSE
Normal file
23
LICENSE
Normal file
@ -0,0 +1,23 @@
|
||||
Copyright (c) 2013, oblique
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
21
Makefile
Normal file
21
Makefile
Normal file
@ -0,0 +1,21 @@
|
||||
PREFIX=/usr
|
||||
MANDIR=$(PREFIX)/share/man
|
||||
BINDIR=$(PREFIX)/bin
|
||||
|
||||
all:
|
||||
@echo "Run 'make install' for installation."
|
||||
@echo "Run 'make uninstall' for uninstallation."
|
||||
|
||||
install:
|
||||
install -Dm755 create_ap $(DESTDIR)$(BINDIR)/create_ap
|
||||
install -Dm644 create_ap.conf $(DESTDIR)/etc/create_ap.conf
|
||||
[ ! -d /lib/systemd/system ] || install -Dm644 create_ap.service $(DESTDIR)$(PREFIX)/lib/systemd/system/create_ap.service
|
||||
install -Dm644 bash_completion $(DESTDIR)$(PREFIX)/share/bash-completion/completions/create_ap
|
||||
install -Dm644 README.md $(DESTDIR)$(PREFIX)/share/doc/create_ap/README.md
|
||||
|
||||
uninstall:
|
||||
rm -f $(DESTDIR)$(BINDIR)/create_ap
|
||||
rm -f $(DESTDIR)/etc/create_ap.conf
|
||||
[ ! -f /lib/systemd/system/create_ap.service ] || rm -f $(DESTDIR)$(PREFIX)/lib/systemd/system/create_ap.service
|
||||
rm -f $(DESTDIR)$(PREFIX)/share/bash-completion/completions/create_ap
|
||||
rm -f $(DESTDIR)$(PREFIX)/share/doc/create_ap/README.md
|
87
README.md
Normal file
87
README.md
Normal file
@ -0,0 +1,87 @@
|
||||
## Features
|
||||
* Create an AP (Access Point) at any channel.
|
||||
* Choose one of the following encryptions: WPA, WPA2, WPA/WPA2, Open (no encryption).
|
||||
* Hide your SSID.
|
||||
* Disable communication between clients (client isolation).
|
||||
* IEEE 802.11n & 802.11ac support
|
||||
* Internet sharing methods: NATed or Bridged or None (no Internet sharing).
|
||||
* Choose the AP Gateway IP (only for 'NATed' and 'None' Internet sharing methods).
|
||||
* You can create an AP with the same interface you are getting your Internet connection.
|
||||
* You can pass your SSID and password through pipe or through arguments (see examples).
|
||||
|
||||
|
||||
## Dependencies
|
||||
### General
|
||||
* bash (to run this script)
|
||||
* util-linux (for getopt)
|
||||
* procps or procps-ng
|
||||
* hostapd
|
||||
* iproute2
|
||||
* iw
|
||||
* iwconfig (you only need this if 'iw' can not recognize your adapter)
|
||||
* haveged (optional)
|
||||
|
||||
### For 'NATed' or 'None' Internet sharing method
|
||||
* dnsmasq
|
||||
* iptables
|
||||
|
||||
|
||||
## Installation
|
||||
### Generic
|
||||
git clone https://github.com/oblique/create_ap
|
||||
cd create_ap
|
||||
make install
|
||||
|
||||
### ArchLinux
|
||||
pacman -S create_ap
|
||||
|
||||
### Gentoo
|
||||
emerge layman
|
||||
layman -f -a jorgicio
|
||||
emerge net-wireless/create_ap
|
||||
|
||||
## Examples
|
||||
### No passphrase (open network):
|
||||
create_ap wlan0 eth0 MyAccessPoint
|
||||
|
||||
### WPA + WPA2 passphrase:
|
||||
create_ap wlan0 eth0 MyAccessPoint MyPassPhrase
|
||||
|
||||
### AP without Internet sharing:
|
||||
create_ap -n wlan0 MyAccessPoint MyPassPhrase
|
||||
|
||||
### Bridged Internet sharing:
|
||||
create_ap -m bridge wlan0 eth0 MyAccessPoint MyPassPhrase
|
||||
|
||||
### Bridged Internet sharing (pre-configured bridge interface):
|
||||
create_ap -m bridge wlan0 br0 MyAccessPoint MyPassPhrase
|
||||
|
||||
### Internet sharing from the same WiFi interface:
|
||||
create_ap wlan0 wlan0 MyAccessPoint MyPassPhrase
|
||||
|
||||
### Choose a different WiFi adapter driver
|
||||
create_ap --driver rtl871xdrv wlan0 eth0 MyAccessPoint MyPassPhrase
|
||||
|
||||
### No passphrase (open network) using pipe:
|
||||
echo -e "MyAccessPoint" | create_ap wlan0 eth0
|
||||
|
||||
### WPA + WPA2 passphrase using pipe:
|
||||
echo -e "MyAccessPoint\nMyPassPhrase" | create_ap wlan0 eth0
|
||||
|
||||
### Enable IEEE 802.11n
|
||||
create_ap --ieee80211n --ht_capab '[HT40+]' wlan0 eth0 MyAccessPoint MyPassPhrase
|
||||
|
||||
### Client Isolation:
|
||||
create_ap --isolate-clients wlan0 eth0 MyAccessPoint MyPassPhrase
|
||||
|
||||
## Systemd service
|
||||
Using the persistent [systemd](https://wiki.archlinux.org/index.php/systemd#Basic_systemctl_usage) service
|
||||
### Start service immediately:
|
||||
systemctl start create_ap
|
||||
|
||||
### Start on boot:
|
||||
systemctl enable create_ap
|
||||
|
||||
|
||||
## License
|
||||
FreeBSD
|
168
bash_completion
Normal file
168
bash_completion
Normal file
@ -0,0 +1,168 @@
|
||||
#
|
||||
# Bash Completion routine for create_ap
|
||||
#
|
||||
|
||||
_use_filedir() {
|
||||
if [[ $(type -t _filedir) == "function" ]]; then
|
||||
_filedir
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
_create_ap() {
|
||||
local awk_cmd='
|
||||
($1 ~ /^-/) {
|
||||
for (i = 1; i <= NF; i++) {
|
||||
if ($i ~ /,$/) {
|
||||
print substr ($i, 0, length ($i)-1)
|
||||
}
|
||||
else {
|
||||
print $i
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
'
|
||||
|
||||
local cur prev opts
|
||||
COMPREPLY=()
|
||||
cur="$2"
|
||||
prev="$3"
|
||||
opts=$("$1" --help | awk "$awk_cmd")
|
||||
|
||||
case "$prev" in
|
||||
-h|--help)
|
||||
# No Options
|
||||
;;
|
||||
--version)
|
||||
# No Options
|
||||
;;
|
||||
-c)
|
||||
# Refer http://en.wikipedia.org/wiki/List_of_WLAN_channels
|
||||
opts=$(
|
||||
iw list | grep ' MHz \[[[:digit:]]\+\] ' |
|
||||
grep -v 'no IR\|disabled' |
|
||||
sed 's/.*\[\(.*\)\].*/\1/' | sort -n | uniq
|
||||
)
|
||||
;;
|
||||
-w)
|
||||
opts="1 2 1+2"
|
||||
;;
|
||||
-n)
|
||||
# No Options
|
||||
;;
|
||||
-m)
|
||||
opts="nat bridge none"
|
||||
;;
|
||||
--psk)
|
||||
# No Options
|
||||
;;
|
||||
--hidden)
|
||||
# No Options
|
||||
;;
|
||||
--mac-filter)
|
||||
# No Options
|
||||
;;
|
||||
--mac-filter-accept)
|
||||
# No Options
|
||||
;;
|
||||
--ieee80211n)
|
||||
# No Options
|
||||
;;
|
||||
--ht_capab)
|
||||
# Refer http://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf
|
||||
opts='
|
||||
[LDPC] [HT40-] [HT40+] [SMPS-STATIC] [SMPS-DYNAMIC]
|
||||
[GF] [SHORT-GI-20] [SHORT-GI-40] [TX-STBC]
|
||||
[RX-STBC1] [RX-STBC12] [RX-STBC123] [DELAYED-BA]
|
||||
[MAX-AMSDU-7935] [DSSS_CCK-40] [40-INTOLERANT]
|
||||
[LSIG-TXOP-PROT]
|
||||
'
|
||||
;;
|
||||
--country)
|
||||
local reg_file=/usr/lib/crda/regulatory.bin
|
||||
if command -v regdbdump > /dev/null && [[ -f "$reg_file" ]]; then
|
||||
local country_awk_cmd='
|
||||
($1 ~ /^country/) {
|
||||
print substr ($2, 0, length ($2)-1)
|
||||
}
|
||||
'
|
||||
opts=$(regdbdump "$reg_file" 2>/dev/null | awk "$country_awk_cmd")
|
||||
else
|
||||
opts='
|
||||
AD AE AF AI AL AM AN AR AS AT AU AW AZ BA BB BD BE
|
||||
BF BG BH BL BM BN BO BR BS BT BY BZ CA CF CH CI CL
|
||||
CN CO CR CX CY CZ DE DK DM DO DZ EC EE EG ES ET FI
|
||||
FM FR GB GD GE GF GH GL GP GR GT GU GY HK HN HR HT
|
||||
HU ID IE IL IN IR IS IT JM JO JP KE KH KN KP KR KW
|
||||
KY KZ LB LC LI LK LS LT LU LV MA MC MD ME MF MH MK
|
||||
MN MO MP MQ MR MT MU MW MX MY NG NI NL NO NP NZ OM
|
||||
PA PE PF PG PH PK PL PM PR PT PW PY QA RE RO RS RU
|
||||
RW SA SE SG SI SK SN SR SV SY TC TD TG TH TN TR TT
|
||||
TW TZ UA UG US UY UZ VC VE VI VN VU WF WS YE YT ZA
|
||||
ZW 00
|
||||
'
|
||||
fi
|
||||
;;
|
||||
--freq-band)
|
||||
opts="2.4 5"
|
||||
;;
|
||||
--driver)
|
||||
# Refer http://w1.fi/cgit/hostap/tree/src/drivers
|
||||
# Not going to implement
|
||||
;;
|
||||
--no-virt)
|
||||
# No Options
|
||||
;;
|
||||
--no-haveged)
|
||||
# No Options
|
||||
;;
|
||||
--fix-unmanaged)
|
||||
# No Options
|
||||
;;
|
||||
--mac)
|
||||
# Not going to implement
|
||||
;;
|
||||
--daemon)
|
||||
# No Options
|
||||
;;
|
||||
--stop)
|
||||
local stop_awk_cmd='$1 ~ /^[0-9]+$/'
|
||||
opts=$("$1" --list-running | awk "$stop_awk_cmd")
|
||||
;;
|
||||
--list-running)
|
||||
# No Options
|
||||
;;
|
||||
--list-clients)
|
||||
local clients_awk_cmd='$1 ~ /^[0-9]+$/'
|
||||
opts=$("$1" --list-running | awk "$clients_awk_cmd")
|
||||
;;
|
||||
--no-dns)
|
||||
# No Options
|
||||
;;
|
||||
--dhcp-dns)
|
||||
# Not going to implement
|
||||
;;
|
||||
--mkconfig)
|
||||
_use_filedir && return 0
|
||||
;;
|
||||
--config)
|
||||
_use_filedir && return 0
|
||||
;;
|
||||
-g)
|
||||
# Not going to implement
|
||||
;;
|
||||
-d)
|
||||
# No Options
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
COMPREPLY=( $(compgen -W "$opts" -- $cur) )
|
||||
return 0
|
||||
}
|
||||
complete -F _create_ap create_ap
|
||||
|
||||
# vim: set ft=sh:
|
28
create_ap.conf
Normal file
28
create_ap.conf
Normal file
@ -0,0 +1,28 @@
|
||||
CHANNEL=default
|
||||
GATEWAY=10.0.0.1
|
||||
WPA_VERSION=2
|
||||
ETC_HOSTS=0
|
||||
DHCP_DNS=gateway
|
||||
NO_DNS=0
|
||||
NO_DNSMASQ=0
|
||||
HIDDEN=0
|
||||
MAC_FILTER=0
|
||||
MAC_FILTER_ACCEPT=/etc/hostapd/hostapd.accept
|
||||
ISOLATE_CLIENTS=0
|
||||
SHARE_METHOD=nat
|
||||
IEEE80211N=0
|
||||
IEEE80211AC=0
|
||||
HT_CAPAB=[HT40+]
|
||||
VHT_CAPAB=
|
||||
DRIVER=nl80211
|
||||
NO_VIRT=0
|
||||
COUNTRY=
|
||||
FREQ_BAND=2.4
|
||||
NEW_MACADDR=
|
||||
DAEMONIZE=0
|
||||
NO_HAVEGED=0
|
||||
WIFI_IFACE=wlan0
|
||||
INTERNET_IFACE=eth0
|
||||
SSID=MyAccessPoint
|
||||
PASSPHRASE=12345678
|
||||
USE_PSK=0
|
13
create_ap.service
Normal file
13
create_ap.service
Normal file
@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=Create AP Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/create_ap --config /etc/create_ap.conf
|
||||
KillSignal=SIGINT
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
74
howto/realtek.md
Normal file
74
howto/realtek.md
Normal file
@ -0,0 +1,74 @@
|
||||
## Try this first
|
||||
|
||||
If you are facing any problems with Realtek adapters (e.g. Edimax EW-7811Un)
|
||||
first try to run create_ap with `-w 2` (i.e. use WPA2 only) or use it
|
||||
without passphrase. If you are still facing any problems or you want to
|
||||
also use WPA1, then follow the instructions below.
|
||||
|
||||
NOTE: The instructions below are only valid for Realtek adapters with 8192 chipset.
|
||||
|
||||
## Before installation
|
||||
|
||||
If you're using ArchLinux, run:
|
||||
|
||||
```
|
||||
pacman -S base-devel linux-headers dkms git
|
||||
pacman -R hostapd
|
||||
```
|
||||
|
||||
If you're using Debian, Ubuntu, or any Debian-based distribution, run:
|
||||
|
||||
```
|
||||
apt-get install build-essential linux-headers-generic dkms git
|
||||
apt-get remove hostapd
|
||||
apt-get build-dep hostapd
|
||||
```
|
||||
|
||||
## Install driver
|
||||
|
||||
The driver in the mainline of Linux kernel doesn't work well with the 8192 adapters.
|
||||
For this reason you need to install the driver that is provided from Realtek. Their
|
||||
driver can not be compiled with newer kernels, but since it was an open-source
|
||||
release under GPL license some people were able to fixed it and make it compile.
|
||||
|
||||
With the following commands you can install a fixed version of Realtek's driver:
|
||||
|
||||
```
|
||||
git clone https://github.com/pvaret/rtl8192cu-fixes.git
|
||||
dkms add rtl8192cu-fixes
|
||||
dkms install 8192cu/1.9
|
||||
cp rtl8192cu-fixes/blacklist-native-rtl8192.conf /etc/modprobe.d
|
||||
cp rtl8192cu-fixes/8192cu-disable-power-management.conf /etc/modprobe.d
|
||||
```
|
||||
|
||||
After installation, unload the previous driver and load the new one, or just reboot.
|
||||
|
||||
## Install hostapd
|
||||
|
||||
Realtek's driver is using an old subsystem which is called `wireless-extensions`
|
||||
(or `wext`). Hostapd works only with the new subsystem (which is called `nl80211`).
|
||||
For this reason Realtek wrote a patch for hostapd. You can install it with the
|
||||
following commands:
|
||||
|
||||
If you have ArchLinux install [hostapd-rtl871xdrv](https://aur.archlinux.org/packages/hostapd-rtl871xdrv)
|
||||
from AUR or just run:
|
||||
|
||||
```
|
||||
yaourt -S hostapd-rtl871xdrv
|
||||
```
|
||||
|
||||
If you're using any other distribution, run:
|
||||
|
||||
```
|
||||
git clone https://github.com/pritambaral/hostapd-rtl871xdrv.git
|
||||
wget http://w1.fi/releases/hostapd-2.2.tar.gz
|
||||
tar zxvf hostapd-2.2.tar.gz
|
||||
cd hostapd-2.2
|
||||
patch -p1 -i ../hostapd-rtl871xdrv/rtlxdrv.patch
|
||||
cp ../hostapd-rtl871xdrv/driver_* src/drivers
|
||||
cd hostapd
|
||||
cp defconfig .config
|
||||
echo CONFIG_DRIVER_RTW=y >> .config
|
||||
make
|
||||
make install
|
||||
```
|
Loading…
Reference in New Issue
Block a user