Linux Learning Summary (ii) network configuration-nat mode static IP configuration Chapter

Source: Internet
Author: User

One: DHCP service validation

1: Before we have installed the CentOS, we chose the network mode for the NAT mode, then how can we quickly implement virtual machine system access to the extranet? Can you go directly to the Internet, let's try
Ping baidu.com

2: Prompt unknown name or service, come to us to view the next IP, I have been using ifconfig, just see can use IP addr, we use IP addr try
IP addr

3:ENS33 is our network card, we found that there is no IP address assigned, that of course not on the network, then we can use the DHCP service to quickly assign a network card IP, and then see if we can access the Internet, we enter
Dhclient enter, and then input ping baidu.com see the effect

4: We found that the discount network, we ifocnfig see the DHCP service has been assigned the IP address, note the IP address 192.168.226.129, after the use of

Note: Just as we entered dhclient, we found that the cursor paused a few seconds to come out, no feedback results, this is a DHCP configuration process, Linux Everyone found a small rule, no result is the best result, (no error)

two static IP network service configuration

1: But the above so that after the CentOS restart, the IP will be lost, and have to restart DHCP, this is very troublesome, then we configure this IP as a static IP, see if we can achieve
Next we find the gateway and subnet mask in the virtual machine Nat settings, based on the path lookup
Virtual machine edit Bar point in, find the Virtual network editor, click

Then point to the lower right corner NAT settings

2: Write down the gateway address: 192.168.226.2, subnet mask 255.255.255.0, and the IP address you just noted 192.168.226.129 remember that according to the actual situation,
3: Next we want to edit the NIC configuration file, vi+ the profile path, open the configuration file
Vi/etc/sysconfig/network-scripts/ifcfg-ens33
, 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.226.129
netmask=225.225.225.0
gateway=192.168.226.2
dns1=119.29.29.29

Note: The above VI has just entered for the command mode, VI has three modes, command mode, edit mode, tail line mode, the default is the command mode, and then edit the mode to edit the content, input I can be from the command mode into the editing mode, vi will appear below the insert prompt. The above modification of the configuration file is the first known VI, after modification, press ESC to exit the edit mode, and then enter ": Wq" Save exit
4: What work have we done? First we change the IP allocation method, the DHCP changed to static, and then let the configuration boot effective onboot No to Yes, add four lines at the end, followed by IP address, subnet mask, gateway, and public DNS
5: Down to restart the network
Systemct1 Restart Network.service
Re-test the ping baidu.com to see if you can sisu the net

Configuration complete at this point

Linux Learning Summary (ii) network configuration-nat mode static IP configuration Chapter

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.