Configure a static ip address for the server

Original link: https://www.chen.fun/zh/2023/07/static-ip-address/

The last summer vacation of my school career is coming as scheduled. Because I may not be able to go home for the New Year this year, I will return to vacation early this time. The daily pastime is to do scientific research (you can’t graduate QAQ if you paddle), cook for your family, and take a (sports) camera and ride a bike in the countryside. It’s a small fortune. Regarding work equipment, I usually use a laptop to connect an external monitor to minimize the tossing and turning of multiple computers. But at home, there is still a desktop computer bought for writing a master’s thesis during the epidemic, which is a pity, so I decided to change it to a Linux server and run time-consuming programs such as MCMC through a remote connection.

The server is next to the router and connected to the network cable, and I work in another room. In order to facilitate remote connection, I changed the server ip address to static. First enter ip addr on the command line to view the ip address. My computer lists three results, lo for the local loop interface, enp3s for the wired connection, and wlp4s0 1 for the wireless connection.

The network configuration file sudo /etc/netplan/00-installer-config.yaml sets the dynamic ip address dhcp4: true by default. Modify it as follows:

 1 2 3 4 5 6 7 8 9 10 11 12
 network :  
 version : 2  
 renderer : networkd # 桌面端一般是NetworkManager  
 ethernets :  
 enp3s0 : # 网卡名称  
 dhcp4 : no # 静态ip  
 addresses : [ 192.168.1.100 /24] # ip 地址和子网掩码  
 routes : # 网关  
 - to : default  
 via : 192.168.1.1  
 nameservers :  
 addresses : [ 114.114.114.114 ] # DNS  

After that, connect to the server remotely through VS Code. For specific operations, refer to the previous example of connecting VS Code to WSL.


  1. The names of different network cards are different, but the beginning should be consistent, for example, en (ethernet) means Ethernet, wl (wlan) means wireless local area network. Subsequent p means PCI, o (on-board) means on-board device index number, s (slot) means hot-plug index number, x means MAC address, etc. ↩

This article is transferred from: https://www.chen.fun/zh/2023/07/static-ip-address/
This site is only for collection, and the copyright belongs to the original author.