wlan0 after reboot not working - but works fine every time if manually setup

A lot of related posts seem to be hardware specific or due to hardware issues, which I don't appear to be having, since everything works fine so long as I setup wlan0 after boot and after logging in.

I'm a n00b to ubuntu server, so I'm hoping there's just a configuration issue at play here.

I simply want the wireless to connect after boot so I can ssh into the box and work remotely all the time.

If I setup /etc/network/interfaces with wlan0, either with static settings or dhcp, then the card appears to be setup with an IP address (according to ifconfig), but ip addr says wlan0 is DOWN, and commands to ask it to come up don't seem to do anything.

If I rem out the settings in /etc/network/interfaces, reboot, login on the actual machine, ip addr shows wlan0 to be UP, then I run sudo dhclient wlan0 then everything is fine.

An answer here: No Wi-Fi after system reboot implied there could be timing issues during boot that are at play, and that seems to fit, but I'm not sure how to troubleshoot that.

Here's /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
auto wlan0
iface wlan0 inet static
address 192.168.1.13
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1
pre-up /etc/init.d/wpa.sh start
post-down /etc/init.d/wpa.sh stop

I tried chili555's suggestions. The changes to /etc/network/interfaces didn't affect anything. After boot, ip addr shows wlan0 to be DOWN, and various commands listed here to try and bring it up don't work.

I couldn't capture all of the output from sudo ifup -v wlan0 even with various 2>&1 >file redirects, the parts not captured was from wpa_supplicant. It didn't indicate any errors that I could tell, here's the rest from the sudo ifup command (the sudo ifdown seemed to work fine with little output):

OK
ip addr add 192.168.1.13/255.255.255.0 broadcast 192.168.1.255 dev wlan0 label wlan0
ip link set dev wlan0 up ip route add default via 192.168.1.1 dev wlan0
run-parts --verbose /etc/network/if-up.d
run-parts: executing /etc/network/if-up.d/000resolvconf
run-parts: executing /etc/network/if-up.d/ethtool
run-parts: executing /etc/network/if-up.d/ntpdate
run-parts: executing /etc/network/if-up.d/openssh-server
run-parts: executing /etc/network/if-up.d/upstart
run-parts: executing /etc/network/if-up.d/wpasupplicant

But ip addr afterwards is still DOWN and I'm unable to connect. I tried sudo ip link set wlan0 up (with and without the dev bit), also sudo ifconfig wlan0 up - nothing seemed to change anything.

Running sudo dhclient ip just hangs a while then times out. There's already a static ip assigned, dunno if that would matter.

When I leave wlan0 unconfigured in /etc/network/interfaces then restart, here's what ip addr shows after boot:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever
2: p12p1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether f0:4d:a2:4c:6a:c4 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:21:6a:c7:12:38 brd ff:ff:ff:ff:ff:ff inet6 fe80::221:6aff:fec7:1238/64 scope link valid_lft forever preferred_lft forever

then running sudo dhclient wlan0 connects everything and here's the subsequent ip addr output:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever
2: p12p1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether f0:4d:a2:4c:6a:c4 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:21:6a:c7:12:38 brd ff:ff:ff:ff:ff:ff inet 192.168.1.13/24 brd 192.168.1.255 scope global wlan0 valid_lft forever preferred_lft forever inet6 fe80::221:6aff:fec7:1238/64 scope link valid_lft forever preferred_lft forever
1

2 Answers

Test this:

Write a script, suppose wifi-on.sh, in /etc/init.d/

 sudo -i nano /etc/init.d/wifi-on.sh

With this content, or that you use to enable wlan0:

!/bin/bash
ifconfig wlan0 up
iwconfig wlan0 essid <ESSID>
iwconfig wlan0 key s:<password_wireless>
dhclient wlan0

You give execute permissions and add to system startup:

sudo -i
chmod 755 /etc/init.d/wifi-on.sh
update-rc.d wifi-on.sh defaults

I'm not at all sure what your pre-up and post-down declarations are doing. I suggest you amend the file to:

auto lo
iface lo inet loopback
auto wlan0
iface wlan0 inet static
address 192.168.1.13
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1
wpa-essid your_network
wpa-psk your_key

Please be sure the address you select is outside the range of addresses used by the DHCP server in the router so there is no collision. Restart the interface to see if it connects or complains about an error:

sudo ifdown wlan0 && sudo ifup -v wlan0

Check:

ifconfig
ping -c3 

chrismo: These changes to /etc/network/interfaces didn't affect anything. After boot, ip addr shows wlan0 to be DOWN, and various commands listed here to try and bring it up don't work.

I couldn't capture all of the output from sudo ifup -v wlan0 even with various 2>&1 >file redirects, the parts not captured was from wpa_supplicant. It didn't indicate any errors that I could tell, here's the rest from the sudo ifup command (the sudo ifdown seemed to work fine with little output):

OK
ip addr add 192.168.1.13/255.255.255.0 broadcast 192.168.1.255 dev wlan0 label wlan0
ip link set dev wlan0 up ip route add default via 192.168.1.1 dev wlan0
run-parts --verbose /etc/network/if-up.d
run-parts: executing /etc/network/if-up.d/000resolvconf
run-parts: executing /etc/network/if-up.d/ethtool
run-parts: executing /etc/network/if-up.d/ntpdate
run-parts: executing /etc/network/if-up.d/openssh-server
run-parts: executing /etc/network/if-up.d/upstart
run-parts: executing /etc/network/if-up.d/wpasupplicant

But ip addr afterwards is still DOWN and I'm unable to connect. I tried sudo ip link set wlan0 up (with and without the dev bit), also sudo ifconfig wlan0 up - nothing seemed to change anything.

Running sudo dhclient ip just hangs a while then times out. There's already a static ip assigned, dunno if that would matter.

When I leave wlan0 unconfigured in /etc/network/interfaces then restart, here's what ip addr shows after boot:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever
2: p12p1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether f0:4d:a2:4c:6a:c4 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:21:6a:c7:12:38 brd ff:ff:ff:ff:ff:ff inet6 fe80::221:6aff:fec7:1238/64 scope link valid_lft forever preferred_lft forever

then running sudo dhclient wlan0 connects everything and here's the subsequent ip addr output:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever
2: p12p1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether f0:4d:a2:4c:6a:c4 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:21:6a:c7:12:38 brd ff:ff:ff:ff:ff:ff inet 192.168.1.13/24 brd 192.168.1.255 scope global wlan0 valid_lft forever preferred_lft forever inet6 fe80::221:6aff:fec7:1238/64 scope link valid_lft forever preferred_lft forever
2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like