BLL
Posts: 230
Joined: Fri Jun 07, 2013 2:30 pm

Bridging

Tue Jun 25, 2013 12:06 pm

Hi, Can anyone help please? I have set up my RasPi as a router. It gets its internet from a wifi modem and wlan1 is configured as an AP, so my computers etc can connect via the Pi to the internet. That works fine. The AP runs dhcp.
However, I have one device which needs a network cable. I presume therefore that I could bridge eth0 with wlan1 to achieve this?

I have tried various tutorials online and all have been a disaster and I am now totally lost and confused! I haven't used bridging before.
I have tried:
sudo ifdown wlan1
sudo ifdown eth0
sudo brctl addbr br0
sudo brctl addif br0 wlan1
sudo brctl addif br0 eth0
sudo ifup br0 (that says unconfigured bridge br0=br0 !!!!!

I can no longer connect to wlan1 as the PC sticks on "acquiring network address" and a computer on eth0 reports limited or no connectivity!

HELP!!!!

Thanks

User avatar
rpdom
Posts: 15582
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Bridging

Tue Jun 25, 2013 12:50 pm

To use ifup and ifdown, you need to configure the bridge in /etc/networks/interfaces.

I tried this on a Debian PC once (worked perfectly). If I remember, the interfaces file was something like

Code: Select all

auto lo
iface lo inet loopback

iface eth0 inet manual

iface wlan0 inet manual

auto br0
iface br0 inet dhcp
    bridge_ports eth0 wlan0
That was all from memory, I don't have the file any more and I can't remember where I put the wireless config lines.
I'm sure I'm missing something here... :(

Ah, just checked on the Debian Wiki. You should look http://wiki.debian.org/BridgeNetworkConnections

BLL
Posts: 230
Joined: Fri Jun 07, 2013 2:30 pm

Re: Bridging

Tue Jun 25, 2013 3:40 pm

Thanks. The link you give is the latest one I have been trying to use, without success. At present, my 'etc/network/interfaces looks like this:
auto lo
iface lo inet loopback
iface eth0 inet dhcp
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

iface wlan1 inet static
address 192.168.2.1
netmask 255.255.255.0

up iptables-restore < /etc/iptables.ipv4.nat

I don't understand it, which doesn't help!

DHCP for wlan1 (the AP) comes from dnsmasq and I presume that the wlan1 entry will have to become br0?

interface=wlan1
dhcp-range=192.168.2.50,192.168.2.200,255.255.255.0,12h
dhcp-option=252,"\n"

Am I on the right lines?

Thanks for the reply.

User avatar
rpdom
Posts: 15582
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Bridging

Tue Jun 25, 2013 6:41 pm

You seem to have a confused mix of routing and bridging.

Do you want to set your Pi up as a router or a bridge?

A router connects two different networks with different ranges of IP addresses together and often uses masquerading to make it appear that all computers on one network seem to be using the same IP address on the other network. This is how most home internet routers work.

On a Linux computer you will usually use iptables to do this.

A bridge connects two parts of the SAME network together with the same range of IP addresses. A wireless access point is a type of bridge. It joins the wired and wireless parts of the same network together.

On a Linux computer you will use bridge utilities to do this.

You need to decide on one or the other. In your case I think just bridging will work best. You don't need a router.

BLL
Posts: 230
Joined: Fri Jun 07, 2013 2:30 pm

Re: Bridging

Tue Jun 25, 2013 8:01 pm

Hi, Thanks for the reply. I already have the Pi acting as a router, so I can connect my computers to the AP I have setup on wlan1. I can connect the Pi to the internet either by a 3g modem or to another AP. However, I have one device (a Skype cordless phone) which requires a wired (CAT5) connection, so I want to connect it to the Pi's NIC to be able to see the internet. so it's just 1 device to connect that isn't wireless. I think therefore that it is a bridge I need to set up, but I would welcome some advice as my networking knowledge is not very good!

User avatar
rpdom
Posts: 15582
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Bridging

Wed Jun 26, 2013 6:57 am

Let me get this straight then.
wlan0 is your your internet access.
wlan1 and eth0 will be your local LAN.

You want to bridge wlan1 and eth0 together and route external traffic from them to wlan0.

Is that right?

Based on that, I reckon your 'etc/network/interfaces should look like this:

Code: Select all

auto lo
iface lo inet loopback

iface eth0 inet manual

# I'm not sure why this is set to manual?
iface wlan0 inet manual
    wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface wlan1 inet manual

auto br0
    iface br0 inet static
    address 192.168.2.1
    netmask 255.255.255.0
    bridge_ports eth0 wlan1
    up iptables-restore < /etc/iptables.ipv4.nat
DHCP for wlan1 (the AP) comes from dnsmasq and I presume that the wlan1 entry will have to become br0?

Code: Select all

interface=wlan1
dhcp-range=192.168.2.50,192.168.2.200,255.255.255.0,12h
dhcp-option=252,"\n"
Yes, that's right. You might need to change your IPtables settings if they refer to wlan1 to use br0 instead.

Go through what I've put and see if it makes sense to you. Ask any questions you like.

Then backup your files, shutdown all interfaces with sudo ifdown -a, then make the changes, and sudo ifup -a. See if that works - but do check and make sure you understand what I've suggested first! (and that I haven't made any errors)

BLL
Posts: 230
Joined: Fri Jun 07, 2013 2:30 pm

Re: Bridging

Wed Jun 26, 2013 8:49 am

Hi, No, that's not right. At present, I can have the Pi do either of the following, according to which of 2 scripts I run, before rebooting it:

1). Connect wlan0 to an AP (eg. one on a caravan site) and route that to my local AP, wlan1

