Wireless - Changing SSID

Hello. My wireless is successfully installed, however I have run into a sort of problem. Around the web, I see people just using
Code:
ifconfig wlan0 ssid "bla bla bla"

To change SSID's however, whenever I do that it keeps the previous inet and also gets a new one from the new SSID, the problem is then I have 2 inet addresses, I would of thought since there on different subnets this wouldn't of mattered but apparently it does (and I can't connect to the new SSID unless all other inet addresses are cleared).
Code:
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 00:24:2c:01:39:bd
[B]inet 192.168.2.3 netmask 0xffffff00 broadcast 192.168.2.255
inet 192.168.1.14 netmask 0xffffff00 broadcast 192.168.1.255[/B]
media: IEEE 802.11 Wireless Ethernet OFDM/36Mbps mode 11g
status: associated
ssid xxxxx channel 3 (2422 MHz 11g) bssid 00:21:27:dc:10:08
regdomain 106 indoor ecm authmode WPA2/802.11i privacy OFF txpower 20
bmiss 7 scanvalid 60 bgscan bgscanintvl 300 bgscanidle 250 roam:rssi 7
roam:rate 5 protmode CTS wme burst

The only way I can connect to the internet through the new different SSID, is to clear all my inet and only have a single inet present, and restart networking.. But this code below is not very good I'm sure, as it only work sometimes (at least some times is better than no times). The problem with the below is, (the inet issues is sorted out, and I clear inet before changing SSID, however the below script I created sometimes can't find the channel for the SSID and will continue jumping even when it does land on it..
- Also if I just clear inet (without network restart) and leave it as that, then it doesn't get any new inet from any new SSID I join..

Thus I have 2 questions:
(Q) Is there any better method for switching between wireless [SSIDs] and wired.
(Q) Also how do I disable autoselect network, when I enable wlan0. I'd rather manually connect to which ever SSID, when I enable it.

myCrappyScript [I haven't automated it because I'm still testing]

Code:
-- eth0 [To use wired..]
/etc/rc.d/wpa_supplicant stop wlan0
ifconfig wlan0 down
/etc/rc.d/netif restart
ifconfig wlan0 down

-- wlan [UNPLUG wire]
ifconfig wlan0 up [color="DarkRed"]#for when I first start, I need to bring wlan0 up[/color]
ifconfig wlan0 inet -alias [color="DarkRed"]#clear inet addresses[/color]
/etc/rc.d/netif restart [color="DarkRed"]#restart networking, without eth, since wire not in[/color]
/etc/rc.d/wpa_supplicant stop wlan0 [color="DarkRed"]#stop it in case it's already running[/color]
/etc/rc.d/wpa_supplicant start wlan0 [color="DarkRed"]#start it[/color]
ifconfig wlan0 down [color="DarkRed"]#bring it down, before it auto connects >:([/color]

ifconfig wlan0 ssid "SSIDnameblabla" [color="DarkRed"]#choose SSID[/color]
ifconfig wlan0 up [color="DarkRed"]#bring it UP[/color]
dhclient wlan0 [color="DarkRed"]#request IP[/color]
 
Anyone have a better way of switching SSID (without adding it to /etc/wpa_supplicant.conf .. since I use different SSIDs quite a lot, uni, public wifis etc)? :(
 
astralfx said:
To change SSID's however, whenever I do that it keeps the previous inet and also gets a new one from the new SSID, the problem is then I have 2 inet addresses, I would of thought since there on different subnets this wouldn't of mattered but apparently it does (and I can't connect to the new SSID unless all other inet addresses are cleared).

Hello,
The problem is that the packet that leaves wlan0 interface has source address set to first ip address. So the packet gets to destination but can't get back.
I tried to delete previously assigned ip with
Code:
#ifconfig wlan0 delete 192.168.1.105
,but the problem is that the previously assigned default gateway by DHCP stays in routing table, easily checked with
Code:
#netstat -rf inet

Therefore if I have to make switch, I found that the easiest way is to simply destroy wlan0 interface and make a new one avoiding any possible pitfalls. I'm not sure if there's quicker solution.
So simply
Code:
#ifconfig wlan0 destroy

As for not getting automatically associated with SSID, simply don't have any configuration in rc.conf. Then, when needed create your own wlan0 interface
Code:
#ifconfig wlan0 create wlandev ath0 up
using your own adapter.
Then associate with SSID, noting that the file specified with '-c' can be any file.
Code:
#wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf
Then run
Code:
#dhclient wlan0

Like I said if I need to change to different network I simply destroy wlan0 interface, rinse and repeat. I'm not sure if there's better way, but I never had to change to different numbers of SSIDs in such a short time.
 
Hello, unfortunately it doesn't work.

The first wireless network I join works, however when I change SSID, it just keeps changing channel when trying to find the SSID (and never lands on it).. Thus dhclient wlan0 doesn't work either.

Though when I switch SSID, I get a change in the netstat -r (so at least it clears the old path) .. (this is new router path, router = 192.168.2.1 .. I don't know what the .2 is)
Code:
default            192.168.2.1        UGS         0    30439    re0
localhost          link#3             UH          0       50    lo0
192.168.2.0        link#2             U           2     1220    re0
192.168.2.2        link#2             UHS         0        0    lo0

Here is the ifconfig for wlan0
Code:
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
 ether 00:24:2c:01:39:bd
 media: IEEE 802.11 Wireless Ethernet autoselect (autoselect)
 status: no carrier
 ssid "xxxxxxxxx" channel 9 (2452 MHz 11g)
 regdomain 106 indoor ecm authmode OPEN privacy OFF txpower 20 bmiss 7
 scanvalid 60 bgscan bgscanintvl 300 bgscanidle 250 roam:rssi 7
 roam:rate 5 protmode CTS wme burst bintval 0
(and it continues to change channels, without finding the SSID. However, this is not always the case. Sometimes it will stop changing channels and find the correct one, however still no internet access )

However this is very weird. So there are 2 wireless points which I try to connect to. My home router and public Wifi.

My home router works when I do wpa_supplicant -i wlan0 -c etc/wpa_supplicant.conf. And it generates me an IP:
Code:
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPNAK from 192.168.2.1
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5
DHCPOFFER from 192.168.2.1
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPACK from 192.168.2.1
bound to 192.168.2.3 -- renewal in 840735948 seconds.
Code:
inet 192.168.2.3 netmask 0xffffff00 broadcast 192.168.2.255
However the problem remains, I still can't access to the internet, even pinging the router 192.168.2.1 fails.

Now the problem with the Publifi wifi is: first to get a working IP via dhclien wlan0, I MUST NOT use wpa_supplicant. For some reason, the connection only works when there is no encryption (when I do ifconfig wlan0 list scan the public wifi only has ATH flag), I can ping the 192.168.1.1 and get a respone, but the problem is I still can't connect to the internet (can't browse sites, can't ping any websites
Code:
ping: cannot resolve [url]www.google.com:[/url] Host name lookup  failure]

And if I do netstat -r

Code:
Destination        Gateway            Flags    Refs      Use  Netif Expire   
default            192.168.2.1        UGS         0    30439    re0   
localhost          link#3             UH          0       50    lo0
192.168.1.0        link#4             U           0        2  wlan0
192.168.1.10       link#4             UHS         0        0    lo0
192.168.2.0        link#2             U           2     1461    re0
192.168.2.2        link#2             UHS         0        0    lo0

Sorry this is probably a big chunk to read through, I tried to give as much info as possible to help you guys help me.

[Here's my /etc/wpa_supplicant.conf if you may want to look at it.]
Code:
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=wheel

eapol_version=1
ap_scan=1
fast_reauth=1
network={
        ssid="xxxxxxx"
        key_mgmt=WPA-PSK
        pairwise=TKIP
        group=TKIP
        #scan_ssid=1
        psk="xxxxxxx"
        priority=1
}


network={
        ssid="TP-LINK"
        key_mgmt=NONE
        wep_key0=0a13aafcde
        wep_key1=0x02030405
        wep_key2="1234567890123"
        wep_tx_keyidx=0
        priority=2

}
 
Back
Top