[Linux] -- Failure to access the Internet when Ubuntu server 12.04 is restarted

Source: Internet
Author: User
Tags nameserver

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.

Related Article

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.