WiFi frequently disconnects on Ubuntu 16.04 and is not working in 14.04 [duplicate]

I have installed Ubuntu 15.04 on my laptop with RTL8723BE Wi-fi card. But it is always disconnecting from network. I have tried echo "options rtl8723be fwlps=N ips=N" | sudo tee /etc/modprobe.d/rtl8723be.conf but that didn't helped. What can I do to prevent the wifi from disconnecting? If I upgrade to kernel 4.X, will it help?

~$ lspci -knn | grep Net -A2

09:00.0 Network controller [0280]: Realtek Semiconductor Co., Ltd. RTL8723BE PCIe Wireless Network Adapter [10ec:b723]
    Subsystem: Hewlett-Packard Company Device [103c:2231]
    Kernel driver in use: rtl8723be


~$ rfkill list
0: hci0: Bluetooth
    Soft blocked: yes
    Hard blocked: no
1: phy0: Wireless LAN
    Soft blocked: no
    Hard blocked: no


~$ ifconfig && iwconfig && route -n && ping -c 1 google.com
eth0      Link encap:Ethernet  HWaddr 38:63:bb:cd:4a:7e  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:3 errors:0 dropped:0 overruns:0 frame:0
          TX packets:53 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:752 (752.0 B)  TX bytes:8445 (8.4 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:3870 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3870 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:314613 (314.6 KB)  TX bytes:314613 (314.6 KB)

wlan0     Link encap:Ethernet  HWaddr c0:38:96:6d:c4:83  
          inet addr:192.168.1.205  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::c238:96ff:fe6d:c483/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:15240 errors:0 dropped:0 overruns:0 frame:0
          TX packets:14627 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:14410285 (14.4 MB)  TX bytes:2192744 (2.1 MB)

eth0      no wireless extensions.

wlan0     IEEE 802.11bgn  ESSID:"DIR-615"  
          Mode:Managed  Frequency:2.437 GHz  Access Point: 00:90:4C:08:00:0D   
          Bit Rate=150 Mb/s   Tx-Power=20 dBm   
          Retry short limit:7   RTS thr=2347 B   Fragment thr:off
          Power Management:off
          Link Quality=70/70  Signal level=-22 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:186   Missed beacon:0

lo        no wireless extensions.

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    400    0        0 wlan0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 wlan0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 wlan0
PING google.com.Dlink (172.26.136.19) 56(84) bytes of data.
64 bytes from 19.136.26.172.in-addr.arpa (172.26.136.19): icmp_seq=1 ttl=249 time=102 ms

--- google.com.Dlink ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 102.547/102.547/102.547/0.000 ms

Solution 1:

First of all remove the settings you made.

sudo rm /etc/modprobe.d/rtl8723be.conf

If you do not have this file, nothing is wrong.

Then install a good driver

sudo add-apt-repository ppa:hanipouspilot/rtlwifi
sudo apt-get update
sudo apt-get install rtlwifi-new-dkms

Reboot and enjoy

If you still have problems (low signal), you may need to add an option:

echo "options rtl8723be ant_sel=2"  | sudo tee /etc/modprobe.d/rtl8723be.conf

then reboot again.

Expanation is made by chili555 in this answer.

This is the same driver as https://github.com/lwfinger/rtlwifi_new, rock.new_btcoex branch but packed as dkms.

You can see all that at https://github.com/hanipouspilot/rtlwifi_new/tree/rock.new_btcoex

If you also need bluetooth working, run also:

sudo apt-get install rtl8723au-bt-dkms linux-firmware

Note: Support for 4.2 kernels and Ubuntu 15.10 has been added to the PPA. For kernel 4.2 the bluetooth driver should not be installed from the PPA. There is already native support of the bluetooth adapter in kernel 4.2.

Offline guide

If you do not have any internet connection, you can download the package using another computer, a phone, etc.

The package is HERE

You will also need DKMS installed. You can find the DKMS package for Ubuntu 16.04 HERE

Copy these two files to the Ubuntu Home folder (~/) and run in terminal

sudo dpkg -i dkms*.deb rtlwifi*.deb

Then reboot.

Important: For new Ubuntu kernels installed on a system with Secure Boot on UEFI, the unsigned kernel module may not load. In this case see THIS ANSWER to fix it.

Update: I have now a laptop with this adapter. It works perfectly on the 4.8 kernel that is available in Ubuntu 16.10 and 16.04.2.

Installation of a custom driver is required only for kernels older than 4.8.

I suggest installing the 4.8 kernel to Ubuntu 16.04 if it is not installed yet by

sudo apt install linux-generic-hwe-16.04

The device should work well after a reboot.

But still if your laptop has only one antenna and it is attached to a "wrong" connector, setting ant_sel=2, or and_sel=1 may be required.

Solution 2:

If your Wifi drops after a while and you dual boot with Windows

On HP 250 G4 (using rtl8723be), I at first had the antenna bug: wifi signal was too low:

It was solved after installing new driver and setting ant_sel=2, just as described here.

But then came the 2nd problem :
wifi was working fine for some time (sometimes 2 hours) then suddenly going slow and eventually disconnecting.
Changing parameters (ips, fwps...) didn't help.
I finally found that removing Windows 10 fastboot (in Windows energy settings) solved the problem.

This has been confirmed by another user (see RTL8723BE: Wifi always drops after 15/20 mins

Solution 3:

What worked for me was enabling the MSI parameter (message signal interupt). I have a lenovo Z50 laptop. My wifi would work with all wifi laptop manufacturers but i was having a problem with a Lancorm wifi router at a Hotel I once stayed.

I found the file sw.c in the folder path

/home/peter/rtlwifi_new/rtl8723be

Then in the sw.c file, I added the variable .msi_support and initiated it to "false" under the data type

rtl_mod_params rtl8723be_mod_params

i.e

static struct rtl_mod_params rtl8723be_mod_params = {
.sw_crypto = false,
.inactiveps = true,
.swctrl_lps = false,
.fwctrl_lps = true,
.msi_support = false,
};

Since msi_support is by default disabled, we have to appropriately initialize it as disabled(hence false),

I then complied the code:

cd rtl8723be
make clean
sudo make install
sudo modprobe rtl8723be

After that I set the msi parameter to 1, in the file

/etc/modprobe.d/rtl8723be.conf

it should contain

options rtl8723be fwlps=N ips=N swenc=Y msi=1

You may have to reboot the computer and wait after for a couple of minutes after restarting the browser for the msi to be triggered.

This worked for a lenovo z50. Depending on your pc, you may toggle and choose instead an msi of 0

Solution 4:

Just took a HP Stream 13 and wiped it, put Ubuntu 15.10 on it symlinking all home folders to a 64GB SD card to expand the 32GB SSD... Then ran into the dreaded rtl8723be problem, which I have also noticed on a HP 430 work laptop that had a different variant....

After a lot of messing, I finally find there is actually 2 issues here.

  1. The WiFi driver needs swapping as stated above, to cure drop outs of the card which require network manager to be restarted or card resynched with network. Update the driver as stated.

    sudo add-apt-repository ppa:hanipouspilot/rtlwifi
    sudo apt-get update
    sudo apt-get install rtlwifi-new-dkms linux-firmware
    
  2. Once your drop outs are fixed, you need to cure the low signal strength issue... This is a little more invasive. Undo all screws on bottom, even the ones under the 2 back rubber feet, centre little rubber cover and hinge rubber covers all on the bottom.

Gently ease the top off clicking it away from the base. Lift top off gently. Locate the network card in the centre, towards the rear. Remove the fine coax cable of the antenna connected (main) and replace it on the connector next to it (aux). Put everything back together.

The driver for Linux uses the other antenna on this dual antenna card, so if you don't swap it you will get severe signal loss.

Now the laptop has plenty of space for storage, boots pretty quick and has full signal with no dropouts all around the house. Great little laptop for the price but needs some planning if you are gonna put Linux on it.

Thanks everyone for the work on this.

Solution 5:

I had the same problem, I updated my driver just as explaind in Pilot6 answer , but it still frequently disconnected. I was desperatly searching for another solution when I found in laugeo's answer that removing Windows 10 fastboot solves the problem. Unfortunalty, I only have Ubuntu and no Windows. However I found that simply disabling Legacy Support solves the problem!

I had to go to disable Legacy Support in Bios like this:

Bios -> Boot Option (Enter) -> Legacy Support: Disabled

enter image description here

Now WLAN works perfectly - no more disconnects!