Ubuntu set static IP method

  

After the system is installed, the source is also set up (comment the previous default source, changed to a source of several education networks, the source of the North Exchange is relatively fast), down The task is to update the system and install the required software, but only if you have to go online, because the lab uses fixed IP, so you need to set Ubuntu as a static IP. The method is as follows:

1. Modify the network configuration file

The network configuration information is stored in the /etc/network/interfaces file

sudo vi /etc/network/interfaces

I opened with vi, my file shows the following:

# This file describes the network interfaces available on your system

# and how to activate them. For more information, See interfaces(5).

# The loopback network interface

auto lo

iface lo inet loopback

There is only one ring in my network configuration file The back address, which is 127.0.0.1. Added below:

auto eth0 # indicates that NIC eth0 is automatically loaded at system startup

iface eth0 inet static # indicates that eth0 uses ipv4 address, inet indicates ipv4 address, inet6 indicates ipv6 address; static Indicates static, dhcp indicates dynamic

address 172.22.112.13 #staticip

netmask 255.255.255.128 #subnet mask

gateway 172.22.112.1 #gateway address

:wq #Save and exit

2, set up the DNS server

Also configure the DNS server under static ip (Windows does the same), DNS information is stored in /etc/resolv In .conf, if you don't have this file, create it directly:

sudo vi /etc/resolv.conf #Open the file with vi

Enter edit mode, type a, and then type the following:

nameserver 202.202.32.33 #首选DNS服务

nameserver 61.128.128.68 #备用DNS服务

:wq #Save and exit

3, after modification You need to restart the NIC to make the changes take effect. To do so, enter the following command:

sudo ifdown eth0 #disable NIC

sudo ifup eth0 #Start NIC

Copyright © Windows knowledge All Rights Reserved