Linux (1): linux change IP address command _ change DNS _ change default gateway _ change subnet mask _ host name, linuxdns

Source: Internet
Author: User

Linux (1): linux change IP address command _ change DNS _ change default gateway _ change subnet mask _ host name, linuxdns

How to use commands to change the linux IP address, DNS, and subnet mask, and add a Linux virtual machine to the Virtual Machine (vitrualBox;

Installation: http://pan.baidu.com/s/1sjJPhP7


After installation, go to the Linux desktop, which is like this:



Press CTRL + ALT + F2 to enter the command line window, log on, and enter:

vi  /etc/sysconfig/network-scripts/ifcfg-ethx

The setting window is opened. By default, if you only have one Nic, you can do this. If there are multiple NICs, the NIC may be divided into 0 and 1:

vi  /etc/sysconfig/network-scripts/ifcfg-ethx0vi  /etc/sysconfig/network-scripts/ifcfg-ethx1

If there are two NICs, set them separately;

Open a file, which will display the following:



You just need to set the parameters in it, as shown in the annotation:


Press the "Insert" key on the disk to enter the change. After all the configurations are complete, press the Esc key and enter the following three letters: wq: Write, save, and exit;

Then execute the command

vi  /etc/sysconfig/network-scripts/ifcfg-ethx

We can see that our changes have been saved.

Set the local virtual Virtualize uralbox-Host-only Network. Right-click the Network in the lower right corner and open the Network center. This item is displayed:



Click Settings-> properties-> IP4-> Settings



The IP address here is preferably the gateway set in the virtual machine;

After completing the settings, let's try to see if the Ping is successful:


If you can Ping the host name, set its host name as follows:

By now, the system of the virtual machine can be used. We can connect to the system by using a remote tool. We use putty to download the Chinese version of putty.



Then, log on. After the logon is successful, run vi/etc/hosts.

Go to settings and press "insert" to set the settings. The format is IP host name, for example:



After the modification, Press Esc and enter wq to save and exit. At the same time, change the command to vi/etc/sysconfig/network.

Set the Host Name:


The right side of the equal sign is the host name to be set. After setting, press "ESC" and enter: wq to exit;

It does not take effect after exiting. Enter the command hostname redhat1 and press enter, and enter su-to change it temporarily:




But this is only temporary. If you want to change it permanently, You need to restart Linux.


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.