From: http://blog.csdn.net/njchenyi/article/details/8715417
1. Configure static IP addresses:
# Vim/etc/Network/interfaces
The original content contains the following four lines:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
The above indicates that IP addresses are allocated using DHCP by default, and are changed to the following:
auto lo
iface lo inet loopback
# The primary network interface
Auto eth0
# Iface eth0 Inet DHCP
iface eth0 inet static
address 192.168.80.129
netmask 255.255.255.0
gateway 192.168.80.2
Save and exit.
Note: you only need to set the address (IP address), netmask (subnet mask), and gateway (GATEWAY). The network and broadcast parameters can be left empty.
2. manually set the DNS server:
# Vim/etc/resolv. conf
Add the following content (all Linux distributions are generic ):
Nameserver 192.168.80.2
Nameserver 8.8.8.8
Save and exit.
Note: After you restart Ubuntu, you will find that you cannot access the Internet again. The problem lies in/etc/resolv. conf. After the file is restarted, the DNS configured in this file is automatically changed to the default value. Therefore, you need to modify DNS permanently. The method is as follows:
# Vim/etc/resolvconf/resolv. conf. d/base
Nameserver 192.168.80.2
Nameserver 8.8.8.8
3. Restart the networking service to make it take effect:
#/Etc/init. d/networking restart
In this way, the network configuration takes effect permanently.