2) Connect 3g modem to the internet and route that to my AP on wlan1

What I want is to connect my Skype phone base unit to the Pi's eth0 and have it able to see the internet in either case.

This all seems complicated but basically it is for my caravan. On some sites they have wifi, so I use that and on others they don't and so I have to use the 3g dongle, but in both cases I want to be able to connect my laptop and printer by wireless and the phone unit by cable.

Hope I've made it clearer this time!

Thanks for your help.

User avatar
rpdom
Posts: 15582
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Bridging

Wed Jun 26, 2013 11:18 am

That sounds like what I said?

The bridge just joins wlan1 and eth0 together with the same IP adddress and calls them both br0 instead.

Your script that currently routes internet traffic from AP or modem to wlan1 would need to route to virtual port br0 instead and the traffic would go to both wlan1 and eth0.

BLL
Posts: 230
Joined: Fri Jun 07, 2013 2:30 pm

Re: Bridging

Wed Jun 26, 2013 4:03 pm

Thanks for that and sorry about my confusion, but I wanted to make sure you understood what I want to do. The wlan0 manual I found was needed when bringing the Pi up for wlan0 to wlan1 routing or I got an error message that the supplicant was handling things and buzz off!

Could you explain the loopback lines please?

I will try your suggestions as soon as I can and will get back to you!

I do appreciate your help. Having spent 35 years in dos/windows, linux comes as a nasty shock!!

Brian

User avatar
rpdom
Posts: 15582
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Bridging

Wed Jun 26, 2013 4:22 pm

No problem :)

The loopback interface is an internal fake network connection that allows you to connect to services on the local machine without it using any network interfaces. It has the IP address 127.0.0.1 - even Windows has this (although I have heard that it also responds to other addresses on the 127.0.0.x subnet, which is allowed).

BLL
Posts: 230
Joined: Fri Jun 07, 2013 2:30 pm

Re: Bridging

Wed Jun 26, 2013 6:39 pm

Hi again, I'm afraid it doesn't work! During boot up it says: "can't add wlan1 to bridge br0 operation not supported"

That's followed by: "waiting for br0 to get ready (MAXWAIT is 32 seconds)"

I presume the 2nd error is a consequence of the first.

Back to the drawing board!

User avatar
rpdom
Posts: 15582
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Bridging

Thu Jun 27, 2013 5:25 am

