# Can not connect to Wireless LAN.



## bhargava (Mar 5, 2011)

Hi,

I am unable to connect to wireless networks. I have my wireless driver loaded and is showing the wireless devices available. 


```
%uname -a
FreeBSD mybox.hsd1.ca.comcast.net. 8.2-RELEASE FreeBSD 8.2-RELEASE #0: 
Fri Feb 18 02:24:46 UTC 2011     root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

% pciconf -lv | grep -i broadcom
    vendor     = 'Broadcom Corporation'
    device     = 'Broadcom Corporation Dell Wireless 1390 WLAN Mini-PCI Card (BCM4311)'
```


```
%ifconfig bwn0
bwn0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 2290
        ether 00:1a:73:98:8c:94
        media: IEEE 802.11 Wireless Ethernet autoselect mode 11g
        status: associated


%ifconfig wlan0
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:1a:73:98:8c:94
        inet6 fe80::21a:73ff:fe98:8c94%wlan0 prefixlen 64 scopeid 0x6 
        inet 192.168.1.107 netmask 0xffffff00 broadcast 192.168.1.255
        nd6 options=3<PERFORMNUD,ACCEPT_RTADV>
        media: IEEE 802.11 Wireless Ethernet OFDM/48Mbps mode 11g
        status: associated
        ssid Espresso channel 6 (2437 MHz 11g) bssid 00:23:69:b8:92:52
        country US authmode WPA2/802.11i privacy ON deftxkey UNDEF
        AES-CCM 2:128-bit AES-CCM 3:128-bit txpower 30 bmiss 7 scanvalid 450
        bgscan bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5
        protmode CTS wme roaming MANUAL
```
Here is the scan list, need to connect to Espresso.

```
% ifconfig wlan0 list scan
SSID/MESH ID    BSSID              CHAN RATE   S:N     INT CAPS
SugarZSwt       c0:3f:0e:2f:76:2e    1   54M -45:-67  100 EP   WPS WPA WME
[B][U]Espresso        00:23:69:b8:92:52    6   54M -42:-67  100 EP   RSN WPS[/U][/B]
```

Can not ping to google.com or externel IP addresses. 

```
ping -c3 google.com
ping: cannot resolve google.com: Host name lookup failure

%ping -c3 74.125.224.16
PING 74.125.224.16 (74.125.224.16): 56 data bytes
ping: sendto: No route to host
ping: sendto: No route to host
ping: sendto: No route to host

--- 74.125.224.16 ping statistics ---
3 packets transmitted, 0 packets received, 100.0% packet loss
```

Can ping with in the LAN.

```
%ping -c3 127.0.0.1
PING 127.0.0.1 (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.036 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.040 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.027 ms

--- 127.0.0.1 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.027/0.034/0.040/0.005 ms

%ping -c3 192.168.1.101
--- 192.168.1.101 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.042/0.042/0.043/0.000 ms

%ping -c3 192.168.1.1
PING 192.168.1.1 (192.168.1.1): 56 data bytes
--- 192.168.1.1 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.714/0.793/0.938/0.103 ms
```

Here are some file contents which I think will be useful. Let me know if any other info is needed. 

```
%cat /etc/resolv.conf 
search hsd1.ca.comcast.net.
nameserver 68.87.76.182
nameserver 68.87.78.134

%hostname 
mybox.hsd1.ca.comcast.net.

%cat /etc/wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=wheel
ap_scan=1
network={
        ssid="Espresso"
        psk="ABCDEFGHIJ" (changed of-course :-))
        }


%cat /etc/hosts.allow
#
# hosts.allow access control file for "tcp wrapped" applications.
# $FreeBSD: src/etc/hosts.allow,v 1.23.10.1.6.1 2010/12/21 17:09:25 kensmith Exp $
#
# NOTE: The hosts.deny file is deprecated.
#       Place both 'allow' and 'deny' rules in the hosts.allow file.
#       See hosts_options(5) for the format of this file.
#       hosts_access(5) no longer fully applies.

#        _____                                      _          _
#       | ____| __  __   __ _   _ __ ___    _ __   | |   ___  | |
#       |  _|   \ \/ /  / _` | | '_ ` _ \  | '_ \  | |  / _ \ | |
#       | |___   >  <  | (_| | | | | | | | | |_) | | | |  __/ |_|
#       |_____| /_/\_\  \__,_| |_| |_| |_| | .__/  |_|  \___| (_)
#                                          |_|
# !!! This is an example! You will need to modify it for your specific
# !!! requirements!


# Start by allowing everything (this prevents the rest of the file
# from working, so remove it when you need protection).
# The rules here work on a "First match wins" basis.
ALL : ALL : allow

# Wrapping sshd(8) is not normally a good idea, but if you
# need to do it, here's how
#sshd : .evil.cracker.example.com : deny

# Protect against simple DNS spoofing attacks by checking that the
# forward and reverse records for the remote host match. If a mismatch
# occurs, access is denied, and any positive ident response within
# 20 seconds is logged. No protection is afforded against DNS poisoning,
# IP spoofing or more complicated attacks. Hosts with no reverse DNS
# pass this rule.
ALL : PARANOID : RFC931 20 : deny

