rginphilly
Posts: 3
Joined: Thu Jan 09, 2014 9:22 pm

connect 2 Wifi adapters to two Wifi networks

Sat May 17, 2014 6:08 pm

HI all - I'm trying to connect my Raspberry Pi to two separate networks to act as a router. I have a Wifi dongle (wlan0) that can connect to a public Wifi network. I have a second Wifi dongle (wlan1) connected to a private Wifi network.

If I have one of the dongles connected, it stays connected, but if I try to connect them both at the same time, one of them always disconnects. I have them plugged into an externally powered USB hub.

I'm not sure if its a hardware problem, configuration problem, or something else and need help determining what is going on here. any help/ideas would be appreciated.

My /etc/interfaces is:
<pre>
auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_network.conf
iface wlan0 inet static
address 192.168.2.1
netmask 255.255.255.0

allow-hotplug wlan1
iface wlan1 inet manual
wpa-roam /etc/wpa_supplicant/wep_network.conf
iface default inet dhcp
</pre>

My wpa_network.conf and wep_network.conf basically look like this:
<pre>
network={
...
}
</pre>

Again, if I have one of the dongles connected, it stays connected. This only fails when both dongles are connected.

User avatar
DougieLawson
Posts: 39303
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: connect 2 Wifi adapters to two Wifi networks

Sat May 17, 2014 7:25 pm

sudo apt-get purge ifplugd
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

rginphilly
Posts: 3
Joined: Thu Jan 09, 2014 9:22 pm

Re: connect 2 Wifi adapters to two Wifi networks

Tue May 20, 2014 12:48 am

That worked. thank you thank you thank you!

Aydan
Posts: 729
Joined: Fri Apr 13, 2012 11:48 am
Location: Germany, near Lake Constance

Re: connect 2 Wifi adapters to two Wifi networks

Tue May 20, 2014 3:42 pm

And now for the explanation of why dougie's solution works:
ifplugd shuts down all networks it controls whenever a new network is connected.
This makes sense as long as the new connection connects to the same network, e.g. switching from wlan to ethernet on the same router.
It breaks though whenever you want to do bridging.
I tried (unsuccessfully I might add) to check if the new connection connects to the same network, but the ifplugd script gets called too early. Before the new link is up.
I think the ifplugd functionality needs a serious rethinking. As it is now it is way too aggressive.

Regards
Aydan

MrEngman
Posts: 4037
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: connect 2 Wifi adapters to two Wifi networks

Tue May 20, 2014 4:48 pm

So why does my Pi sat next to me have 3 connections, eth0, wlan0 and wlan1, up at the moment? Because what you are saying would appear to say I should only have one up.

Anyway, to see what happens I removed ifplugd (sudo apt-get purge ifplugd) and rebooted and up came wlan0 and wlan1 and no eth0. Hmm. OK edited /etc/network/interfaces and added [b]auto eth0[/b] and rebooted and eth0, wlan0 and wlan1 all came up.

Now here's something odd. I unplugged the Ethernet cable and ifconfig still shows eth0 as connected. I am currently connected via SSH to eth0, wlan0 and wlan1 and I am able to use all three interfaces even though eth0 is actually disconnected. How about that. And eth0 can still connect to the internet. Care to explain that?

And a little more. Unplugged wlan0 and lost the SSH connection to eth0 and wlan0. Then ifconfig on wlan1 shows eth0 and wlan1 connected so tried SSH to the eth0 IP and the connection is back even though the Ethernet cable is disconnected, so eth0 should be down. Anything else to explain?

I think time to re-install ifplugd.


MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

User avatar
DougieLawson
Posts: 39303
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: connect 2 Wifi adapters to two Wifi networks

Tue May 20, 2014 4:53 pm

Have you changed the configuration of ifplugd? Because the default config is designed to make the network behave like windows. That allows one active interface regardless of what subnet it is connected to. It's the first thing I remove off any distribution because I like to retain complete control of all parts of my network.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

MrEngman
Posts: 4037
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: connect 2 Wifi adapters to two Wifi networks

Tue May 20, 2014 5:03 pm

No, just standard raspbian, currently 3.12.19+ #684, although I have added samba and tightvnc but no changes to anything to do with networking, except of course /etc/network/interfaces.


MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

MrEngman
Posts: 4037
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: connect 2 Wifi adapters to two Wifi networks

Tue May 20, 2014 6:06 pm

MrEngman wrote:No, just standard raspbian, currently 3.12.19+ #684, although I have added samba and tightvnc but no changes to anything to do with networking, except of course /etc/network/interfaces.
Not quite right. It's using raspbian 3.10.25+ #622, and /lib/udev/rules.d/75-persistent-net-generator.rules has been modified to allow udev to handle wlan*[0-9]

Code: Select all

# device name whitelist
KERNEL!="ath*|wlan*[0-9]|msh*|ra*|sta*|ctc*|lcs*|hsi*", \
                                        GOTO="persistent_net_generator_end"

MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

Aydan
Posts: 729
Joined: Fri Apr 13, 2012 11:48 am
Location: Germany, near Lake Constance

Re: connect 2 Wifi adapters to two Wifi networks

Tue May 20, 2014 9:16 pm

MrEngman wrote:So why does my Pi sat next to me have 3 connections, eth0, wlan0 and wlan1, up at the moment? Because what you are saying would appear to say I should only have one up.
As far ass I recall, when you boot up all connections will come up because ifplugd doesnt fire any triggers. ifplugd probably starts later than networking.
That means if you were to disconenct and reconnect your ethernet or replug your wifi dongles the other network interfaces would shut down.

MrEngman
Posts: 4037
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: connect 2 Wifi adapters to two Wifi networks

Tue May 20, 2014 9:28 pm

Aydan wrote:
MrEngman wrote:So why does my Pi sat next to me have 3 connections, eth0, wlan0 and wlan1, up at the moment? Because what you are saying would appear to say I should only have one up.
As far ass I recall, when you boot up all connections will come up because ifplugd doesnt fire any triggers. ifplugd probably starts later than networking.
That means if you were to disconenct and reconnect your ethernet or replug your wifi dongles the other network interfaces would shut down.
That doesn't happen for me. If I unplug an interface the remaining interfaces stay up and when I plug the disconnected one back in they all remain up.


MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

Aydan
Posts: 729
Joined: Fri Apr 13, 2012 11:48 am
Location: Germany, near Lake Constance

Re: connect 2 Wifi adapters to two Wifi networks

Tue May 20, 2014 9:33 pm

MrEngman wrote:That doesn't happen for me. If I unplug an interface the remaining interfaces stay up and when I plug the disconnected one back in they all remain up.


MrEngman
Do you have ifplugd active and configured to control all interfaces?
I had a hell of a time to make my wifi to ethernet bridge behave as I wanted and not as Mr. Ifplugd wanted. But without ifplugd ethernet hotplugging doesn't work properly either.

Regards
Aydan

Return to “Troubleshooting”