Detailed record of Realtek RTL8188FU WiFi connection route

The road is blocked and long, and the line is coming. Keep your head down and work hard. If you don't make a noise, you'll be a blockbuster! Come on, Sao Nian!

Hello, everyone. I'm Xiao 2. I summarized the last article WiFi command compilation process

This article shares the process of WiFi connection routing. I hope it can be helpful to you!

1 references

1. For the configuration process, some references are as follows:

2. To solve the problem, some references are as follows:

3. There are some other advanced tutorials, thank you very much!

2 Environment Introduction

1,Ubuntu18.04. No encryption environment. The version information is as follows:

zhaoc@Ubuntu1804:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.5 LTS
Release:	18.04
Codename:	bionic


zhaoc@Ubuntu1804:~$ uname -a
Linux Ubuntu1804 5.4.0-54-generic #60~18.04.1-Ubuntu SMP Fri Nov 6 17:25:16 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

2. Linux kernel version: 4.4.179;

3. Cross compile chain version

arm-none-linux-gnueabi-gcc

gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-29)

3 connection routing

In my actual debugging process, I first configure it through the command line. After the code is mature, I use the script file to connect the route.

Therefore, there are three methods:

  • Manual connection, fixed IP mode;
  • Manual connection, dynamic DHCP mode;
  • Script connection, dynamic DHCP mode;

3.1 fixed IP

The command configuration process is recorded as follows.

1. Turn on the wireless network card, WLAN 0

ifconfig wlan0 up

2. Auto connect using profile, r8000 Refer to the article for the conf configuration file WiFi command compilation process , or refer to the resources at the end of the article.

wpa_supplicant -iwlan0 -c ./r8000.conf -B

3. View WiFi connection status

wpa_cli -iwlan0 status

4. Set fixed IP address and subnet mask

ifconfig wlan0 192.168.60.1 netmask 255.255.255.0

5. View IP address

ifconfig

6. Set default gateway

route add default gw 192.168.60.254

  note: delete the default gateway

route del default

7. View default gateway

# command
route

# test result
[root]#route 
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.60.254  0.0.0.0         UG    0      0        0 wlan0
192.168.60.0    *               255.255.255.0   U     0      0        0 wlan0

8. Set DNS

# Edit profile
vi /etc/resolv.conf

# Add DNS and try it yourself
nameserver 8.8.8.8
nameserver 223.5.5.5
nameserver 223.6.6.6

  command line modification of DNS method

# Modify DNS and configure it according to the reference materials;
echo nameserver 223.5.5.5 > /etc/resolv.conf

3.2 dynamic DHCP

1. Confirm that the wireless network card can be detected normally (the network card name can be seen normally)

ifconfig -a

2. Stop wired network card

ifconfig eth0 down

3. Restart the wireless network card

ifconfig wlan0 down 

ifconfig wlan0 up

4. Set up a wireless network card to connect to WiFi using a profile

wpa_supplicant -iwlan0 -c ./r8000.conf -B

5. Scan WiFi test with wireless network card

iwlist wlan0 scanning

6. Configure the wireless network card to use DHCP function

udhcpc -i wlan0

7. Check the IP address of the wireless network card and whether it is obtained successfully

ifconfig -a

8. Test whether the external network can be connected normally

ping baidu.com

9. View current WiFi connection status

wpa_cli -iwlan0 status

3.3 script file

The start and stop processes are basically similar to the command line configuration, except that they are all encapsulated into scripts for easy operation.

1. Enable WiFi connection script

#/bin/sh
# Log printing
echo "========================= $0 start ============================"

# Kill all related processes first
killall hostapd udhcpd wpa_supplicant udhcpc

# Turn off the wireless network card
ifconfig wlan0 down

# Wireless network card on
ifconfig wlan0 up

# Delay 1 second
sleep 1

# Turn on WiFi connection
wpa_supplicant -iwlan0 -c /root/App/wifi.conf -B

# Configure automatic IP acquisition
udhcpc -i wlan0

# Log printing
echo "======================== $0 stop =============================="

2. Turn off WiFi connection and only kill commands related to WiFi connection routing

#/bin/sh
echo "[root] killall wpa_supplicant udhcpc"
killall wpa_supplicant udhcpc

3. WiFi basic configuration file: / root / APP / WiFi conf

ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
network={
	ssid="WiFi name"
	psk="WiFi password"
}

4 resource records

1,r8000.conf configuration file

(1) Precautions:

  • Characters are strictly indented;
  • No more / less characters;
  • The format of this document is very strict. If there is any problem, please check whether this document is incorrect;
  • It must be typed by hand and not copied (the format of assignment is easy to make mistakes)

(2) The content of the configuration file is as follows:

[root]#cat r8000.conf 
ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
network={
	ssid="WiFi name"
	psk="WiFi password"
}

5 Summary

1. At the beginning of debugging, because I don't know whether the parameters are appropriate, I just use the command line to type them out sentence by sentence; The script is not written until the code is basically determined.

2. Now think about it, it's a little silly. Why didn't you use the script directly in the beginning? If there is a problem, just modify the configuration item in the script?

3. WiFi connection routing is one of the most commonly used functions, and two problems are encountered during the process

(1) After WiFi connection routing, the network speed is very slow. After testing, there are several reasons:

  • WiFi antenna is not installed;
  • WiFi antenna mismatch;

(2) WiFi connection is unstable after routing. Specific performance: ping Baidu, delay from high to low. No specific reason has been found yet. Thinking direction:

  • Problems of WiFi module itself (poor performance, process problems, etc.)
  • WiFi driver problem (low version? Unsuitable?)

Well, that's the content of this issue. Thank you for reading. I'm Xiao 2. See you in the next issue!

If the content of the article is wrong, please comment / private letter for more advice! If you think the content of the article is good, remember to click four times (like, collect, leave a message and pay attention). If you can pay attention, it will be my greatest encouragement and the driving force of my creation. Thank you!

Keywords: Linux kernel wifi

Added by designerguy on Mon, 07 Mar 2022 16:33:17 +0200