Linux Learning Notes (ii)

Source: Internet
Author: User
Tags get ip

The previous section learned the virtual machine installation Centos7, which is configured in the network,

1. Obtain the IP and view the network card name

First turn on the virtual machine,

Enter the root return, and then enter the password, the password is not displayed, hit the password to enter

After logging in as shown, the above line shows the time of the last login,

Input

Dhclient

Get the IP address, after executing the command, wait a moment, no error message, and return to the previous interface, it means that the success,

And then enter

IP addr


Remember the IP and NIC name, click Edit in the upper left corner of the virtual machine

Virtual Network Editor

Point Vmnet8, and note that the following is the NAT mode,

Click Nat Settings

Make a note of the gateway with the subnet mask, here I am the gateway: 192.168.40.2 Subnet Mask: 225.225.225.0

Back in the virtual machine, enter

Vi/etc/sysconfig/network-scripts/ifcfg-ens33

This command is to edit the network card configuration, opened, ENS33 is the NIC name, may be different for everyone, this with their own, do not copy

Press ' I ' to enter edit mode, there will be an insert at the bottom left


, the cursor moves to Bootproto to change DHCP to static IP

Change Onboot=no to Onboot=yes to set the NIC to start with the system, add a few lines at the end

ipaddr=192.168.40.133netmask=225.225.225.0gateway=192.168.40.2dns1=119.29.29.29

IPADDR for the previous IP Addr command obtained by the Ip,netmask is the subnet mask, Gateway is the gateways, (gateway and IP each person's different, to learn to work, to change this information to their own, Learn to remember not to blindly copy the hard set) DNS1 is the public DNS of the designated domestic Dnspod company, modify the configuration file must carefully check whether the word is spelled correctly, the above modifications and additions are complete, press the ESC key to exit the insert mode, and then enter ': Wq ' save and exit,

After modifying the NIC configuration file, you need to restart the network service by executing the following command

Systemctl Restart Network.service


Then re-enter dhclient to get IP

It will be an error.

This service is now running and needs to be exited before execution,

Input

Dhclient-r

Close the Dhclient service, and then re-execute dhclient get IP

Enter IP addr View IP again

Input

Ping-c 4 www.baidu.com


See if you can link the extranet

, the network configuration is complete and CENTOS7 has successfully connected to the network.


Linux Learning Notes (ii)

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.