1. Configure static IP address:
# vim/etc/network/interfaces
The original content has the following 4 lines:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
The above indicates that DHCP is used to assign IP by default and is modified as follows:
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 exit.
Note: You only need to set address (IP address), netmask (subnet mask), Gateway (gateways) These three items ok,network and broadcast are not writable.
2. Manually set up the DNS server:
# vim/etc/resolv.conf
Add the following (all Linux distributions are generic):
NameServer 192.168.80.2
NameServer 8.8.8.8
Save exit.
Note: After restarting Ubuntu, it is not possible to surf the internet again, the problem is/etc/resolv.conf. Once restarted, the DNS for this file configuration is automatically modified to the default value. So you need to permanently modify DNS. Here's how:
# 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 effective:
#/etc/init.d/networking Restart
This allows the network configuration to be permanently active.
Permanent Link: http://www.ha97.com/4895.html
Ubuntu Server 12.04 static IP compact Configuration