Results 1 to 5 of 5

Thread: Configure wireless from commandline

  1. #1
    Join Date
    Jan 2008
    Beans
    28
    Distro
    Ubuntu 7.04 Feisty Fawn

    Configure wireless from commandline

    How can we configure a wireless network from commandline in Ubuntu?

    I understand iwlist will give us the list of access points.

    Next using iwconfig it is possible to connect to a wireless network without network manager. Could you please help with details of the step to connect to a wireless network using commandline?

  2. #2
    Join Date
    Aug 2005
    Location
    South Carolina, USA
    Beans
    24,518
    Distro
    Ubuntu Development Release

    Re: Configure wireless from commandline

    First, it is difficult to do with Network Manager working or even installed. If you have NM removed, please read on!

    Confirm your wireless card has a driver associated with it. Is there a wireless interface in iwconfig? If so, find the exact name of your access point with:
    Code:
    sudo iwlist wlan0 scan
    Substitute your wireless interface, if it's not wlan0. You will get a result similar to this:
    wlan0 Scan completed :
    Cell 01 - Address: 99:24:56:2Z:D7:89
    Channel:1
    Frequency:2.412 GHz (Channel 1)
    Quality=65/70 Signal level=-45 dBm
    Encryption key:on
    ESSID:"mylilrouter"
    Ask your wireless interface to associate with the access point:
    Code:
    sudo iwconfig wlan0 essid mylilrouter
    If there is any encryption, supply those details. Here is an example for WEP:
    Code:
    sudo iwconfig wlan0 key 0123456abcd
    Now ask for an IP address:
    Code:
    sudo dhclient wlan0
    WPA encryption is a bit more complex.

    You can set your details in /etc/network/intefaces:
    Code:
    auto lo
    iface lo inet loopback
    
    auto wlan0
    iface wlan0 inet dhcp
    wireless-essid mylilrouter
    wireless-key 0123456abcd
    
    #auto eth0
    iface eth0 inet dhcp
    "Oh, Ubuntu, you are my favorite Linux-based operating system" --Dr. Sheldon Cooper, Ph.D., Sc.D.

  3. #3
    Join Date
    Jan 2008
    Beans
    28
    Distro
    Ubuntu 7.04 Feisty Fawn

    Re: Configure wireless from commandline

    Hello,

    Thank you very much for the response.

    I tried the above steps.. but the DHCP client did not run successful.

    I use WPA Personal encryption, so I tried editing the /etc/network/interfaces file mentioned above. Should we give the key in hexadecimal value? I gave as normal text:

    wireless-key MY_KEY_AS_TEXT


    Is this correct?

  4. #4
    Join Date
    Aug 2005
    Location
    South Carolina, USA
    Beans
    24,518
    Distro
    Ubuntu Development Release

    Re: Configure wireless from commandline

    I use WPA Personal encryption,
    Remember I said WPA is a bit more complex? Please see: http://ubuntuforums.org/showthread.php?t=318539
    "Oh, Ubuntu, you are my favorite Linux-based operating system" --Dr. Sheldon Cooper, Ph.D., Sc.D.

  5. #5
    Join Date
    Jul 2010
    Beans
    9

    Re: Configure wireless from commandline

    Many thanks to Chili555 for this fix to connect wireless from the command line. Uninstalling the network-manager package did the trick. With network-manager installed and the NetworkManager process running in the background, all my configuration commands had no effect or resulted in crazy output.

    My /etc/network/interfaces file:
    Code:
    auto lo
    iface lo inet loopback
    
    iface wlan0 inet dhcp
    wireless-essid linksys
    wireless-key xxxx-xxxx-xxxx
    wireless-mode Managed
    auto wlan0
    On this router it turns out I have to write the WEP key with dashes after every four characters. Was warned about that trick in this helpful wifi doc:
    https://help.ubuntu.com/community/Wi...eShootingGuide

    and iwconfig showed the key formated that way when network manager was running the wifi.)

    My command line commands:

    Code:
    sudo apt-get remove network-manager
    sudo invoke-rc.d networking restart
    iwlist wlan0 scan
    sudo iwconfig wlan0 essid "linksys" mode Managed key xxxx-xxxx-xxxx
    sudo dhclient wlan0
    I don't know if the mode Managed was necessary but many tutorials included a mode option and iwconfig had mode Managed when NetworkManager was running it.

    Anyway much simpler than many confusing older "ifupdown" methods from old documentation! Thanks again to Chili.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •