This article introduces in detail how to use ubuntu14.04 to set a static IP. You can quickly set a static IP without having to modify some SSH links every time. So we will record the method of setting static IP under ubuntu14.04 system.
first step:
Configure a static IP address:
Open the /etc/network/interfaces file, the content is
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
The above means that DHCP is used to allocate IP by default. If you want to specify a static IP, you need to modify the following
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static*******Defined as static IP
address 192.168.2.29*******IP address to be set
netmask 255.255.255.0*******Subnet mask
gateway 192.168.2.1*******Gateway (routing address)
Then save this file
**Step 2: **
Manually set up DNS server
Open the file /etc/resolv.conf and set the content as follows
nameserver 192.168.2.1******Gateway (same as above)
nameserver 202.106.0.20******DNS server address (I found it by referring to other computers linked to this network)
third step:
Note: After restarting Ubuntu, I found that the Internet cannot be accessed. The problem appears in /etc/resolv.conf. After restarting, the dns configured in this file is automatically modified to the default value. So you need to permanently modify the DNS. The method is
Open the file /etc/resolvconf/resolv.conf.d/base and write the following content:
nameserver 192.168.2.1
nameserver 202.106.0.20
the fourth step:
Restart the network service to make it effective, the command is:
/etc/init.d/networking restart
(My personal experience is: restarting this service is invalid, or restarting the system is awesome)
The above is the whole content of this article, I hope it will be helpful to everyone's study.
Recommended Posts