Main references:
0.https://www.raspberrypi.org/forums/viewtopic.php?p=462982#p462982
1.https://www.maketecheasier.com/set-up-raspberry-pi-as-wireless-access-point/
2.http://www.jenssegers.be/43/realtek-rtl8188-based-access-point-on-raspberry-pi
3.https://www.embbnux.com/2015/02/08/setup_raspberry_to_wifi_access_point_with_rtl8188/
4.http://www.christianix.de/linux-tutor/hostapd.html
5.http://www.cnblogs.com/zhuwenger/archive/2011/03/11/1980294.html
===============================================
Part 1
Get ready:
1.Raspberry Pi 21 x
2.USB can not network card one (I use this: tp-linktl-wn725n)
First, install the raspberry. (System installation is no longer described)
Second, the installation of the driver, the main reference: https://www.raspberrypi.org/forums/viewtopic.php?p=462982#p462982
Download the corresponding driver installation.
Third, installation isc-dhcp-server and configuration
Edit "/etc/network/interfaces" and add the static IP address information for wlan0
. You can learn about the static IP addresses in our SSH and static IP address tutorial.
sudo vim/etc/network/interfaces
Place a "#" sign in front of the lines which mention wlan0
wpa
and, except for " allow hotplug wlan0
". Then add the following lines to the file:
Iface wlan0 inet staticaddress 192.168.42.1netmask 255.255.255.0
Gateway 192.168.1.1
The bottom half of the file would now look something like this:
Allow-hotplug Wlan0
#iface Wlan0 inet Manual
#wpa-conf/etc/wpa_supplicant/wpa_supplicant.conf
Iface wlan0 inet staticaddress 192.168.42.1netmask 255.255.255.0
Gateway 192.168.1.1
Now reboot.
Install and configure a DHCP server
Install the DHCP server:
sudo apt-get install Isc-dhcp-server
You can safely ignore any errors on not being able to start of the DHCP server at this point. Now edit the its configuration file:
sudo vim/etc/dhcp/dhcpd.conf
Add a "#" character in front of the " option domain-name
" "lines like this:
#option domain-name "example.org"; #option domain-name-servers ns1.example.org, ns2.example.org;
Remove the "#" sign in front of the " authoritative;
" statement like this:
# IF This DHCP server was the official DHCP server for the local# network, the authoritative directive should be uncommente d.authoritative;
At the bottom of the file add the following lines:
Subnet 192.168.42.0 netmask 255.255.255.0 {range 192.168.42.10 192.168.42.50;option broadcast-address 192.168.42.255;o ption routers 192.168.42.1;default-lease-time 600;max-lease-time 7200;option domain-name "local"; option Domain-name-servers 8.8.8.8, 8.8.4.4;}
Make the wireless adapter the default for the DHCP request:
sudo vim/etc/default/isc-dhcp-server
Change "to INTERFACES=""
" INTERFACES="wlan0"
"
Restart the DHCP server:
sudo service isc-dhcp-server restart
Iv. installation HOSTAPD, reference: Http://www.jenssegers.be/43/Realtek-RTL8188-based-access-point-on-Raspberry-Pi
Since We is building our own HOSTAPD version, remove the original HOSTAPD you might has installed:
sudo apt-get autoremove hostapd
On your Raspberry Pi, download and extract the source files from GitHub:
wget https://github.com/jenssegers/RTL8188-hostapd/archive/v2.0.tar.gztar -zxvf v2.0.tar.gz
Now build HOSTAPD:
cd RTL8188-hostapd-2.0/hostapdsudo make
After a while, you should is given control back to the terminal.
install
This last step would move the created HOSTAPD binary /usr/local/bin
to, add a startup script and create a configuration file in .
This is to illustrate, using WPA encryption, any settings can not connect, do not know why, using WEP encryption method to connect properly
Interface=wlan0driver=nl80211#driver=rtl871xdrvssid=mypihw_mode=gchannel=6macaddr_acl=0auth_algs=1 # 1=WPA, 2=web , 3=both
# Hide ssid:0 (don ' t), 1 (use emtpy), 2 (use ASCII 0) ignore_broadcast_ssid=0#wpa=3 #1: wpa,2:wpa2,3:both#wpa_passphrase=r Aspberry #password #wpa_key_mgmt=wpa-psk#wpa_pairwise=tkip#rsn_pairwise=ccmp
Wep_default_key=0
wep_key0=1234567890
Edit This configuration file and start the HOSTAPD service:
sudo service hostapd restart[ ok ] Stopping advanced IEEE 802.11 management: hostapd.[ ok ] Starting advanced IEEE 802.11 management: hostapd.
Tell HOSTAPD where to find it configuration file by setting the default location:
sudo vim/etc/default/hostapd
Remove the "#" in front of "" and alter the line to DAEMON_CONF
read:
daemon_conf= "/etc/hostapd/hostapd.conf"
Five
Configure IP routing between the Wireless and Ethernet
Edit "to /etc/sysctl.conf
enable IP forwarding:
sudo vim/etc/sysctl.conf
Find the line which reads "" and uncomment the next line like this Uncomment the next line to enable packet forwarding for IPv4
:
# Uncomment the next line to enable packet forwarding for ipv4net.ipv4.ip_forward=1
Run The following command to activate forwarding now:
sudo sh-c "echo 1 >/proc/sys/net/ipv4/ip_forward"
Now turn the Pi to a router with the follow commands:
sudo iptables-t nat-a postrouting-o eth0-j masqueradesudo iptables-a forward-i eth0-o wlan0-m State--state RELATE D,established-j acceptsudo iptables-a forward-i wlan0-o eth0-j ACCEPT
and save the routing tables into the file " /etc/iptables.ipv4.nat
"
sudo sh-c "Iptables-save >/etc/iptables.ipv4.nat"
Edit " /etc/network/interfaces
":
sudo vim/etc/network/interfaces
and add the following line to the end of the file. This line would restore the routing table whenever the Pi is booted:
Pre-up Iptables-restore </etc/iptables.ipv4.nat
You should now reboot your Pi and test the wireless access using a laptop, smartphone, tablet or other Wi-Fi enabled Devic E.
==========================================================
Part 2
0.http://liberize.me/tech/raspberry-pi-transparent-proxy.html
1.http://huahang.im/2014/12/27/shadowsocks-on-miwifi/
2.https://gist.github.com/wen-long/8644243
3.http://hbprotoss.github.io/posts/da-jian-zhi-neng-fan-qiang-lu-you-qi.html
Ss-redir + Chinadns + iptables
VI. Install Shadowsocks-libev
Cd/home/pi/downloads/shadowsocks
wget https://github.com/shadowsocks/shadowsocks-libev/archive/v2.4.4.tar.gz
TAR-ZXVF v2.4.4.tar.gz
CD Shadowsocks-libev
./configure && Make
sudo make install
Create shadowsocks config file
Vim/etc/config.json
Ss-redir-c/etc/config.json
Install Chinadns
Cd/home/pi/downloads/chinadns
wget https://github.com/shadowsocks/ChinaDNS/releases/download/1.3.2/chinadns-1.3.2.tar.gz
TAR-ZXVF chinadns-1.3.2.tar.gz
CD chinadns-1.3.2
./configure &&make
sudo make install
sudo chinadns-m-c/var/local/share/chnroute.txt
Create a script with VI:
vi firewall.sh
Then write the following content:
#!/usr/bin/env shiptables -t nat -N SHADOWSOCKSiptables -t nat -A SHADOWSOCKS -d a.b.c.d -j RETURN # 这里请填写您服务器的外网IP地址iptables -t nat -A SHADOWSOCKS -d 0.0.0.0/8 -j RETURN # 上一行、这一行和下面几行的作用iptables -t nat -A SHADOWSOCKS -d 10.0.0.0/8 -j RETURN # 是让一些特定的网段流量不通过iptables -t nat -A SHADOWSOCKS -d 127.0.0.0/8 -j RETURN # shadowsocks中转iptables -t nat -A SHADOWSOCKS -d 169.254.0.0/16 -j RETURN #iptables -t nat -A SHADOWSOCKS -d 172.16.0.0/12 -j RETURN #iptables -t nat -A SHADOWSOCKS -d 192.168.0.0/16 -j RETURN #iptables -t nat -A SHADOWSOCKS -d 224.0.0.0/4 -j RETURN #iptables -t nat -A SHADOWSOCKS -d 240.0.0.0/4 -j RETURN #iptables -t nat -A SHADOWSOCKS -p tcp -j REDIRECT --to-ports 10000 # 这里填写上一步配置的"local_port"iptables -t nat -A PREROUTING -p tcp -j SHADOWSOCKS
Finally give him executable permissions and execute:
chmod a+x firewall.sh./firewall.sh
Raspberry Pi 2 wireless settings.