Difference between revisions of "How to set a static IP address"
(Created page with "<br>'''1.Use the nmtui command to set a static IP address'''<br><br> 1) First run the nmtui command<br> {| class="wikitable" style="width:800px;" |- |orangepi@orangepi:~$ '''...") |
|||
Line 40: | Line 40: | ||
|orangepi@orangepi:~$ '''ip addr show eth0'''<br> | |orangepi@orangepi:~$ '''ip addr show eth0'''<br> | ||
3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000<br> | 3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000<br> | ||
− | link/ether 5e:ac:14:a5:92:b3 brd ff:ff:ff:ff:ff:ff<br> | + | :link/ether 5e:ac:14:a5:92:b3 brd ff:ff:ff:ff:ff:ff<br> |
− | inet '''<span style="color:#FF0000">192.168.1.177</span>'''/24 brd 192.168.1.255 scope global noprefixroute eth0 valid_lft forever preferred_lft forever<br> | + | :inet '''<span style="color:#FF0000">192.168.1.177</span>'''/24 brd 192.168.1.255 scope global noprefixroute eth0<br> |
− | inet6 241e:3b8:3240:c3a0:e269:8305:dc08:135e/64 scope global dynamic noprefixroute<br> | + | ::valid_lft forever preferred_lft forever<br> |
− | valid_lft 259149sec preferred_lft 172749sec<br> | + | :inet6 241e:3b8:3240:c3a0:e269:8305:dc08:135e/64 scope global dynamic noprefixroute<br> |
− | inet6 fe80::957d:bbbe:4928:3604/64 scope link noprefixroute valid_lft forever preferred_lft forever | + | ::valid_lft 259149sec preferred_lft 172749sec<br> |
+ | :inet6 fe80::957d:bbbe:4928:3604/64 scope link noprefixroute <br> | ||
+ | ::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'''<br> | 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'''<br> | ||
Line 55: | Line 57: | ||
64 bytes from 192.168.1.47: icmp_seq=3 ttl=64 time=0.273 ms<br> | 64 bytes from 192.168.1.47: icmp_seq=3 ttl=64 time=0.273 ms<br> | ||
64 bytes from 192.168.1.47: icmp_seq=4 ttl=64 time=0.269 ms<br> | 64 bytes from 192.168.1.47: icmp_seq=4 ttl=64 time=0.269 ms<br> | ||
− | 64 bytes from 192.168.1.47: icmp_seq=5 ttl=64 time=0.275 ms | + | 64 bytes from 192.168.1.47: icmp_seq=5 ttl=64 time=0.275 ms<br> |
+ | ^Cv | ||
+ | --- 192.168.1.47 ping statistics ---<br> | ||
+ | 5 packets transmitted, 5 received, 0% packet loss, time 4042ms <br> | ||
+ | rtt min/avg/max/mdev = 0.233/0.262/0.275/0.015 ms<br> | ||
|} | |} | ||
Line 65: | Line 71: | ||
{| class="wikitable" style="width:800px;" | {| class="wikitable" style="width:800px;" | ||
|- | |- | ||
− | |orangepi@orangepi:~$ nmcli con show | + | |orangepi@orangepi:~$ '''nmcli con show'''<br> |
+ | <span style="margin-right: 180px;">NAME</span><span style="margin-right: 260px;">UUID </span><span style="margin-right: 45px;">TYPE </span><span style="margin-right: 50px;">DEVICE</span><br> | ||
+ | <span style="margin-right: 125px;">'''orangepi'''</span><span style="margin-right: 70px;">cfc4f922-ae48-46f1-84e1-2f19e9ec5e2a</span><span style="margin-right: 50px;">wifi </span><span style="margin-right: 50px;">wlan0</span><br> | ||
+ | <span style="margin-right: 50px;">'''Wired connection 1'''</span><span style="margin-right: 50px;">9db058b7-7701-37b8-9411-efc2ae8bfa30</span><span style="margin-right: 30px;">ethernet </span><span style="margin-right: 50px;">eth0</span><br> | ||
|} | |} | ||
{| class="wikitable" style="width:800px;border: none !important;" | {| class="wikitable" style="width:800px;border: none !important;" |
Revision as of 20:16, 24 April 2023
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
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
4) Then select Edit via the Tab key and press the Enter key
5) Then use the Tab key to move the cursor to the <Automatic> position shown in the figure below to configure IPv4
6) Then press Enter, select Manual through the up and down arrow keys, and press Enter to confirm
7) The display after selection is shown in the figure below
8) Then move the cursor to <Show> via the Tab key
9) Then press Enter, and the following setting interface will pop up after entering
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
11) After setting, move the cursor to <OK> in the lower right corner, and press Enter to confirm
12) Then click <Back> to return to the previous selection interface
13) Then select Activate a connection, then move the cursor to <OK>, and finally click Enter
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
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
16) Then you can exit nmtui through the <Back> and Quit buttons
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
|
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. |
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 |
NAME | UUID | TYPE | DEVICE |
orangepi | cfc4f922-ae48-46f1-84e1-2f19e9ec5e2a | wifi | wlan0 |
Wired connection 1 | 9db058b7-7701-37b8-9411-efc2ae8bfa30 | ethernet | 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" \ |
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 |