Static IP Configuration
Purpose and Advantages of Static IP
Static IP configuration ensures that a device has a fixed address on the network, providing stable and reliable network connections for various application scenarios.
Main Application Scenarios
-
Ensuring Stable Device Accessibility
- The device always maintains the same IP address, facilitating remote access and control
- Suitable for scenarios requiring fixed addresses such as Web servers, MQTT communication, and PLC control
-
Simplifying Network Management
- In local area networks or industrial networks, devices like cameras, sensors, and controllers require fixed IPs
- Facilitates stable connections for other systems and services
-
Adapting to Special Network Environments
- Static IPs must be used in environments without DHCP services (e.g., industrial control, edge computing)
- Avoids reliance on dynamic address assignment
-
Improving Development and Debugging Efficiency
- Fixed IPs facilitate quick device location and connection
- Simplifies repetitive testing processes
-
Supporting Device Discovery Mechanisms
- When accessing devices via a preset IP range, a static IP ensures the device responds as expected
Comparison of Static IP Advantages
| Advantage | Description |
|---|---|
| Stable and Reliable | The IP address remains fixed, ensuring stable communication for long-running devices |
| Friendly to Headless Environments | Suitable for environments without a graphical interface, such as embedded devices |
| Convenient Remote Maintenance | More efficient when connecting via SSH, Web, API, etc. |
| Adapts to Closed Networks | Must use static IP in industrial networks or private networks without DHCP |
| Automation Support | Deployment, monitoring, and update scripts rely on IP consistency |
System Configuration
- Avoid using IP addresses close to boundary values such as
0,1,254,255 - Using an IP like
192.168.1.254might be preempted by other applications, leading to unstable connections - It is recommended to use IP addresses in the middle range, e.g.,
192.168.1.100-192.168.1.200
Configuration Steps
-
Connect to the System Terminal
- Use SSH to connect to the device system
-
Check Network Interfaces
- Execute command:
ip link show - Note the network interface name, e.g.,
eth0,end0
Loading... - Execute command:
-
Edit the Network Configuration File
- Execute command:
nano /etc/systemd/network/end0.network - Note: Replace
end0in the filename with the actual network interface name
Loading... - Execute command:
-
Configure Static IP Parameters
- Modify the file content as follows (adjust according to the actual network environment):
[Match]# Match the network interface name, modify according to the actual situationName=end0[Network]# Set the static IP address and subnet mask# /24 indicates the subnet mask is 255.255.255.0Address=192.168.1.100/24# Set the default gateway addressGateway=192.168.1.1# Set DNS serversDNS=8.8.8.8DNS=114.114.114.114Loading... -
Save and Apply Configuration
- Press
Ctrl + Sto save the file - Press
Ctrl + Xto exit the editor - Execute the command to restart the network service:
systemctl restart systemd-networkd
- Press
-
Verify the Configuration Result
- Execute command:
ip a - Confirm that the displayed IP address matches the configuration
Loading... - Execute command:
PC Configuration
To ensure that the PC can communicate normally with the device that has a static IP set, corresponding network configuration is required on the PC.
Network Parameter Settings
| Parameter | Configuration Requirement | Description |
|---|---|---|
| Local IP | 192.168.1.xxx | Must be in the same subnet as the device IP |
| Gateway | 192.168.1.1 | Must match the gateway configured on the device |
| Subnet Mask | 255.255.255.0 | Corresponds to the /24 configuration of the device IP |
| DNS Server | 8.8.8.8, 114.114.114.114 | Use commonly available public DNS services |
Configuration Methods
Windows System
- Open "Network and Sharing Center"
- Click "Change adapter settings"
- Right-click the currently used network connection and select "Properties"
- Double-click "Internet Protocol Version 4 (TCP/IPv4)"
- Select "Use the following IP address" and fill in the corresponding parameters
macOS System
- Open "System Preferences" → "Network"
- Select the currently used network connection
- Click "Advanced" → "TCP/IP"
- Configure "IPv4" to "Manually"
- Fill in the corresponding IP address, subnet mask, and router address
Connectivity Test
After configuration, it is recommended to perform a connectivity test:
# Execute the ping command on the PC to test connectivity
ping 192.168.1.100
# If a reply is received, the network configuration is successful.
If the device cannot be pinged, please check:
- Whether the network cable connection is normal
- Whether the firewall settings are blocking communication
- Whether the IP addresses are in the same subnet
- Whether the subnet mask and gateway configurations are correct