Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: How to connect to wifi on boot?

  1. #1
    Join Date
    Jun 2010
    Beans
    36

    How to connect to wifi on boot?

    Hi, I am running ubuntu 11.10 server, on a home WPA PSK wifi network.

    To connect to the wifi network I type these commands.

    Code:
    sudo ifconfig ra0 up 
    sudo wpa_passphrase NetworkName "Password" > ~/WifiSetup/wpa_supplicant.conf 
    sudo wpa_supplicant -B -Dwext -i ra0 -c ~/WifiSetup/wpa_supplicant.conf 
    sudo dhcpcd ra0
    However I want my server to connect to wifi without me logging in.

    Is there a "right" way of doing this?

    I have tried putting those commands into
    Code:
    /etc/rc.local
    If I do this, the first line works propperly, and ra0 is up, but the rest of the commands don't seem to work.

    Also as the server boots it spends 60 seconds waiting for network info. Ideally I would connect to the wifi network at this point?

    Any Ideas?

    Thank you in advance.

  2. #2

    Re: How to connect to wifi on boot?

    make an .sh script with
    Code:
    #!/bin/bash
    ifconfig ra0 up 
    wpa_passphrase NetworkName "Password" > /absolute/path/to/WifiSetup/wpa_supplicant.conf 
    wpa_supplicant -B -Dwext -i ra0 -c /absolute/path/to/WifiSetup/wpa_supplicant.conf 
    dhcpcd ra0
    chmod 700 the same script.
    Use same script in /etc/rc.local

    HTH
    Windows assumes the user is an idiot.
    Linux demands proof.

  3. #3
    Join Date
    Jun 2010
    Beans
    36

    Re: How to connect to wifi on boot?

    Thanks Habitual,

    It still isn't working...

    here's the script
    /home/john/WifiSetup/ConnectWifi.sh
    Code:
    #!/bin/bash
    ifconfig ra0 up
    wpa_passphrase network "password" > /home/john/WifiSetup/wpa_supplicant.conf
    wpa_supplicant -B -Dwext -i ra0 -c /home/john/WifiSetup/wpa_supplicant.conf
    dhcpcd ra0
    echo " run on $(date)" >> /home/john/WifiSetup/log.txt
    Here's my /etc/rc.local

    Code:
    #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # By default this script does nothing.
    
    # Connect To Wifi John 22Apr11
    sh /home/john/WifiSetup/ConnectWifi.sh
    # End Connect to wifi
    
    exit 0
    I put the echo date command into the script, so I could see when it runs. It is not running automatically.

    but it works if I type
    Code:
    sudo sh /home/john/WifiSetup/ConnectWifi.sh
    Thank you for your help.

  4. #4

    Re: How to connect to wifi on boot?

    /home/john/WifiSetup/ConnectWifi.sh has a "#!/bin/bash" line, then the "sh" in /etc/rc.local
    Code:
    sh /home/john/WifiSetup/ConnectWifi.sh
    should not be necessary.

    Try this to get a Log file of the script's running (only a a temp measure)...

    crontab -e
    Code:
    /home/john/WifiSetup/ConnectWifi.sh >> /home/john/WifiSetup/log.txt 2>&1
    save and reboot and someone smarter than I will be along to help if that still doesn't work.

    Try adding /absolute/path/to/wpa_supplicant and /absolute/path/to/wpa_passphrase in the .sh file
    Last edited by Habitual; April 23rd, 2012 at 10:42 PM.
    Windows assumes the user is an idiot.
    Linux demands proof.

  5. #5
    Join Date
    Jun 2010
    Beans
    36

    Re: How to connect to wifi on boot?

    lol, I like the cron command.

    Turn the server on then it will connect after midnight

    I can see why most servers have an Ethernet connection, but there must be a way of doing it by wifi...

    For the moment I have turned it on, manually connected it to wifi and logged out. It's pretty low power so leaving it on all the time should be OK, but it would be nice to have this fixed so I can turn it off and on whenever I want.

  6. #6
    Join Date
    Apr 2009
    Beans
    5

    Re: How to connect to wifi on boot?

    Quote Originally Posted by john1923 View Post
    Hi, I am running ubuntu 11.10 server, on a home WPA PSK wifi network.

    To connect to the wifi network I type these commands.

    Code:
    sudo ifconfig ra0 up 
    sudo wpa_passphrase NetworkName "Password" > ~/WifiSetup/wpa_supplicant.conf 
    sudo wpa_supplicant -B -Dwext -i ra0 -c ~/WifiSetup/wpa_supplicant.conf 
    sudo dhcpcd ra0
    However I want my server to connect to wifi without me logging in.

    Is there a "right" way of doing this?

    I have tried putting those commands into
    Code:
    /etc/rc.local
    If I do this, the first line works propperly, and ra0 is up, but the rest of the commands don't seem to work.

    Also as the server boots it spends 60 seconds waiting for network info. Ideally I would connect to the wifi network at this point?

    Any Ideas?

    Thank you in advance.
    Hi,
    I'm no expert by any means but, I edited the etc/network/interfaces files following the guide here:
    HTML Code:
    http://prupert.co.uk/2010/06/25/how-to-configure-wireless-wifi-networking-in-ubuntu-via-the-command-line-cli/
    My headless server now connects to my local network via wifi when the server is booted without logging in. Only thing I need to figure out now is how to get the wifi interface to switch off automatically if the server is shutdown!

    Also, I commented out the lines regarding the loopback interface as well (this seemed to be a problem for me, since I don't have any ethernet connection between the server and my router).

    Hope this is of help.

    Cheers,
    Doogs

  7. #7
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    15,537
    Distro
    Kubuntu 20.04 Focal Fossa

    Re: How to connect to wifi on boot?

    Replace "wpa_passphrase" and "wpa_supplicant" with "/usr/bin/wpa_passphrase" and "/sbin/wpa_supplicant" in case there's a path problem.
    Last edited by SeijiSensei; April 26th, 2012 at 02:00 PM.

  8. #8
    Join Date
    Jun 2011
    Location
    The Shadow Gallery
    Beans
    6,770

    Re: How to connect to wifi on boot?

    I just put it in
    Code:
    /etc/network/interfaces
    set it as auto wlan0 (or whatever the iface is)

    And thats it for me anyways.

    Peace
    Backtrack - Giving machine guns to monkeys since 2006
    Kali-Linux - Adding a grenade launcher to the machine guns since 2013

  9. #9
    Join Date
    Aug 2005
    Location
    South Carolina, USA
    Beans
    25,442
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: How to connect to wifi on boot?

    Quote Originally Posted by haqking View Post
    I just put it in
    Code:
    /etc/network/interfaces
    set it as auto wlan0 (or whatever the iface is)

    And thats it for me anyways.

    Peace
    That's what I'd do, too.
    Code:
    auto lo
    iface lo inet loopback
    
    auto ra0
    iface ra0 inet dhcp
        wpa-ssid NetworkName
        wpa-psk Password
    No rc.local, no scripts, no fuss.
    "Oh, Ubuntu, you are my favorite Linux-based operating system" --Dr. Sheldon Cooper, Ph.D., Sc.D.

  10. #10
    Join Date
    Jun 2011
    Location
    The Shadow Gallery
    Beans
    6,770

    Re: How to connect to wifi on boot?

    Quote Originally Posted by chili555 View Post
    That's what I'd do, too.
    Code:
    auto lo
    iface lo inet loopback
    
    auto ra0
    iface ra0 inet dhcp
        wpa-ssid NetworkName
        wpa-psk Password
    No rc.local, no scripts, no fuss.
    +1

    Totally agree
    Backtrack - Giving machine guns to monkeys since 2006
    Kali-Linux - Adding a grenade launcher to the machine guns since 2013

Page 1 of 2 12 LastLast

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
  •