In CentOS 7, configure the static IP address and centosnat in NAT mode.

Source: Internet
Author: User

In CentOS 7, configure the static IP address and centosnat in NAT mode.

CentOS 7 virtual machine has been installed in Vmware and NAT mode is selected

Automatically obtain IP commands
dhclient
View IP addresses
ip add

The following information is available:

ens33:
inet 192.168.150.128/24

This is the IP address of my VM

In VMware, choose "edit"> "Virtual Network Editor"> "VMnet8" from the menu bar, and click "NAT Settings" below to view the gateway IP address.

My gateway IP Address: 192.168.150.2

View the files in/etc/sysconfig/network-scripts (press the Tab twice)

ls /etc/sysconfig/network-scripts/ifcfg-ens33
Edit ifcfg-ens33
vi /etc/sysconfig/network-scripts/ifcfg-ens33

Press I to enter the editing mode.

Modify the following content

BOOTPROTO=static

Set to static

ONBOOT=yes

Load the NIC information when starting the Virtual Machine

IPADDR=192.168.150.128NETMASK=255.255.255.0GATEWAY=192.168.150.2DNS1=119.29.29.29

The above is my IP information, which is viewed earlier

Press Esc and enter: wq to save and exit.

Restart NETWORK SERVICE
systemctl restart network.service

View IP addresses

ifconfig

View route table

route -n
Ping connectivity test
ping www.baidu.com

Windows CMD input command

ping 192.168.150.128

Ping indicates that the physical machine and virtual machine can communicate with each other.

If the VM does not contain the ifconfig command

First, make sure that the virtual machine can be connected to the Internet.

Enter yum install-y net-tools

Related Article

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.