When I installed the server of ubuntu 12.04 server a few days ago, the IP address was wrong. As a result, the server could not access the internet. I modified the IP address again today. Here is a summary.
1. Configure static IP addresses
Sudo VI/Etc/Network/interfaces
The original content uses DHCP to assign IP addresses by default, as shown below:
Auto loiface lo Inet loopbackAuto eth0iface eth0 Inet DHCP
Modify the eth0 IP Address Allocation Method to static allocation (Static).IP address,Subnet Mask,Gateway(Only the three items can be set) and other information
# The loopback network interface
Auto loiface lo Inet loopback# The primary network interfaceAuto eth0# Set to automatically start the eth0 Interface# Iface eth0 Inet DHCPIface eth0 Inet static# Configuring static IP addressesAddress192.168.145.190# IP AddressNetmask 255.255.255.0# Subnet MaskGateway 192.168.145.254# Default Gateway
# Network 192.168.145.0
# Broadcast 192.168.145.255
2. Set the DNS server
Here, if you only modify/etc/resolv. conf, the DNS configured in the file is automatically changed to the default value after the restart. Therefore, you need to modify DNS permanently.
Sudo VI/Etc/resolvconf/resolv. conf. d/base
Add the following content:
Nameserver 192.168.145.2nameserver 8.8.8.8# Set the local DNS server address here (for online search)
3. Restart
Restart the network networking service
/Etc/init. d/networking restart
Or restart the system.Sudo rebootYes.
4. view the current IP Address
Ifconfig