Raspberry pi 2 wireless settings.

主要参考:

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

准备:

1.Raspberry pi 2 一个

2.USB无法网卡一个(我这里用的是:TP-LINKTL-WN725N)

一、安装raspberry.(系统安装就不再累述)

二、安装驱动,主要参考:https://www.raspberrypi.org/forums/viewtopic.php?p=462982#p462982

  下载对应的驱动安装即可。

三、安装isc-dhcp-server及配置

Edit “/etc/network/interfaces” and add the static IP address information for wlan0. You can learn about static IP addresses in our SSH and static IP address tutorial.

 sudo vim /etc/network/interfaces

Place a “#” sign in front of all the lines which mention wlan0 and wpa, except for “allow hotplug wlan0“. Then add the following lines to the file:

iface wlan0 inet static
address 192.168.42.1
netmask 255.255.255.0gateway 192.168.1.1

The bottom half of the file will now look something like this:

allow-hotplug wlan0#iface wlan0 inet manual#wpa-conf /etc/wpa_supplicant/wpa_supplicant.confiface wlan0 inet static
address 192.168.42.1
netmask 255.255.255.0gateway 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 about not being able to start the DHCP server at this point. Now edit 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 is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
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;
option 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 “INTERFACES=""” to “INTERFACES="wlan0"

Restart the DHCP server:

sudo service isc-dhcp-server restart

四、安装hostapd, 参考:http://www.jenssegers.be/43/Realtek-RTL8188-based-access-point-on-Raspberry-Pi

Since we are building our own hostapd version, remove the original hostapd you might have 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.gz
tar -zxvf v2.0.tar.gz

Now build hostapd:

cd RTL8188-hostapd-2.0/hostapd
sudo make

After a while, you should be given control back to the terminal.

sudo make install

This last step will move the created hostapd binary to /usr/local/bin, add a startup script and create a configuration file in /etc/hostapd/hostapd.conf.

这是要说明一下,使用wpa加密方式,任何设置都无法连接,不知道为什么 ,使用wep加密方式可以正常连接

interface=wlan0
driver=nl80211
#driver=rtl871xdrv
ssid=MyPi
hw_mode=g
channel=6
macaddr_acl=0
auth_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=raspberry  #password
#wpa_key_mgmt=WPA-PSK
#wpa_pairwise=TKIP
#rsn_pairwise=CCMP

wep_default_key=0wep_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 its configuration file by setting the default location:

sudo vim /etc/default/hostapd

Remove the “#” in front of “DAEMON_CONF” and alter the line to read:

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

五、

Configure IP routing between the wireless and Ethernet

Edit “/etc/sysctl.conf” to enable IP forwarding:

sudo vim /etc/sysctl.conf

Find the line which reads “Uncomment the next line to enable packet forwarding for IPv4” and uncomment the next line like this:

# Uncomment the next line to enable packet forwarding for IPv4
net.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 into a router with the follow commands:

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

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 will 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 device.

==========================================================

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

六、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

用vi创建一个脚本:

vi firewall.sh

然后写入如下内容:

#!/usr/bin/env sh

iptables -t nat -N SHADOWSOCKS
iptables -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

最后赋予他可执行的权限,并且执行之:

chmod a+x firewall.sh
./firewall.sh
 
时间: 2024-12-13 11:14:45

Raspberry pi 2 wireless settings.的相关文章

Turn Your Raspberry Pi Into a WiFi Hotspot with Edimax Nano USB EW-7811Un (RTL8188CUS chipset)

http://www.daveconroy.com/turn-your-raspberry-pi-into-a-wifi-hotspot-with-edimax-nano-usb-ew-7811un-rtl8188cus-chipset/ Posted by dconroy on Jul 10, 2013 in How To's, Raspberry Pi | 142 comments | 143,087 views I’m writing this blog to help anyone wi

RASPBERRY PI 外设学习资源