I've been googling and checking stuff. Unfortunately I can't test with a similar setup as neither of my wlan interfaces support AP mode :(

Some people claim to have got it working, but there seems to be an issue with the wlan drivers to do with using an alternate MAC address. I haven't found a solution to that, sorry :(

The only suggestion I can make is a hardware get-around. Plug a 4 port switch into eth0, connect your Skype phone and a separate access point to that and change your routing tables to use eth0 instead of wlan1. Not the best answer really.

Hmm, I'm a bit fuzzy on the iptables routing options, but could you make eth0 a different subnet and masquerade traffic between that and wlan0 as well as doing the same for wlan1? Does the phone need to connect to your internal network as well as internet?

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: Bridging

Thu Jun 27, 2013 7:38 am

You don't want to bridge it.
You want to make it route from wlan0 to eth0
Do you want the skype phone to be able to access the local network ?
If not, then it's a lot easier.
It's just another set of iptable rules, the same as what you have for wlan1, except replace wlan1 with eth0
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

geekinthesticks
Posts: 97
Joined: Fri Feb 08, 2013 7:22 pm

Re: Bridging

Thu Jun 27, 2013 7:58 am

I am not 100% sure exactly what you are tying to do. However, if you want to route your Skype phone on eth0 to the internet and have an access point on wlan0 one way of doing this is to:

* set up eth0 on one network eg 192.168.0.1
* setup wlan0 on another network eg 10.0.0.0. Make the wlan adapter 10.0.0.1
* setup a dhcp server to listen on wlan0, so clients connecting to wlan0 get an address in the 10.0.0.0 range. If you don't have a dhcp server for 192.168.0.0 you could also listen on eth0 and assign addresses in that range to clients connecting via eth0.
* Make the default gateway on your 192.168.0.0 network 10.0.0.1
* Fire up your 3g modem.
* You will need to set up something like Shorewall to route traffic between the internet and eth0.

Now all traffic from eth0 that is outside the 192.168.0.0 range will get routed via 10.0.0.1 and hence to the internet. Anyone connecting to wlan0 is on the 10.0.0.0 network and their traffic should get routed to the internet if its outside that network.

This post is brought to you via a system very similar to what I have described!

BLL
Posts: 230
Joined: Fri Jun 07, 2013 2:30 pm

Re: Bridging

Thu Jun 27, 2013 8:26 am

Hi, Thanks for that. That first solution almost makes the Pi redundant! The phone base unit only needs to see the internet, nothing internally, but the internet comes from either a 3g modem or wlan0. Your last suggestion is way above my understanding I' afraid and needs translation!!

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: Bridging

Thu Jun 27, 2013 8:37 am

BLL wrote:Hi, Thanks for that. That first solution almost makes the Pi redundant! The phone base unit only needs to see the internet, nothing internally, but the internet comes from either a 3g modem or wlan0. Your last suggestion is way above my understanding I' afraid and needs translation!!
In that case, just duplicate the configuration you have for wlan1 for eth0. Don't need to muck around with bridging.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

BLL
Posts: 230
Joined: Fri Jun 07, 2013 2:30 pm

Re: Bridging

Thu Jun 27, 2013 9:29 am

I have tried to do as you say but a computer on eth0 isn't getting an ip address.
My interfaces file at present is:
auto lo

iface lo inet dhcp

iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

iface wlan1 inet nstatic
address 192.168.2.1
netmask 255.255.255.0

up iptables-restore < /etc/iptables.ipv4.net

and my dnsmasq.conf addition:
interface=wlan1
dhcp-range=192.168.2.50,192.168.2.200,255.255.255.0,12h

Thanks again in anticipation!!

User avatar
rpdom
Posts: 15582
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Bridging

Thu Jun 27, 2013 11:07 am

As you will be wanting to use different IP address ranges for wlan1 and eth0, I think you'll need a static address for eth0 on a different 192.168.x.y range.

Then make dnsmasq work on both interfaces by adding an "interface=eth0" line.

Then you have to tell it which dhcp IP addresses to offer on each port by changing your dhcp-range line to

Code: Select all

dhcp-range=interface:wlan1,192.168.2.50,192.168.2.200,255.255.255.0,12h
dhcp-range=interface:eth0,192.168.3.50,192.168.3.200,255.255.255.0,12h
(I've just used 192.168.3.x here as an example)

BLL
Posts: 230
Joined: Fri Jun 07, 2013 2:30 pm

Re: Bridging

Thu Jun 27, 2013 11:45 am

Hi, It still doesn't! The laptop I have connected to eth0 says it has limited/no connectivity and on trying to repair it, it says it can't get an ip address.

Is my interfaces file alright?

Thanks

Brian

User avatar
rpdom
Posts: 15582
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Bridging

Thu Jun 27, 2013 1:57 pm

I can't see an entry for eth0 in your interfaces file, so that might be why the laptop can't connect? That is, unless you configured it manually.

BLL
Posts: 230
Joined: Fri Jun 07, 2013 2:30 pm

Re: Bridging

Thu Jun 27, 2013 2:44 pm

No, I haven't. The interfaces file entries I don't understand and nowhere have I been able to find a simple explanation! Sorry to be a pain, but what do I need to add for eth0, please?

Thanks again

User avatar
rpdom
Posts: 15582
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Bridging

Thu Jun 27, 2013 3:26 pm

All you need is a simple interface definition stanza like

Code: Select all

auto eth0
iface eth0 inet static
    address 192.168.3.1
    netmask 255.255.255.0
The "auto" line means "Run ifup on this interface at start-up, or when the interface is detected"
The next line defines the type of interface "inet" and the method for getting an address, "static" which means use the address in the file.
Then you have the IP address for this interface (indent isn't needed, but makes it a bit more readable)
Finally the netmask.

There are also the options "network" and "broadcast", but these are outdated. Modern systems (under 20 years old!) work those out from combining the address and netmask. (broadcast would be 192.168.3.255, and network would be 192.168.3.0).

"man interfaces" gives a description of the file and options.

BLL
Posts: 230
Joined: Fri Jun 07, 2013 2:30 pm

Re: Bridging

Thu Jun 27, 2013 3:46 pm

Hi again

Thanks for that - I was surprised I couldn't find it on the net! Anyway, it now actually works! What had held me up was that I had put an '=' after network instead of a space and hadn't seen it on many checks on the file!!

Thanks very much for all your help. :D I can now replace my commercial Tenda 3G622 with the raspi. The Tenda used to keep dropping its 3G connection and needed rebooting. UMTSkeeper seems to do a fine job restoring the connection when needed.

Brian :mrgreen:

Return to “Networking and servers”