How to set a static IP address

From Wiki-Orange Pi
Jump to: navigation, search

Please do not set a static IP address by modifying the /etc/network/interfaces configuration file.


1.Use the nmtui command to set a static IP address

1) First run the nmtui command

orangepi@orangepi:~$ nmtui

2) Then select Edit a connection and press Enter

Pi-5-details-pic72.png

3) Then select the network interface that needs to set a static IP address, for example, to set the static IP address of the Ethernet interface, select Wired connection 1

Pi-5-details-pic73.png

4) Then select Edit via the Tab key and press the Enter key

Pi-5-details-pic74.png

5) Then use the Tab key to move the cursor to the <Automatic> position shown in the figure below to configure IPv4

Pi-5-details-pic75.png

6) Then press Enter, select Manual through the up and down arrow keys, and press Enter to confirm

Pi-5-details-pic76.png

7) The display after selection is shown in the figure below

Pi-5-details-pic77.png

8) Then move the cursor to <Show> via the Tab key

Pi-5-details-pic78.png

9) Then press Enter, and the following setting interface will pop up after entering

Pi-5-details-pic79.png

10) Then you can set the IP address (Addresses), gateway (Gateway) and DNS server address in the position shown in the figure below (there are many other setting options in it, please explore by yourself),Please set it according to your specific needs, the value set in the figure below is just an example

Pi-5-details-pic80.png

11) After setting, move the cursor to <OK> in the lower right corner, and press Enter to confirm

Pi-5-details-pic81.png

12) Then click <Back> to return to the previous selection interface

Pi-5-details-pic82.png

13) Then select Activate a connection, then move the cursor to <OK>, and finally click Enter

Pi-5-details-pic83.png

14) Then select the network interface that needs to be set, such as Wired connection 1, then move the cursor to <Deactivate>, and press Enter to disable Wired connection 1

Pi-5-details-pic84.png

15) Then please do not move the cursor, and then press the Enter key to re-enable Wired connection 1, so that the static IP address set earlier will take effect

Pi-5-details-pic85.png

16) Then you can exit nmtui through the <Back> and Quit buttons

Pi-5-details-pic86.pngPi-5-details-pic86-1.png

17) Then through ip addr show eth0, you can see that the IP address of the network port has changed to the static IP address set earlier

orangepi@orangepi:~$ ip addr show eth0

3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

link/ether 5e:ac:14:a5:92:b3 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.177/24 brd 192.168.1.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet6 241e:3b8:3240:c3a0:e269:8305:dc08:135e/64 scope global dynamic noprefixroute
valid_lft 259149sec preferred_lft 172749sec
inet6 fe80::957d:bbbe:4928:3604/64 scope link noprefixroute
valid_lft forever preferred_lft forever

18) Then you can test the connectivity of the network to check whether the IP address is configured OK, and the ping command can be interrupted through the shortcut key Ctrl+C

orangepi@orangepi:~$ ping 192.168.1.47 -I eth0

PING 192.168.1.47 (192.168.1.47) from 192.168.1.188 eth0: 56(84) bytes of data.
64 bytes from 192.168.1.47: icmp_seq=1 ttl=64 time=0.233 ms
64 bytes from 192.168.1.47: icmp_seq=2 ttl=64 time=0.263 ms
64 bytes from 192.168.1.47: icmp_seq=3 ttl=64 time=0.273 ms
64 bytes from 192.168.1.47: icmp_seq=4 ttl=64 time=0.269 ms
64 bytes from 192.168.1.47: icmp_seq=5 ttl=64 time=0.275 ms
^C
--- 192.168.1.47 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4042ms
rtt min/avg/max/mdev = 0.233/0.262/0.275/0.015 ms


2.Use the nmcli command to set a static IP address

1) If you want to set the static IP address of the network port, please insert the network cable into the development board first. If you need to set the static IP address of WIFI, please connect the WIFI first, and then start to set the static IP address

2) Then you can view the name of the network device through the nmcli con show command, as shown below
a. orangepi is the name of the WIFI network interface (the name is not necessarily the same)
b. Wired connection 1 is the name of the Ethernet interface

orangepi@orangepi:~$ nmcli con show

NAMEUUID TYPE DEVICE
orangepicfc4f922-ae48-46f1-84e1-2f19e9ec5e2awifi wlan0
Wired connection 19db058b7-7701-37b8-9411-efc2ae8bfa30ethernet eth0

3) Then enter the following command, where
a. "Wired connection 1" means to set the static IP address of the Ethernet port. If you need to set the static IP address of the WIFI, please modify it to the corresponding name of the WIFI network interface (you can get it through the nmcli con show command)
b. ipv4.addresses is followed by the static IP address to be set, which can be modified to the value you want to set
c. ipv4.gateway represents the address of the gateway

orangepi@orangepi:~$ nmcli con mod "Wired connection 1" \

ipv4.addresses "192.168.1.110" \
ipv4.gateway "192.168.1.1" \
ipv4.dns "8.8.8.8" \
ipv4.method "manual"

4) Then restart the linux system

orangepi@orangepi:~$ sudo reboot

5) Then re-enter the linux system and use the ip addr show eth0 command to see that the IP address has been set to the desired value

orangepi@orangepi:~$ ip addr show eth0

3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

link/ether 5e:ae:14:a5:91:b3 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.110/32 brd 192.168.1.110 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet6 240e:3b7:3240:c3a0:97de:1d01:b290:fe3a/64 scope global dynamic noprefixroute
valid_lft 259183sec preferred_lft 172783sec
inet6 fe80::3312:861a:a589:d3c/64 scope link noprefixroute
valid_lft forever preferred_lft forever