参考: http://www.siongboon.com/projects/2013-07-08_raspberry_pi/index.html Raspberry Pi         Get started with Raspberry Pi (RPi), a step by step approach to get your Raspberry Pi with low level electronics hardware control. Make simple, step by step

Raspberry pi,一个好玩的派:第五季 无线网卡

Raspberry pi的板子由于成本原因是没有加无线模块的,不想被网线束缚的我们,需要自备USB无线模块.在购买板子时,看见官方推荐EDUP无线网卡,价格还算合适,就直接入手了. 采用REALTEK8188芯片,802.11n,传输速度150Mbps,适用范围130平方米. 将其插到任一U口即可,如下图: 由于外壳阻碍了电源插孔,所以只好先裸着了,图中已经加电,HDMI的另一头是电视机. 接下来的任务就是如何让这个无线网卡工作,连接到我已经开启的无线路由器. 一.wpa_gui 在进入Rasp

Using OpenCV with the Raspberry Pi camera

// Using OpenCV with the Raspberry Pi camera// 2015.11.21 created by Huangtao raspi-config “camera” and select “enable” install Pi Camera:===================http://www.raspberrypi.org/archives/3890test Pi Camera:=============== raspistill -t 10000ok.

最简单的RASPBERRY PI wifi配置

Setting up Wifi with the Command Line  SIMON MONK This tutorial works best if your router is broadcasting the SSID. Make sure you have "Broadcast SSID" set up on your router! This may not work with "private" SSID setups Setting up WiFi

Raspberry Pi AP功能改进: systemd服务封装以及dnsmasq的使用

前言在上一篇<Raspberry pi 设置自动拨号, 搭建无线路由环境>一文中,笔者利用hostapd和udhcpd程序,创建无线热点,实现地址分配以及DNS服务器的设置.本篇将基于上一篇的环境,对树莓派AP进行改进:使用dnsmasq代替udhcpd实现DNS以及地址租约,并将AP功能封装成为一个服务 上一篇中使用的hostapd以及udhcpd,其方式有一些缺陷: 使用命令行方式启动,并未将启动本身封装成为一个固定的"服务" 三代树莓派的内置网卡以及笔者使用的外置网卡

RASPBERRY PI wifi配置

Raspberry Pi 手把手教你在树莓派上安装USB无线网卡支持WIFI 树莓派虽然已经有了有线网卡,但是并未配置无线网卡,移动性不够强,好在机器配备了2个USB口,当然要分一个出来给WIFI无线网卡使用了,这样小派使用起来就更便利了!我手头有个NetCore磊科NW336无线网卡,非常便宜的那种,好像芯片是Realtek的,插入USB口试试,发现网卡上的指示灯会闪烁,感觉有戏,马上登陆系统折腾:(一)查看USB设备类型,寻找USB无线网卡是否已经被系统识别.运行lsusb[email pr

安装树莓派 Raspberry PI

安装树莓派 树莓派终于到货了,是这个样子的 上面有一行日期是 Raspberry PI (c) 2011.12 下载镜像,写入SD卡 http://www.raspberrypi.org/downloads/ 选择这个镜像: RASPBIAN Debian 2014-01-07 780M的压缩包,很大的样子 似乎还有个NOOBS的安装方式,完全无感 顺便展示一下SD卡,通过查阅可用SD卡列表,似乎是支持个别的64G Class10的卡的,就像这个,编号是 Transcend SDXC 64G C

Raspberry pi,一个好玩的派:第七季 Raspbmc(上)

Raspberry pi的一个优势是它具有很强的视频解码能力,用它来播放视频是个不错的选择.接下来的两季要用它来做家庭的媒体中心,而XMBC软件和Raspbmc发行版将使这一切变为可能. 一.XMBC和Raspbmc XMBC(即将更名为Kodi)是开源媒体中心软件中的佼佼者,最初是为XBOX开发的,现在可以运行在多个平台,其中就包括Raspberry pi运行的Linux系统.而更妙的一件事是有人已经把XMBC直接集成到系统中,变成了一个XMBC的专用系统,名为Raspbmc,这个人就是Sam