Ubuntu Server’s IP address in local area network (LAN) is changed after restart. How fix the IP address ?
Step 1: Revise the network configuration file
$sudo vi /etc/network/interfaces
Add those information blow:
auto eth0
iface eth0 inet static
address 192.168.1.222
netmask 255.255.255.0
gateway 192.168.1.1
Step 2: Amend the DNS
After set static IP address, it can’t analytic domain name (i.e. can’t browse external network).
We should set the DNS first. Edit /etc/resolv.conf
still can’t work, because it will be overtritten after every-restart in Ubuntu system.
Revising /etc/resolv.conf.d/base
is one way.
$sudo vi /etc/resolv.conf.d/base
Append DNS information.
nameserver 8.8.8.8 # Google DNS Server
nameserver 8.8.4.4
nameserver 202.127.207.1 # Hefei CAS DNS Server
# other DNS Server of Telecom operators
Final restart network configuration. Enjoy …
$sudo /etc/init.d/networking restart