Timeline
Timeline
2025-10-09
init
This article introduces the configuration and authentication methods for the campus network connection script. It first explains the basic steps to enable wlan and connect to the campus network, including using the Raspberry Pi system options or modifying wpa_supplicant.conf file to configure the wireless network, and restart wpa_supplicant service. Then, the article explains how to use the ifconfig command to check whether wlan has obtained an IP address to determine the connection status. If the connection fails, troubleshoot by checking logs. In addition, the article also covers analyzing the authentication process through packet capture, writing an authentication script based on it, and finally running the script to test whether the connection is successful.
First enable wlan, then let wlan connect to the campus network. The Raspberry Pi can be configured with the following command:
1 | sudo raspi-config |
Then in System Option, under Wireless LAN, enter the ssid and passphrase
Or write to /etc/wpa_supplicant/wpa_supplicant.conf
12345678 | ctrl_interface=DIR=/run/wpa_supplicant GROUP=netdevupdate_config=1country=CNnetwork={ ssid="HNU" key_mgmt=NONE} |
Then restart the wpa_supplicant service
1 | sudo systemctl restart wpa_supplicant |
After the above operations, use the ifconfig command to check whether wlan’s inet has an IP address. If there is an IP address, it means it has connected to the campus network, and the next step is to pass authentication.
If it is not successful, run the following command to view the logs
1 | journalctl -u wpa_supplicant -n 50 --no-pager |
Packet capture:

Based on the packet capture, the following authentication script can be written:
1234567891011121314151617181920 | # First obtain the IPv4 and MAC of wlan0IP=$(ip -4 -o addr show wlan0 | awk '{print $4}' | cut -d/ -f1)MAC=$(cat /sys/class/net/wlan0/address)USER=",0,your_student_number"PASS="your_password"curl -s --get "https://web.hnu.edu.cn:802/eportal/portal/login" \ --data-urlencode "callback=dr1003" \ --data-urlencode "login_method=1" \ --data-urlencode "user_account=${USER}" \ --data-urlencode "user_password=${PASS}" \ --data-urlencode "wlan_user_ip=${IP}" \ --data-urlencode "wlan_user_mac=${MAC}" \ --data-urlencode "terminal_type=1" \ --insecure \ -D - \ | sed -n '1,200p' |
After running the above script, test whether the connection is successful
1 | ping www.baidu.com |