Centos Experiment 4: Configure dual-nic for virtual machines to install centos servervirtualbox Virtual Machine network settings

Source: Internet
Author: User
Tags centos server

My centos Server is a virtual machine (installed with centos server) implemented by VMware Workstation on Windows 7. Why should I configure dual NICs for it?

 

Cause 1: The company controls the Internet permissions of the computer and binds the domain account and IP address. Therefore, a network adapter in Nat mode is required in the virtual machine to access the Internet through the host.

Cause 2: I need to use SSH to log on to the VM on other computers in the company. This requires a network card in the bridged mode to set the Virtual Machine IP address to the same network segment as the host.

 

For more information about virtual machine network configuration, see virtualbox Virtual Machine network settings.

 

1. Configure the Virtual Machine and add a bridged NIC based on the original Nat Nic.

 

2./etc/sysconfig/network-scripts is the network configuration directory of centos. The configuration file for the first NIC (NAT) is the ifcfg-eth0, the configuration file for the second NIC (bridged) is the ifcfg-eth1, and so on. Ifcfg-eth0 file installed after the default should exist, the original content of the file should be similar to the following:

 
Device = "eth0"Hwaddr= "00: 0C: 29: 16: 7A: ca"Nm_controlled= "Yes"Onboot= "No"

Replace the file with the following content:

Device =Eth0bootproto=Dhcponboot= Yes

This Nic uses DHCP to dynamically allocate IP addresses and use the DHCP service provided by VMware.

 

3. Configure the second NIC (bridged ). The NIC configuration file is a ifcfg-eth1, the default does not exist, you need to create the file first. After the file is created, replace it with the following content:

 
Device =Eth1bootproto=Staticipaddr= 192.168.12.215Netmask= 255.255.255.0Onboot= Yes

The IP address 192.168.12.215 is specified statically for this Nic. Other parameters (subnet mask and gateway) depend on the network conditions.

 

4. Restart the network service. Restart the network service to check whether the current configuration is correct. Because onboot = yes is set in both configuration files, the network service is automatically set according to the configuration file after the server restarts next time.

 
[Root @ localhost ~] # Service network restart

 

5. OK. Run the ifconfig command to check the final result.

[Root @ localhost ~] #Ifconfig  Eth0 link encap: Ethernet hwaddr  00 : 0C: 29 : 16  : 7A: Ca Inet ADDR:  192.168 . 197.143 Bcast: 192.168 . 197.255 Mask: 255.255 . 255.0  Inet6 ADDR: fe80: 20c: 29ff: fe16: 7aca /64  Scope: link up broadcast running Multicast MTU:  1500 Metric: 1  RX packets:  28 Errors: 0 Dropped: 0 Overruns: 0 Frame: 0  TX packets:  48 Errors: 0 Dropped: 0 Overruns: 0 Carrier: 0  Collisions:  0 Txqueuelen: 1000  RX Bytes:  3618 ( 3.5 Kib) TX Bytes: 6508 ( 6.3  Kib) eth1 link encap: Ethernet hwaddr  00 : 0C: 29 : 16 : 7A: D4 Inet ADDR:  192.168 . 12.215 Bcast: 192.168 . 12.255 Mask: 255.255 . 255.0  Inet6 ADDR: fe80: 20c: 29ff: fe16: 7ad4 / 64  Scope: link up broadcast running Multicast MTU:  1500 Metric: 1  RX packets: 8524 Errors: 0 Dropped: 0 Overruns: 0 Frame: 0  TX packets:  275 Errors: 0 Dropped: 0 Overruns: 0 Carrier: 0  Collisions:  0 Txqueuelen: 1000 RX Bytes:  823502 ( 804.2 Kib) TX Bytes: 31804 ( 31.0  Kib) lo link encap: local loopback Inet ADDR:  127.0 . 0.1 Mask: 255.0 . 0.0  Inet6 ADDR :::  1 / 128 Scope: Host up loopback running MTU:  16436 Metric: 1  RX packets:  0 Errors: 0 Dropped: 0 Overruns: 0 Frame: 0  TX packets:  0 Errors: 0 Dropped: 0 Overruns:0 Carrier: 0  Collisions:  0 Txqueuelen: 0  RX Bytes:  0 ( 0.0 B) TX Bytes: 0 ( 0.0 B)

 

Reference link:

    • What is the difference between the Linux Command route add default Dev eth0 and route add default GW eth0?
    • Linux route command examples (how to add route in Linux)
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.