# Allow anything from localhost.  Note that an IP address (not a host
# name) *MUST* be specified for rpcbind(8).
ALL : localhost 127.0.0.1 : allow
# Comment out next line if you build libwrap without IPv6 support.
ALL : [::1] : allow
#ALL : my.machine.example.com 192.0.2.35 : allow

# To use IPv6 addresses you must enclose them in []'s
#ALL : [fe80::%fxp0]/10 : allow
#ALL : [fe80::]/10 : deny
#ALL : [2001:db8:2:1:2:3:4:3fe1] : deny
#ALL : [2001:db8:2:1::]/64 : allow

# Sendmail can help protect you against spammers and relay-rapers
sendmail : localhost : allow
#sendmail : .nice.guy.example.com : allow
#sendmail : .evil.cracker.example.com : deny
sendmail : ALL : allow

# Exim is an alternative to sendmail, available in the ports tree
exim : localhost : allow
#exim : .nice.guy.example.com : allow
#exim : .evil.cracker.example.com : deny
exim : ALL : allow

# Rpcbind is used for all RPC services; protect your NFS!
# (IP addresses rather than hostnames *MUST* be used here)
#rpcbind : 192.0.2.32/255.255.255.224 : allow
#rpcbind : 192.0.2.96/255.255.255.224 : allow
rpcbind : ALL : deny

# NIS master server. Only local nets should have access
# (Since this is an RPC service, rpcbind needs to be considered)
ypserv : localhost : allow
#ypserv : .unsafe.my.net.example.com : deny
#ypserv : .my.net.example.com : allow
ypserv : ALL : deny

# Provide a small amount of protection for ftpd
ftpd : localhost : allow
#ftpd : .nice.guy.example.com : allow
#ftpd : .evil.cracker.example.com : deny
ftpd : ALL : allow

# You need to be clever with finger; do _not_ backfinger!! You can easily
# start a "finger war".
fingerd : ALL \
        : spawn (echo Finger. | \
         /usr/bin/mail -s "tcpd\: %u@%h[%a] fingered me!" root) & \
        : deny

# The rest of the daemons are protected.
ALL : ALL \
        : severity auth.info \
        : twist /bin/echo "You are not welcome to use %d from %h."
```

How do I resolve this issue and connect to the internet. 

Thank you.


----------



## wblock@ (Mar 5, 2011)

Looks like it just needs a DHCP lease.  That can be done manually:
`# dhclient wlan0`

or through /etc/rc.conf on startup:

```
wlans_bw0="wlan0"
ifconfig_wlan0="SYNCDHCP WPA"
```


----------



## jalla (Mar 5, 2011)

Add a default route.


----------



## bhargava (Mar 5, 2011)

wblock said:
			
		

> Looks like it just needs a DHCP lease.  That can be done manually:
> `# dhclient wlan0`
> 
> or through /etc/rc.conf on startup:
> ...



Thank you. adding SYNCDHCP to /etc/rc.conf and rebooting worked. While a simple `# dhclient wlan0` did not work. Can you please tell me why or point to where I can learn the reason. 

Also earlier I had only _DHCP_ for _ifconfig_wlan0_ in /etc/rc.conf but  it did not work, changing to _SYNCDHCP_ it worked. What is the difference between these two options. 



			
				jalla said:
			
		

> Add a default route.


Thanks for the reply. I got it working by doing the change (above). I was just curious to know how to add a default route. Any pointers regarding this is appreciated. 

Thank you.


----------



## wblock@ (Mar 5, 2011)

bhargava said:
			
		

> Thank you. adding SYNCDHCP to /etc/rc.conf and rebooting worked. While a simple `# dhclient wlan0` did not work. Can you please tell me why or point to where I can learn the reason.



wpa_supplicant(8) was started and you were already associated to the access point, so I... don't know.



> Also earlier I had only _DHCP_ for _ifconfig_wlan0_ in /etc/rc.conf but  it did not work, changing to _SYNCDHCP_ it worked. What is the difference between these two options.




```
ifconfig_wlan0="DHCP"
```
 runs dhclient(8) in the background when the system is starting.  This speeds up booting, but other network settings may be run before a DHCP lease is obtained.


```
ifconfig_wlan="SYNCDHCP"
```
 runs dhclient(8) synchronously.  The startup has to wait until a lease is obtained before continuing.  That can take longer, but is more likely to work.

This is all just automation.  The command-line equivalent of the rc.conf version is (assuming I haven't forgotten anything since the last time):


```
# kldload bwn_v4_ucode
# kldload if_bwn
# ifconfig wlan0 create wlandev bwn0
# wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf
# dhclient wlan0
```

dhclient(8) assigns a default route.  You could instead set a static address with ifconfig(8) and set a default route with route(8).


----------



## bhargava (Mar 5, 2011)

Thank you  wblock, for explaining.


----------

