# Connecting to multiple wireless networks



## Heraklit (Sep 9, 2012)

Hi,

I am using two wireless routers to which I can connect from my desktop PC. The first router serves as an internet gateway whereas the second one is used to connect a single PC with static IP 192.168.2.3. The two routers also possess static IPs, namely 192.168.2.1 for the internet gateway and 192.168.2.2, respectively. I am currently using the following script to connect to either routers:

```
ifconfig wlan0 destroy
ifconfig wlan0 create wlandev ath0 up

if [ "$1" = "WLAN2" ]; then
  ifconfig wlan0 inet 192.168.2.112 netmask 255.255.255.0 ssid WLAN2 authmode shared wepmode on weptxkey 1 wepkey 1:0x.... up
else
  wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf &
fi
```

So I am connecting to the internet router via WPA-Supplicant and to my simple network via WEP. The script is used to switch between both networks in this context.
As this solution is somehow cumbersome I am searching for an alternative way to connect both routers with my desktop PC.

So it would be nice, if there's a possibility to integrate both networks (with ideally little effort) so that I can set up a internet connection using destination 192.168.2.1 and reach the second PC by calling address 192.168.2.3 at the same time. How could this requirement be realised? (links?)
Maybe there's a possibility to create two interfaces wlan0 and wlan1 by extending wlans_ath0 in /etc/rc.conf, so that interface wlan0 need not to destroyed before each connection.


```
wlans_ath0="wlan0"
ifconfig_wlan0="WPA DHCP"
```

And one second question: After having connected to my WEP-network, two IP-addresses are assigned to interface wlan0 (see the following output of ifconfig). I would expect only IP 192.168.2.112 which is assigned by the above listed script.

Output of ifconfig after connection to 192.168.2.2:


```
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
       ether 00:1b:9e:4e:31:a9
       inet6 fe90::31b:9fff:fe4e:24ab%wlan0 prefixlen 64 scopeid 0xa 
       inet 192.168.2.112 netmask 0xffffff00 broadcast 192.168.2.255
       inet 192.168.2.101 netmask 0xffffff00 broadcast 192.168.2.255
       nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
       media: IEEE 802.11 Wireless Ethernet OFDM/48Mbps mode 11g
       status: associated
       ssid WLAN2 channel 8 (2447 MHz 11g) bssid 00:13:bc:68:1d:c4
       regdomain 101 indoor ecm authmode SHARED privacy ON deftxkey 1
       wepkey 1:104-bit txpower 20 bmiss 7 scanvalid 60 bgscan
       bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
       wme burst
```

And that's the output of ifconfig after a connection to 192.168.2.1 has been established:


```
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	ether 00:2b:9e:5e:a1:c9
	inet6 fe80::22b:9aff:ff4e:41c9%wlan0 prefixlen 64 tentative scopeid 0xa 
	inet 192.168.2.100 netmask 0xffffff00 broadcast 192.168.2.255
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
	media: IEEE 802.11 Wireless Ethernet OFDM/12Mbps mode 11g
	status: associated
	ssid WLAN channel 8 (2447 MHz 11g) bssid 00:12:cf:9e:af:04
	regdomain 101 indoor ecm authmode WPA2/802.11i privacy ON
	deftxkey UNDEF AES-CCM 3:128-bit AES-CCM 4:128-bit txpower 20 bmiss 7
	scanvalid 450 bgscan bgscanintvl 300 bgscanidle 250 roam:rssi 7
	roam:rate 5 protmode CTS wme burst roaming MANUAL
```


----------



## SirDice (Sep 10, 2012)

Both networks use the same subnet. It'll be tricky to get them both online at the same time. If both networks have _seperate_ subnets it will be a lot easier.

NB. I advise not to use WEP, it's easily cracked (only takes about 10 minutes). Use WPA2.


----------



## wblock@ (Sep 10, 2012)

Replace the second wireless router and WEP with an Ethernet cable.  Goes faster, more secure, less hassle.


----------



## Heraklit (Sep 10, 2012)

Hi,

thank you for your answers!
I know that WEP can easily be cracked. However, in this case, it doesn't really matter (IMHO). As the WEP-router is at another floor, I am connecting to it by wlan.
Of couse, I can change the subnet-address of my routers. So, what do I have to change to make this scenario work? What configurations? Do I have to setup another wlan interface, i.e. wlan1 at boot-time?

Best regards


----------



## Heraklit (Sep 11, 2012)

Hi,

I have changed the WLAN-router-addresses now:
Router 1 (SSID WLAN): 192.168.1.1
Router 2 (SSID WLAN2): 192.168.2.1

How can I combine these two networks? I just want to access these two routers from my PC at the same time.

Best regards


----------



## wblock@ (Sep 11, 2012)

Heraklit said:
			
		

> Hi,
> 
> thank you for your answers!
> I know that WEP can easily be cracked. However, in this case, it doesn't really matter (IMHO).



It's like having an Ethernet jack on the outside of the building, or in a hallway.  It allows random people onto your network, inside the firewall.  Maybe they won't abuse your systems, or use your network to abuse other systems.  But what reason is there to take that chance?


----------



## Heraklit (Sep 11, 2012)

Hi wblock@,

my problem is not the wep-encryption! The encryption does NOT matter in this case, as I only need the second router to receive some data, which are further protected by password!
But I am wondering how to combine these two networks (see above). Can you give me some advice?

Thank you


----------



## wblock@ (Sep 11, 2012)

It's not just _your_ data that is in danger.  When someone uses your network to launch an attack elsewhere, the authorities will come to see you.  This is not hypothetical.

As far as the original problem, using the second router as a bridge or repeater for the first is a possibility.  Whether it can do that depends on the model and firmware.


----------



## mamalos (Sep 12, 2012)

Heraklit,

if I understood correctly, you have two wireless APs with one wireless NIC each, and one PC with one wireless NIC. All three devices are far enough, so wired interconnection is out of the question.

If that is your case, then the only way I can imagine of not switching from one wireless connection to the other WITHOUT having to obtain a second wireless NIC for your PC (which would allow you to do whatever configuration you wish, but we'll talk about it once you decide to buy one) is to make one AP become a repeater of the other AP (no matter what the direction). In order to do this, as wblock has made clear already, your APs will have to support such a feature (if your one AP could become a client to the other AP and bridge its wireless and wired NIC, then you could achieve the same results). If your APs are of the same brand, they'll probably allow it.


----------



## Heraklit (Sep 13, 2012)

Hi,

in the meantime, I found a solution for my problem:
I activated the repeater-funtion for my wlan-modems. Now, I can access both networks at the same time. But unfortunately, only WEP is supported for this function.

Best regards


----------

