Set static IP address in Ubuntu to solve the problem that you need to reset after restart.

Source: Internet
Author: User
Tags nameserver
In ubuntu 8.10, gnome is used by default, and DHCP is used by default to automatically obtain IP addresses. Set the static IP address and restart it.

1. Set IP
Sudo gedit/etc/Network/interfaces

Auto Lo
Iface lo Inet loopback # Lo is the local loopback address: 127.1

Auto eth0

Iface eth0 Inet static

Address 192.168.1.152

Gateway 192.168.1.1

Netmask 255.255.255.0

Network 192.168.1.0

Broadcast 192.168.1.255 # Set the IP address of eth0

In this way, the IP address does not take effect immediately.
Sudo/etc/init. d/networking restart

2. At this time, you can ping the computer in the LAN. But cannot access the Internet because DNS is not set. The DNS information is saved in/etc/resolv. conf. Once changed, it takes effect immediately.

Sudo gedit/etc/resolv. conf

Nameserver 208.67.222.222

Nameserver 208.67.220.220

Now you can access the Internet.

Attached Nic settings commands:

View Nic information: ifconfig

Set a nic ip Address: ifconfig eth1 192.168.1.10 netmask 255.255.255.0

Restart the NIC to make the settings take effect: sudo/etc/init. d/networking restart

Change MAC address: ifconfig eth0 HW ether XX: xx

View route information: route-n

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.