Welcome to DOFBOT-Ultra repository
7.Network configuration
Network Configuration
Network ConfigurationWired NetworkModifying Static IP ConfigurationModifying DHCP ConfigurationModify MAC address configurationWireless NetworkStation ModeSoft AP Mode
This section mainly introduces the methods for modifying the wired and wireless network configurations of the development board.
Wired Network
The default wired network configuration of the development board uses static IP configuration, and the initial IP address is 192.168.1.10. Users can switch between static and DHCP modes by the following methods.
Modifying Static IP Configuration
The development board's static network configuration is saved in the /etc/network/interfaces file. By modifying the address, netmask, gateway, and other fields, the static IP configuration can be modified. metric is the network priority configuration, setting it to 700 is to lower the priority of the wired network. When both wired and wireless networks are enabled, the wireless network will be prioritized. For example:
xxxxxxxxxxsudo vim /etc/network/interfacesxxxxxxxxxx# interfaces(5) file used by ifup(8) and ifdown(8)# Include files from /etc/network/interfaces.d:source-directory /etc/network/interfaces.dauto eth0iface eth0 inet static address 192.168.1.10 netmask 255.255.255.0 gateway 192.168.1.1 metric 700
After the modification is completed, enter the command sudo restart_network on the command line to make the configuration take effect.
Modifying DHCP Configuration
DHCP (Dynamic Host Configuration Protocol) is usually applied in local area network environments. Its main function is centralized management and allocation of IP addresses, allowing hosts in the network environment to dynamically obtain IP addresses, gateway addresses, DNS server addresses, and other information, thereby improving the utilization of addresses.
The development board's DHCP network configuration is saved in the /etc/network/interfaces file. By modifying the relevant configuration of eth0, the DHCP mode can be modified. For example:
xxxxxxxxxxsudo vim /etc/network/interfaces
xxxxxxxxxxsource-directory /etc/network/interfaces.dauto loiface lo inet loopbackauto eth0iface eth0 inet dhcpmetric 700
After modifying, enter the sudo restart_network command in the command line to make the configuration take effect.
Modify MAC address configuration
If you need to modify the default MAC address of the development board, you can add pre-up configuration information in the /etc/network/interfaces file to specify the MAC address you need, for example:
xxxxxxxxxxsudo vim /etc/network/interfaces
xxxxxxxxxx# interfaces(5) file used by ifup(8) and ifdown(8)# Include files from /etc/network/interfaces.d:source-directory /etc/network/interfaces.dauto eth0iface eth0 inet static address 192.168.1.10 netmask 255.255.255.0 gateway 192.168.1.1 pre-up ifconfig eth0 hw ether 00:11:22:9f:51:27
After modifying, reboot to make the configuration take effect.
Wireless Network
The development board integrates a 2.4GHz wireless WiFi module, which supports Soft AP and Station modes, and runs in Station mode by default. The following introduces how to use the two modes.
Station Mode
In Station mode, the development board as a client and accesses the router's wireless hotspot for internet connection.
- For users of Ubuntu Desktop version, you can click on the Wi-Fi icon in the upper right corner of the desktop, select the corresponding hotspot, and enter the password to complete the network configuration, as shown in the figure below:

