Set static IP addresses and static IP addresses

Source: Internet
Author: User
Tags nameserver

Set static IP addresses and static IP addresses
Set IP
$ Sudo vi/etc/network/interfaces
Autolo
Iface lo inet loopback
Add the following content
Autoeth0
Iface eth0inet static
Address192.168.0.221 <-enter the ip address that is not used for self-check.
Netmask00000000255.0
Gateway192.168.0.1 <-enter the same gateway as the host
Save and disable gedit.
In this way, the IP address does not take effect immediately. Need to execute
$ Sudo/etc/init. d/networking restart
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 vi/etc/resolv. conf
Name server192.168.1.1
Name server8.8.8.8
Save and close, and now you can access the Internet.
However, after Ubuntu12.04 is restarted, The nameserver set in/etc/resolv. conf will be cleared.
If you want to define a nameserver as always valid, there are two methods:
A is added to the NIC configuration file:
Iface eth0inet static
Address192.168.3.3
Netmask00000000255.0
Gateway192.168.3.1
Dns-nameservers114.114.114.1148.8.8.8
B. modify the configuration file of the resolvconf service:/etc/resolvconf/resolv. conf. d/base
Clear the original content and write the following content
Name server8.8.8.8
In this way, you can ensure that the configuration will be written to/etc/resolv. conf when the machine or resolvconf service is restarted.
In fact, there are always prompts in/etc/resolv. conf, but I did not pay attention to them:
DONOTEDITTHISFILEBYHAND--YOURCHANGESWILLBEOVERWRITTEN"
Attached Nic settings commands:
View Nic information: ifconfig
Set a nic ip Address: ifconfig eth0192.168.1.10netmask1_255.255.0
Restart the NIC to make the settings take effect: sudo/etc/init. d/networking restart
Change MAC address: ifconfig eth0hwetherxx: xx
View route information: route-n
Add Gateway
Sudorouteadddefaultgw192.168.10.1
Delete Gateway
Sudoroutedeldefault
DNS server settings (Ubuntu)
1. Two free and easy-to-use DNS servers
GoogleDNS: 8.8.8.8; 8.8.8.4
OpenDNS: 208.67.220.220; 208.67.222.222
2. view the local DNS Server
View DNSserver: nslookupwww.baidu.com
Update dns settings, sudoresolvconf-u
Temporarily set ubuntustaticip and be able to access the Internet
1. ipnetmask
Sudoifconfig eth0192.168.0.167netmask1_255.0
2. dns
Sudovi/etc/resolv. conf
Add
Nameserver8.8.8.8
3. Gateway
Sudorouteadddefalutgw192.168.10.1
Sudoroutedeldefault
How to Set static IP addresses

Right-click "Network Neighbor", select "properties", right-click "Local Connection", select "properties", click "Internet Protocol", and then click "properties". Then, select "Use the following IP address to connect the gateway and dns address to the same vro in a CIDR block. set it to the ip address of the router.

How to Set static IP addresses

Right-click "Network Neighbor", select "properties", right-click "Local Connection", select "properties", click "Internet Protocol", and then click "properties". Then, select "Use the following IP address to connect the gateway and dns address to the same vro in a CIDR block. set it to the ip address of the router.

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.