Skip to main content

5. Network connection and static configuration

The ArmSoM series products are all equipped with Ethernet ports or WIFI modules, PCIE to Ethernet modules, USB to Ethernet modules, etc., so our network needs are not just as simple as surfing the Internet, and can be derived into a variety of different ways of playing.

5.1 Network connection

Connecting to the Internet or forming a local area network requires a prerequisite - the device needs to obtain an IP, which can be understood as the name of the device. Devices in the local area network can communicate through the IP in the local area network. As follows 192.168.10.100

armsom@armsom-sige7:~$ ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 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 2: enP4p65s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 92:be:6d:d5:e7:b4 brd ff:ff:ff:ff:ff:ff permaddr 72:d3:55:ba:fe:0a
inet 192.168.10.100/24 ​​brd 192.168.10.255 scope global dynamic noprefixroute enP4p65s0
valid_lft 34665sec preferred_lft 34665sec

5.1.1 ping command

ping (Packet Internet Groper), Internet packet explorer, is a program used to test network connection capacity. It is a command used to check whether the network is smooth or the speed of the network connection

The principle of ping: Send a data packet of a certain length to the specified network address. According to the agreement, if the specified network address exists, a data packet of the same size will be returned. Of course, if there is no return within a specific time, it is "timeout" and it will be considered that the specified network address does not exist

5.1.2 Local Area Communication

A local area network must have a gateway. We can ping the gateway to see if our IP can be used successfully. If even the gateway cannot be pinged, it proves that the local area network is not connected.

#ping command
sudo ping + ip address
  • If the network is successfully connected, you can see a series of data, as follows
armsom@armsom-sige7:~$ sudo ping 192.168.10.1
ping: socket: Address family not supported by protocol
PING 192.168.10.1 (192.168.10.1) 56(84) bytes of data.
64 bytes from 192.168.10.1: icmp_seq=1 ttl=64 time=0.649 ms
64 bytes from 192.168.10.1: icmp_seq=2 ttl=64 time=0.583 ms
64 bytes from 192.168.10.1: icmp_seq=3 ttl=64 time=0.571 ms
64 bytes from 192.168.10.1: icmp_seq=4 ttl=64 time=0.614 ms
64 bytes from 192.168.10.1: icmp_seq=5 ttl=64 time=0.583 ms
64 bytes from 192.168.10.1: icmp_seq=6 ttl=64 time=0.703 ms

5.1.3 Connect to the Internet

We can check whether the product is connected to the Internet by pinging the website

#ping command
sudo ping xxx.com
  • Take baidu.com as an example. If the network is successfully connected, you can see a series of data, as shown below
armsom@armsom-sige7:~$ sudo ping www.baidu.com ping: socket: Address family not supported by protocol PING www.a.shifen.com (183.2.172.185) 56(84) bytes of data. 64 bytes from 183.2.172.185 (183.2.172.185): icmp_seq=1 ttl=52 time=7.83 ms 64 bytes from 183.2.172.185 (183.2.172.185): icmp_seq=2 ttl=52 time=7.80 ms 64 bytes from 183.2.172.185 (183.2.172.185): icmp_seq=3 ttl=52 time=8.36 ms 64 bytes from 183.2.172.185 (183.2.172.185): icmp_seq=4 ttl=52 time=8.39 ms

5.2 Command line graphical connection

  • Enter the graphical configuration
armsom@armsom-sige7:~$ sudo nmtui
  • Move the keyboard arrow key to Active a connection and press Enter to enter the wifi settings

  • Move the arrow key to the wifi you want to connect to and press Enter

  • If you are connecting to an unconnected hotspot with a password, enter the password input interface

  • If you want to disconnect the wifi, press Enter in the connected state to disconnect

5.3 Command line connection

  • List the wifi list
armsom@armsom-sige7:~$ nmcli dev wifi list
  • Connect to wifi

Take hotspot: armsom password: armsom88 and use interface wlan0 as an example

# First connection
armsom@armsom-sige7:~$ sudo nmcli dev wifi connect armsom password 'armsom88' ifname wlan0
Device 'wlan0' successfully activated with '7867c3af-dca2-4e9a-9721-a20f7a0e1b46'.

# After the first successful connection, reconnect or switch wifi
armsom@armsom-sige7:~$ sudo nmcli dev wifi connect armsom

5.4 Desktop connection

When using wired Internet access, please insert the network cable into the RJ45 interface. There will be a network connection icon in the upper right corner of the desktop. Select the network you want to connect to and enter the password to access the Internet.

5.5 USB tethering

todo

5.6 Static network configuration

5.6.1 nmtui

  • Set the IP address before the static address
