Ubuntu-12.04-server configuration modify static IP Address

Source: Internet
Author: User

 

 

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.