Raspberry pi Wireless Bridge

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
learningasigo
 
Posts: 14
Joined: Tue May 22, 2012 8:19 am

Raspberry pi Wireless Bridge

Post by learningasigo »

Hello all,

I am new to raspberry pi. I have successfully made an access point to bridge wlan0 to eth0, following adafruit guide. I would however like to make a wireless bridge but I need a for dummies guide. I use the basic debian OS. I want to put a hub on eth0 and forward all packets to wlan0 to connect to my home router with WPA2 wireless b/g/n BT Hub.

win7+--------------+|H| | | )))))))))))) (((((((((((( | |
Ubuntu+----------+ |U|+----+[raspberrypi] [wireless bridge] [ROUTER]
printer1+---------+ |B|

Any help would be great,

Cheers

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Raspberry pi Wireless Bridge

Post by adafruit_support_mike »

The process would be pretty much the same as in our wireless router tutorial (http://learn.adafruit.com/setting-up-a- ... cess-point), but you'd reverse wlan0 and eth0 in the NAT tables. Instead of routing connections from wlan0 to eth0, you'd send connections from eth0 to wlan0.

learningasigo
 
Posts: 14
Joined: Tue May 22, 2012 8:19 am

Re: Raspberry pi Wireless Bridge

Post by learningasigo »

iv caught this post a little late. I got distracted by the arduino. Ill follow this tommoz and post the process I go through encase I get any issues.

learningasigo
 
Posts: 14
Joined: Tue May 22, 2012 8:19 am

Re: Raspberry pi Wireless Bridge

Post by learningasigo »

Ok so I downloaded the pdf and from what I understand these are the steps I will take:
I will set up Wlan0 to connect to my home router.
Step1: Get Software

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

Step2:Set Up DHCP Sever

sudo nano /etc/dhcp/dhcpd.conf

Find the lines that say:
option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;
and change them to add a # in the beginning so they say:

Code: Select all

 #option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;
Find the lines that say:
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
and remove the # so it says

Code: Select all

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;
Then scroll down to the bottom and add the following lines

Code: Select all

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;
}
Step3: Set the DHCP interface to receive ip address

Run:
sudo nano /etc/default/isc-dhcp-server
edit line to:
INTERFACES="eth0"

Step4: Set up eth0 for static IP
Run:
sudo ifdown eth0
Then we set the eth0 connection to be static for incoming, we run:
sudo nano
/etc/network/interfaces


The config file is edit to:

Code: Select all

auto lo

iface lo inet loopback 
iface wlan0 inet dhcp

allow hotplug eth0

iface eth0 inet static
  address 192.168.42.1
  netmask 255.255.255.0
Then crtl and ctrl y to save
i will then assign a static ip to eth0:
sudo ifconfig eth0 192.168.42.1

Step5: NAT
run:
sudo nano /etc/sysctl.conf
scroll to the bottom and add:

Code: Select all

net.ipv4.ip_forward=1
save and exit, then start ip forwarding on boot:
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

Create a NAT between wlan0 and eth0:
sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
sudo iptables -A FORWARD -i wlan0 -o eth00 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i eth00 -o wlan0 -j ACCEPT

check to see whats in the tables wit:
sudo iptables -t nat -S
sudo iptables -S
To make this happen on reboot (so you don't have to type it every time) run
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
sudo nano /etc/network/interfaces

then add at the bottom:

Code: Select all

 up iptables-restore < /etc/iptables.ipv4.nat
Step6: finishing up
sudo service isc-dhcp-server start
I will then plug eth0 into hub and Ubuntu pc into hub and try to connect to website?

Thanx can anyone tell me if this is the right process?

Cheers

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Raspberry pi Wireless Bridge

Post by adafruit_support_mike »

That looks right.

Check it each step of the way to make the pieces respond as they should before moving on to the next service.. get your IP addresses set correctly, then set up the DHCP server and make sure it hands out addresses to the machines connected through the Ethernet interface, get your WAP connection working, then bring in the address translation.

Your overall research looks very good though.

learningasigo
 
Posts: 14
Joined: Tue May 22, 2012 8:19 am

Re: Raspberry pi Wireless Bridge

Post by learningasigo »

yes it works I can ping 192.168.42.1 and my home bt router 192.168.1.254 however google is a no go. I can connect to google using the raspberry pi. However the WAP gets the ip address of 192.168.1.75 but my bt home hub packets come back so im thinking maybe my raspberry pi has to be forwarded to let my Ubuntu pc access the internet using a browser. Any ideas?

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Raspberry pi Wireless Bridge

Post by adafruit_support_mike »

Actually, I think I see a typo in your IP forwarding rules: you have '-i eth00' up above, and the interface name is 'eth0'.

Try changing that.

learningasigo
 
Posts: 14
Joined: Tue May 22, 2012 8:19 am

Re: Raspberry pi Wireless Bridge

Post by learningasigo »

yup I changed the typo's as I went along. I can connect to my router so it forwards, but beyond that it does not connect to the internet.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Raspberry pi Wireless Bridge

Post by adafruit_support_mike »

When you say "connect to the router", do you mean the RasPi can reach it, or machines with an Ethernet connection to the RasPi can reach it?

learningasigo
 
Posts: 14
Joined: Tue May 22, 2012 8:19 am

Re: Raspberry pi Wireless Bridge

Post by learningasigo »

I started of with a wifi connection using the gui to the router.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Raspberry pi Wireless Bridge

Post by adafruit_support_mike »

Can you ping the router from a machine connected to the RasPi?

learningasigo
 
Posts: 14
Joined: Tue May 22, 2012 8:19 am

Re: Raspberry pi Wireless Bridge

Post by learningasigo »

yes I can

learningasigo
 
Posts: 14
Joined: Tue May 22, 2012 8:19 am

Re: Raspberry pi Wireless Bridge

Post by learningasigo »

now I have rebooted the pi and Ubuntu pc they have no connx to eachother or router. The wpa_gui will not let me connect wirelessly to my router. Why is this so complicated. Setting it up as a bridge to wlan0 to eth0 worked straight away. This seems to BANNED-up.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Raspberry pi Wireless Bridge

Post by adafruit_support_mike »

It isn't so bad once you get used to it, but a distributed communications medium that spans the globe has lots of moving pieces.

Start by checking your interfaces (`ifconfig -a`), IP forwarding (`sysctl net.ipv4.ip_forward`) and DHCP server (`ps ax | grep dhcp`)

learningasigo
 
Posts: 14
Joined: Tue May 22, 2012 8:19 am

Re: Raspberry pi Wireless Bridge

Post by learningasigo »

ugh I can only get this going as an AP. Really miffed. Might try using it for something else.

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”