armsom@armsom-sige7:~$ sudo ifconfig
enP4p65s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.10.100 netmask 255.255.255.0 broadcast 192.168.10.255
ether 92:be:6d:d5:e7:b4 txqueuelen 1000 (Ethernet)
RX packets 23758 bytes 1774543 (1.6 MiB)
RX errors 0 dropped 80 overruns 0 frame 0
TX packets 67013 bytes 3879463 (3.6 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 155

If you want to successfully set a static address, you need to pay attention to whether the IP address you want to set is occupied by other devices. You can use ping to set the static address. If there is data returned, it proves that the IP is occupied by other devices.

Here it is recommended that newbies who do not understand network configuration can set the static address to the IP address obtained during dynamic connection

The following are detailed steps

  • Enter the graphical configuration
armsom@armsom-sige7:~$ nmtui

Move the keyboard arrow key to Edit a connection and press Enter to enter the wifi settings

Select the network you want to edit. Here we take eth0 as an example

  • Enter to see the default configuration of the network

  • You need to set IPV4 CONFIGURATION to Manual

  • Then move the cursor to show Press enter to enter detailed configuration

Here we take the IP address 192.168.10.13 and the gateway 192.168.10.1 as an example

Note!

The IP address and gateway need to be configured according to your actual network situation. If you copy the configuration here, there is a high probability that your product will not be able to connect to the Internet. Junior developers recommend changing the static IP to a dynamically obtained IP

  • How to obtain the gateway
#1. Set the network to automatically obtain the IP

#2. After successfully obtaining the IP, use the command
route

#Result
root@armsom-w3:/home/armsom# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.10.1 0.0.0.0 UG 100 0 0 enP4p65s0
192.168.10.0 0.0.0.0 255.255.255.0 U 100 0 0 enP4p65s0

#3. Gateway is our gateway. Use the following command
route -n

#Result
root@armsom-w3:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.10.1 0.0.0.0 UG 100 0 0 enP4p65s0
192.168.10.0 0.0.0.0 255.255.255.0 U 100 0 0 enP4p65s0

#You can see our gateway address ---- 192.168.10.1

  • 192.168.10.13/24 where /24 represents the mask 255.255.255.0,
  • DNS servers National General DNS –>114.114.114.114 Global General DNS –>8.8.8.8
  • search The domain can be set using the DNS servers.
  • Multiple DNS servers and search domains can be set.
  • After setting, you can move to the back and click OK to complete the setting
  • After completing the setting, you need to activate the setting to make the network effective. Click Activate a connection to enter the connection, press enter once to cancel the connection, and press enter again to reconnect
  • The IP after reconnection becomes the ip we set
root@armsom-w3:/home/armsom# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
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
2: enP4p65s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 92:be:6d:d5:e7:b4 brd ff:ff:ff:ff:ff:ff permaddr be:87:f6:b4:e5:ad inet 192.168.10.13/24 brd 192.168.10.255 scope global noprefixroute enP4p65s0 valid_lft forever preferred_lft forever 3: wlP2p33s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000 link/ether 2c:05:47:8e:4a:6c brd ff:ff:ff:ff:ff:ff 4: wlan1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether 2e:05:47:8e:4a:6c brd ff:ff:ff:ff:ff:ff

We can also use ping mi.com to check whether the external network is successfully connected

root@armsom-w3:/home/armsom# ping mi.com
ping: socket: Address family not supported by protocol
PING sgp.ali.cdn.b2cop.lb.mi.com (161.117.94.231) 56(84) bytes of data.
64 bytes from 161.117.94.231 (161.117.94.231): icmp_seq=1 ttl=87 time=48.8 ms
64 bytes from 161.117.94.231 (161.117.94.231): icmp_seq=2 ttl=87 time=49.5 ms

5.6.1 nmcli

Take enP4p65s0 as an example. This step is the same as editing the network in nmtui, except that it is changed from a graphical interface to a command line operation. There are various names in the command line. Only some are introduced here. Those who are interested can explore it by themselves.

#List the connection configuration first. eth0 is now connected to Wired connection 1

root@armsom-w3:/home/armsom# nmcli c s
NAME UUID TYPE DEVICE
Wired connection 1 e01f934d-7fae-344f-90bf-e2483db3f3e5 ethernet enP4p65s0
armsom d3d9a6ff-9c9c-44f8-a366-6a69af1edd1a wifi --
armsom 1 7867c3af-dca2-4e9a-9721-a20f7a0e1b46 wifi --

Then modify Wired connection 1

#Static ip settings
sudo nmcli c modify 'Wired connection 1' [ + | - ]Option Option value # or

sudo nmcli c m 'Wired connection 1' ipv4.address 192.168.10.13/24 # Modify the IP address and subnet mask
sudo nmcli c m 'Wired connection 1' ipv4.method manual # Change to static configuration, the default is auto
sudo nmcli c m 'Wired connection 1' ipv4.gateway 192.168.10.1 # Modify the default gateway
sudo nmcli c m 'Wired connection 1' ipv4.dns 8.8.8.8 # Modify DNS
sudo nmcli c m 'Wired connection 1' +ipv4.dns 114.114.114.114 # Add a DNS
sudo nmcli c m 'Wired connection 1' ipv6.method disabled # Disable IPv6
sudo nmcli c m 'Wired connection 1' connection.autoconnect yes # Startup

Note that you must modify ipv4.address first before you can modify ipv4.method!
Use empty quotes "" instead of the option value to set the option back to the default value (taking ipv4.method as an example):

#Activate configuration
sudo nmcli c up ifname eth0

After configuration, the IP address will be changed

armsom@armsom-sige7:~$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
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
2: enP4p65s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 92:be:6d:d5:e7:b4 brd ff:ff:ff:ff:ff:ff permaddr be:87:f6:b4:e5:ad
inet 192.168.10.14/24 brd 192.168.10.255 scope global noprefixroute enP4p65s0
valid_lft forever preferred_lft forever
3: wlP2p33s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether 2c:05:47:8e:4a:6c brd ff:ff:ff:ff:ff:ff
4: wlan1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether 2e:05:47:8e:4a:6c brd ff:ff:ff:ff:ff:ff

5.7 Create WIFI hotspot

create_ap is a script that helps quickly create WIFI hotspots on Linux. It supports bridge and NAT modes. It can automatically combine hostapd, dnsmasq and iptables to complete the setting of WIFI hotspots, avoiding users from making complex configurations. The github address is as follows: https://github.com/oblique/create_ap

root@armsom-sige7:/home/armsom/create_ap# make install

5.7.1 create_ap How to create a WIFI hotspot in NAT mode

  1. Enter the following command to create a WIFI hotspot named armsom and password armsom in NAT mode
armsom@armsom-sige7:~$ sudo create_ap -m nat wlan0 enP2p33s0 armsom armsom