Ubuntu Command set IP gateway DNS

Source: Internet
Author: User
Tags nameserver

This article is reproduced, describes how Ubuntu set up IP and network to connect to the network

If you are using Ubuntu in a virtual machine, please refer to my previous article virtual machine net to set up the Network Settings section of the extranet, first set up the host network, and then configure the virtual machine Ubuntu IP and gateway

If the host operating system is Ubuntu, please directly refer to the following settings

The contents are reproduced as follows:

1. Check if connectivity is possible, ping the gateway using the ping command
The beginning is always real unreachable
2. Set IP
sudo ifconfig eth0 133.133.133.190 netmask 255.255.255.0
This sets the IP address and subnet mask of the NIC Eth0
3. Set the gateway sudo route add default GW 133.133.133.40
4. Ping the gateway to ping through
5. Set the DNS modification/etc/resolv.conf in which to add
NameServer DNS Address 1
NameServer DNS Address 2
Complete.
Once this is set up, the next time it appears, the IP will change.


Permanently modify Ubuntu LINUX IP
First, use the command to set the IP address of Ubuntu
1. Set IP sudo ifconfig eth0 203.171.239.155 netmask 255.255.255.224 so that the IP address and subnet mask of the NIC Eth0 is set
2. Set the gateway sudo route add default GW 203.171.239.129
3. Set the DNS modification/etc/resolv.conf, where nameserver DNS is added to address 1 nameserver DNS address 2 is complete. However, after this setup, it seems that the IP does not exist at the next boot time.
Second, directly modify the system profile Ubuntu network configuration file is:/etc/network/interfaces Open after you can set up DHCP or manually set the static IP. Front auto eth0, let the network card boot automatically mount.
1. Configure the network card edit file in dhcp, switch to/etc/network/interfaces: Specify the following command, sudo vi/etc/network/interfaces

Replace the line with the following line for eth0:

# The primary network Interface-use DHCP to find our address

Auto Eth0 iface

Eth0 inet DHCP

Use the following command to make the network settings effective: sudo/etc/init.d/networking restart

You can also enter the following command directly below the command line to get the address sudo dhclient eth0
2. Configure a static IP address for the NIC to edit the file

/etc/network/interfaces:sudo vi/etc/network/interfaces

Replace the line with the following line for eth0:

# The Primary network interface

Auto Eth0

Iface eth0 inet Static

Address 203.171.239.155

Gateway 203.171.239.129

Netmask 255.255.255.224

#network 203.171.239.128 #broadcast 192.168.3.159

Replace the above IP address with your own. Use the following command to make the network settings effective: sudo/etc/init.d/networking restart
3. Set a second IP address (virtual IP address) to edit the file

/etc/network/interfaces:sudo vi/etc/network/interfaces

Add the following line to the file:

Auto eth0:1 iface eth0:1 inet static address 192.168.1.155 netmask 255.255.255.0 work x.x.x.x broadcast x.x.x.x Gateway X. x.x.x fill in all information, such as address,netmask,network,broadcast and gateways, according to your situation. Use the following command to make the network settings effective: sudo/etc/init.d/networking restart
4. Set the host name (hostname) Use the following command to view the host name of the current host: Sudo/bin/hostname use the following command to set the host name of the current host: Sudo/bin/hostname newname when the system starts, it Etc/hostname to read the name of the host. 5. Configure DNS First, you can add some host names and IP addresses for these host names in/etc/hosts, which is a static query that uses native computers simply. To access the DNS server for querying, you need to set the/etc/resolv.conf file. Assume that the IP address of the DNS server is the contents of the 203.171.230.6 resolv.conf file: Search test.com nameserver 203.171.230.6 Restart Network:/etc/init.d/networking Restart

PS: According to the above, in virtual machine VMware installed Ubuntu, virtual Machine network connection mode is NET, set up a static IP connection network, I have tested, directly modify the Resolv.con and interfaces way can ensure that the IP set after boot still exists.

After Setup cannot connect the network, welcome message, discuss together, hehe!

Original address: http://hi.baidu.com/yinjiubo_java/blog/item/3c4e5bf4a70768e77709d7c4.html

Ubuntu Command sets IP gateway DNS

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.