2

I really need some help with the raspberry networking stuff. I try to set up an Access-Point. I want to Access my Raspberry Wifi "Blackbox". After that I want to connect to "box" (192.168.100.2) over SSH. "box" should be able to connect to NTP TimeServer, if an internet connection is available over wlan1 (USB2)

 ___        ___________  
|   | eth0 |           | wlan0(Accesspoint) 
|box|-----<Eth        USB1>EdimaxWlanStick <<<<<<  PC/Laptop/Smartphone
|___|      | Raspberry |  
           | Pi        | wlan1(Connection to Router for Internet)
           |          USB2>EdimaxWlanStick >>>>>>  Router >>>> Internet
           |___________|

My /etc/network/interfaces looks like this:

auto eth0
iface eth0 inet static
    address 192.168.101.1
    netmask 255.255.255.0

auto wlan0
iface wlan0 inet static
    address 192.168.102.1
    netmask 255.255.255.0

auto wlan1
iface wlan1 inet dhcp
wpa-conf /etc/wpa.conf

auto br0
iface br0 inet static
bridge_ports eth0 wlan0
address 192.168.100.1
netmask 255.255.255.0

My /etc/hostapd/hostapd.conf

interface=wlan0
ssid=Blackbox
channel=10
driver=rtl871xdrv
ieee80211n=1
hw_mode=g
device_name=RTL8188CUS
manufacturer=Realtek
wpa=2
wpa_passphrase=********Secret
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
rsn_pairwise=CCMP

# Other settings
beacon_int=100
auth_algs=3
wmm_enabled=1

Connecting to Wifi Blackbox works fine. Connecting over SSH to the box, too. Internet on Raspberry also works fine.

When I try to ping Google-Server from the Raspberry, everythink works fine.

When I try to ping the same Server from the box, no Internet Connection is available.

Anyone an idea how to bridge the Internet Connection to the box and maybe also to the connected PC/Laptop/Smartphone ?

2
  • Have you checked that the bridge is created? sudo brctl show br0
    – Fred
    Commented Apr 18, 2014 at 14:51
  • yupp, I had checked this and the bridge br0 between etho and wlan0 is created. Commented Apr 18, 2014 at 15:44

2 Answers 2

5

OK. I read your question more carefully and I think I've worked out what's going on. Your bridge and everything is working fine. What's not working is that nothing on the bridge is talking to the internet. Which it can't do because it's not actually connected. On your Pi, two completely separate networks exist. The eth0<->wlan0 network, and the wlan1 network to your router. The simple thing to do would be just to glue them together, by changing the interfaces file.

auto eth0
iface eth0 inet dhcp

auto wlan0
iface wlan0 inet dhcp

auto wlan1
iface wlan1 inet dhcp
wpa-conf /etc/wpa.conf

auto br0
iface br0 inet dhcp
bridge_ports eth0 wlan0 wlan1

Of course, if you actually wanted them to be two separate networks, that's no good. What you want then is to do Network Address Translation (NAT), like your router does to the internet. In which case it's time to enter the land of iptables.

sudo echo 1 > /proc/sys/net/ipv4/ip_forward
sudo iptables -t nat -A POSTROUTING -o wlan1 -s 192.168.100.0/24 -j MASQUERADE

What that does is first enable IP forwarding, allowing the Pi to act as a router. The second line is the iptables magic. It tells the kernel networking stack as the final step of the packet routing procedure to bump it up the chain to wlan1 (your net connection), but also to MASQUERADE it. This is to say make it look like it came from this machine and send it on, rather then routing it normally (like bridging would).

The "box" will also have to be manually told about the gateway address of the Pi, 192.168.100.1, and you'll have to tell it about some DNS servers. Google's are easy to memorize, 8.8.8.8 and 8.8.4.4. If the static IP addressing is too much of a bother, look into a package called dnsmasq, which does all of that for you.

3
  • Thanks, this provides internet access to all connected devices. But now it takes the DHCP Server from the Router. How to configure the Pi, that the Pi is the DHCP Server and giving IP's in the range of 192.168.100.x to all connected devices? Commented Apr 22, 2014 at 11:41
  • Did you use the bridging or the iptables solution?
    – Fred
    Commented Apr 26, 2014 at 17:56
  • bridging solution Commented Apr 29, 2014 at 17:21
-3

I want to configure My Raspberry Pi the same way.

  1. I have a USB Modem (D-LINK 3G MiFi) which connect to Internet via 3G and shows a eth1 in Raspberry Pi and works perfectly to provide internet
  2. I want to connect my LAN device (old pc) to eth0
  3. I want to connect my WiFi devices to wlan0

I am able to connect my eth0 device to internet and able to configure wlan0 as HOSTAPD mode.

I want to share same Netwrok to eth0 and wlan0 I want to access internet for devices connected on eth0 and wlan0

How shall i configure wlan0 as it shall be on same network to communicate between devices and to internet.

1
  • 1
    This is a question, not an answer. You already have an account at Stack Overflow, you should know how this works.
    – goldilocks
    Commented Dec 22, 2014 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.