Linux Network Configuration--to realize the communication of different network segment virtual machines

Source: Internet
Author: User

First we need to understand some basic commands for network configuration

One: Basic command
    1. CENTOS6 Network card name modification (the modification of the NIC name can make it easier and faster to configure):

in the Linux in the //etc/udev/rules.d/70-persistent-net.rules in the name of the network card is stored in the basic information,

View and modify through Vim/etc/udev/rules.d/70-persistent-net.rules.

  

will be NAME changes after saving exit , and then through the command

Modprobe-r eth1; Modprobe eth1 unload driver and load driver to reread Udev settings

  

modifying the NIC is a need to be aware that in case of modification errors, you need to remember the difference between the NIC's mac .

2. Modify the configuration file of the NIC

Each NIC's configuration file is placed in the/etc/sysconfig/network-scripts/ directory, which we can see

Configuration file for network card, opening file

Is the detailed configuration of the NIC

then we just need to know

    1. device is the device name of the NIC
    2. bootproto=dhcp Span style= "font-family: Arial" > represents the network adapter's ip dhcp auto get
    3. hwaddr represents the mac of this NIC Span style= "font-family: Arial" > address
    4.   Modify IP address    will bootproto=dhcp  Delete, or =none|static

                    Add the following two lines

                  ipaddr=2.2.2.2

                  netmask=255.255.255.0

    5.  Note: you need to modprobe-r eth1000 to take effect after you modify the file, Modprobe eth1000 unload the drive and load the drive. 

  

Two:ImplementVmwarecommunication between the next two different network segments1.we need toVMwareconfigure two different network segments, three virtual machines. Configured as follows

The configuration of Vmnet2 and VMnet3 is shown. Then we need to clone three virtual machines. Pc1 and PC2

and R1(as routers)

Pc 1 Add network adapter, select Network Segment as Vmnet2

PC2 Network Segment is vmnet3,R1 's network segment is vmnet2 and vmnet3

We're going to draw a diagram before we configure it.

1.Configure the virtual machine'sIpaddress and network card name toPC1as an examplePc1the configuration

view current NIC and IP via ifconfig command

We usually put the net at the beginning of the 172 in the first place, andthe192 in the second place. So we need to modify the NIC name.

Vim/etc/udev/rules.d/70-persistent-net.rules

At this point we need to change the network card name by the different MAC address of the NIC to get the result we want. "eth4"needs to be replaced with "eth0", "eth5" replaced by "eth1". "eth3"replaced by "eth2". , it is not difficult to find "eth3" (will be replaced by "eth2") is the network card we added.

save after modifying, and then

Modprobe-r eth1000; Modprobe eth1000 unload driver and load driver to reread Udev settings

  

The effect is as follows:

The NIC name was modified successfully.

Now we need to modify the configuration files for each NIC. Through/etc/sysconfig/network-scripts/, the configuration files are all in this place. We need to edit the eth2 configuration file.

Vim  /etc/sysconfig/network-scripts/ifcfg-eht2

  

add an IP address:192.18.33.33

One gateway:255.255.255.

MAC Address modified to

Save Exit then

Modprobe-r eth1000; Modprobe eth1000 Reload     all network cards

  

And then view

PC1 NIC configuration is complete.

R1the NIC configuration

Ifconfig View

Modify the NIC name

Change Eth3 to eth1 eth4 eth2 eth6 to Eth3,eth5 Replace eth0 ;

Save exit, Modprobe-r eth1000; Modprobe eth1000 Reload     all network cards

  

View

The modification was successful. the IP addresses of the eth2 and eth3 are configured

eth2 IP:192.18.33.251

Mac address is 00:50:56:36:85:f2

Eth3 IP:192.18.22.251

Mac address is:00:50:56:36:1f:a3

Save exit, Modprobe-r eth1000; Modprobe eth1000 Reload     all network cards

  

View

Note: The ETH3 configuration file may not be present at this time , we need to add one manually.

The configuration was successful.

Configure PC2 as follows

At present, the IP of three network cards are set up.

We need to set up a route to PC1 and PC2.

2. Routing configuration:

  

Unicom success.

Linux Network Configuration--to realize the communication of different network segment virtual machines

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.