LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   connecting to a wireless network via command line (https://www.linuxquestions.org/questions/linux-newbie-8/connecting-to-a-wireless-network-via-command-line-824948/)

greplinux 08-08-2010 12:53 PM

connecting to a wireless network via command line
 
Hi,

I am trying to write a script to connect my system with a wireless network. The following were the commands I tried for the same:

Quote:


#>> ifconfig wlan0 up

#>> iwlist wlan0 scan
wlan0 Scan completed :
Cell 01 - Address: 00:36:0E:10:63:53
Channel:11
Frequency:2.462 GHz (Channel 11)
Quality=33/70 Signal level=-77 dBm
Encryption key:on
ESSID:"MYNETWORK"
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s
24 Mb/s; 36 Mb/s; 54 Mb/s
Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 48 Mb/s
Mode:Master

#>> iwconfig wlan0 essid MYNETWORK key s:mykey


Then I ran dhclient wlan0 for which i got an message saying that dhclient is already running. so i killed that and ran 'dhclient wlan0' which eventually failed.

Can you guys help me in this?

I am not good at anything particularly with network. If this is a dumb question please ...

I am using Fedora 12 with Hp pavilion laptop.

Thanks

Andrew Benton 08-08-2010 07:13 PM

I would suggest that you disable encryption on your router at first. Once you have connected, then you should look into how to use wpa_supplicant to connect to a password protected router. For what it's worth, these commands allow me to connect this netbook to my router:
Code:

ip addr add 192.168.1.4 dev wlan0
ip link set wlan0 up
wpa_supplicant -B -c/etc/wpa_supplicant.conf -iwlan0 -Dwext
ip route add 192.168.1.1 dev wlan0
ip route add default via 192.168.1.1 dev wlan0

As you see I don't use dhcpd, I use static addresses on my LAN. The passwords go in /etc/wpa_supplicant.conf - read the man page to find out more.

Shadow_7 08-08-2010 08:31 PM

I do a fully manual non-DHCP connection on my home network.

Code:

wireless_interface=wlan0
CURRENT_IP=192.168.2.7
CURRENT_GATEWAY=192.168.2.1
MTU=1492
ESSID="SOMENAME"
KEY="FFFF-FFFF-FFFF-FFFF-FFFF-FFFF-FF"

  iwconfig  $wireless_interface  power all
  iwconfig  $wireless_interface  txpower auto
  iwconfig  $wireless_interface  rate auto
  iwconfig  $wireless_interface  channel 6
  iwconfig  $wireless_interface  essid $ESSID
  iwconfig  $wireless_interface  mode "Ad-Hoc"
  iwconfig  $wireless_interface  key restricted $KEY
  ifconfig  $wireless_interface  $CURRENT_IP netmask 255.255.255.0 up
  ifconfig  $wireless_interface  mtu $MTU
  route add default gw $CURRENT_GATEWAY

But that's WEP encryption. And Ad-Hoc seems to be the only mode that works with my wireless drivers.

When connecting to DHCP networks over wireless I often have to set a few of the things like channel, rate, essid, and mode before running dhclient3. Sometimes I even have to set an IP address for myself before it actually works.

Something like this for the local McD's, before I realized you had to PAY for access, but CAN'T pay IN STORE.

Code:

f_WIRELESS_DHCP() {
  DHCP_CHANNEL=1
  DHCP_RATE=11
  DHCP_KEY=off
  DHCP_MODE=Managed
  DHCP_ESSID=Wayport_Access
  iwconfig $wireless_interface essid $DHCP_ESSID
  iwconfig $wireless_interface mode $DHCP_MODE
  iwconfig $wireless_interface key $DHCP_KEY
  iwconfig $wireless_interface channel $DHCP_CHANNEL
  echo "# dhclient3 $wireless_interface -s $DHCP_ESSID"
  dhclient3 $wireless_interface -s $DHCP_ESSID
}
f_WIRELESS_DHCP

But ndiswrapper isn't the most capable driver option out there IMO.

greplinux 08-09-2010 11:24 PM

Hi Guys,

As I said, I am nobody in networking. I appreciate your response,Still I didnt get anything :-).

Will google with your responses. Thank you guys.

Thanks,


All times are GMT -5. The time now is 09:54 PM.