Have Ubuntu auto-connect to wireless AP without logging in

13,597

Solution 1

Depending on the physical security of the box, you could configure gdm to auto-login using an unprivileged user account that has access to the wireless device. Then Network Manager would handle all of the auto-reconnection issues.

This is configured under System | Administration | Login Window | Security

Solution 2

First, it's worth knowing that a default Ubuntu Desktop installation uses a piece of software named NetworkManager to manage the network.

The advantage of that is that it's very useful on laptops where you move around among different networks a lot, since it makes it very easy to find and connect to wireless networks.

The drawback is that it seems you must be logged in to get a network connection, and that's obviously less than optimal for a server.

Instead of running NetworkManager, the way to go is to configure your network settings in the file /etc/network/interfaces, a file which will be read at startup. I'm a bit uncertain on how to disable networkmanager, but I think it will detect that an interface has already been configured and stay away from it when you login.

Anyway, assuming that your network card is named ath0, you need to add something like the example below to /etc/network/interfaces:

auto ath0
iface ath0 inet static 
    address 10.20.30.40
    netmask 255.255.255.0
    gateway 10.20.30.1
    wireless-essid ESSID
    wireless-ap 00:60:1D:01:23:45
    wireless-key 0123-4567-89

It's been a while since I tested doing this, so the above is untested. The following manpages should be of help:

  • interfaces(5)
  • iwconfig(8)
  • wireless(7)

Solution 3

How can I make NetworkManager connect to a network before I login?

On version 0.7.1 or later edit the profile of the connection you with to start prior to login and select the box in the bottom left "Available to all users"

Solution 4

Use wpa_supplicant to manage your wifi connection.

You do not have to be using WPA for this. It will work with wep or even an open wireless network. When your AP is rebooted or loses power, wpa_supplicant will start scanning for available APs and check if one of them matches the config file.

Have a look at this blog post on how to setup wpa_supplicant.

Share:
13,597

Related videos on Youtube

dragonmantank
Author by

dragonmantank

Love to program in PHP, starting to look into Python and C# as well.

Updated on September 17, 2022

Comments

  • dragonmantank
    dragonmantank almost 2 years

    We have an ubuntu box set up to do some monitoring but due to the placement are unable to run CAT5 to the box itself. I have an Atheros PCI card that works great as long as someone is logged into Gnome and it doesn't disconnect from the AP during that time.

    Is there a way to have Ubuntu connect to the AP during boot, and always reconnect if it finds a signal from a specified AP? The box would have a static IP and only connecting to a specific AP using WEP.

  • dragonmantank
    dragonmantank about 15 years
    It's not my preferred action, but its what I ended up having to do. Network Manager still doesn't automatically reconnect for whatever reason, but it at least works at 'boot' now.