- For users of Ubuntu Server version, you can complete the wireless network configuration through the command line, following these steps:
Use the
sudo nmcli device wifi rescancommand to scan for hotspots. If you get the following message, it means scanning is too frequent and you need to try again later:xxxxxxxxxxroot@ubuntu:~# sudo nmcli device wifi rescanError: Scanning not allowed immediately following previous scan.Use the
sudo nmcli device wifi listcommand to list the scanned hotspots.Use the
sudo wifi_connect "SSID" "PASSWD"command to connect to the hotspot. If you get the following message, it means the network connection is successful:xxxxxxxxxxroot@ubuntu:~# sudo wifi_connect "WiFi-Test" "12345678"Device 'wlan0' successfully activated with 'd7468833-4195-45aa-aa33-3d43da86e1a7'.
tip
If you receive the following message after connecting to the hotspot, it means the hotspot is not found. You can execute the sudo nmcli device wifi rescan command to rescan and reconnect.
xxxxxxxxxxroot@ubuntu:~# sudo wifi_connect "WiFi-Test" "12345678" Error: No network with SSID 'WiFi-Test' found.
Soft AP Mode
By default, the development board's wireless network runs in Station mode. To use the Soft AP mode, please follow the steps below for configuration.
Install
hostapdandisc-dhcp-serverxxxxxxxxxxsudo apt updatesudo apt install hostapdsudo apt install isc-dhcp-serverRun the command
sudo vim /etc/hostapd.confto configure thehostapd.conffile, focusing on the following fields:xxxxxxxxxxinterface=wlan0 # The network card used as an AP hotspotssid=Sunrise # WiFi namewpa=2 # 0 for WPA, 2 for WPA2, usually 2wpa_key_mgmt=WPA-PSK # Encryption algorithm, usually WPA-PSKwpa_passphrase=12345678 # Passwordwpa_pairwise=CCMP # Encryption protocol, usually CCMP- For an open hotspot configuration, add the following content to the
hostapd.conffile:
xxxxxxxxxxinterface=wlan0driver=nl80211ctrl_interface=/var/run/hostapdssid=Sunrisechannel=6ieee80211n=1hw_mode=gignore_broadcast_ssid=0- For a hotspot with a password, add the following content to the
hostapd.conffile:
xxxxxxxxxxinterface=wlan0driver=nl80211ctrl_interface=/var/run/hostapdssid=Sunrisechannel=6ieee80211n=1hw_mode=gignore_broadcast_ssid=0wpa=2wpa_key_mgmt=WPA-PSKrsn_pairwise=CCMPwpa_passphrase=12345678- For an open hotspot configuration, add the following content to the
Configure the
isc-dhcp-serverfile as follows:- Execute
sudo vim /etc/default/isc-dhcp-serverto modify theisc-dhcp-serverfile and add the following definition for the network interface:
xxxxxxxxxxINTERFACESv4="wlan0"- Execute
sudo vim /etc/dhcp/dhcpd.confto modify thedhcpd.conffile and uncomment the following fields:
xxxxxxxxxxauthoritative;- Then, add the following configuration to the end of the
/etc/dhcp/dhcpd.conffile:
xxxxxxxxxxsubnet 10.5.5.0 netmask 255.255.255.0 { #network and subnet maskrange 10.5.5.100 10.5.5.254;#IP range availableoption subnet-mask 255.255.255.0; #subnet maskoption routers 10.5.5.1;#default gatewayoption broadcast-address 10.5.5.31;#broadcast addressdefault-lease-time 600;#default lease time in secondsmax-lease-time 7200;#maximum lease time in seconds}- Execute
Stop the
wpa_supplicantservice and restartwlan0xxxxxxxxxxsystemctl stop wpa_supplicantip addr flush dev wlan0sleep 0.5ifconfig wlan0 downsleep 1ifconfig wlan0 upStart the
hostapdservice as follows:- Execute the command
sudo hostapd -B /etc/hostapd.conf
xxxxxxxxxxroot@ubuntu:~# sudo hostapd -B /etc/hostapd.confConfiguration file: /etc/hostapd.confUsing interface wlan0 with hwaddr 08:e9:f6:af:18:26 and ssid "sunrise"wlan0: interface state UNINITIALIZED->ENABLEDwlan0: AP-ENABLED- Configure the IP and subnet of wireless interface
wlan0using theifconfigcommand, make sure it matches the configuration in the third step
xxxxxxxxxxsudo ifconfig wlan0 10.5.5.1 netmask 255.255.255.0- Finally, start the
dhcpserver. Clients connecting to the hotspot will be assigned an IP address from10.5.5.100to10.5.5.255
xxxxxxxxxxsudo ifconfig wlan0 10.5.5.1 netmask 255.255.255.0sudo systemctl start isc-dhcp-serversudo systemctl enable isc-dhcp-server- Execute the command
Connect to the hotspot on the development board, for example,
sunrise
If you need to switch back to
Stationmode, you can do it as follows:xxxxxxxxxx# Stop hostapdkillall -9 hostapd# Clear the address of wlan0ip addr flush dev wlan0sleep 0.5ifconfig wlan0 downsleep 1ifconfig wlan0 up# Restart wpa_supplicantsystemctl restart wpa_supplicant# Connect to the hotspot, for specific operation, please refer to the previous section "Wireless Network"wifi_connect "WiFi-Test" "12345678"