Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Using VM virtual machine to connect the network

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Today we are going to do an experiment on configuring routing, which will involve the following knowledge points

(1) in the process of building the environment, we need to clone the virtual machine and modify the network card. These are two very important operations.

(2) configure the router

Let me explain this experiment step by step.

One: experimental purpose

Six virtual machines, four routers and two PCs are used to connect the network.

Second: configure environment 1 to clone virtual machine 1.1: clone virtual machine and modify network card (method 1)

There are two ways to clone a virtual machine. Let's start with the first one.

(1) make a copy of the virtual machine file and open it in VM. After opening, the following window pops up. We want to select'I have copied the virtual machine'. Note that the MAC address of the network card in the copied virtual machine will change automatically after selecting this option!

(2) check the Nic MAC of the copied virtual machine, and it is true that it has changed. And found that the name of the network card is not eth0,eth2, so the next step is to modify the network card.

(3)

Vim / etc/udev/rules.d/70-persistent-net.rules # change the last NAME= "eth3" corresponding to the network card to be modified to the required name ethtool-I eth3 # View the driver module name modprobe-r pcnet32 # unload module modprobe pcnet32 # reload module cd / etc/sysconfig/network-scripts # change the configuration file name of the original network card in this directory to the ifcfg- network card name Then modify the configuration file to change the DEVICE= to the name of the network card ifdown eth0 ifup eth0

(3) View the IP of the virtual machine after modifying the network card

(4) restart the network service to see if it is normal

Summary: this method can indeed copy the machine, but there is a drawback, that is, it takes up a lot of space, and then we go on to learn the second method, which takes up very little space and is very convenient. We are also beginning to configure our experimental environment.

1.2. Clone the virtual machine and modify the network card (method 2)

Follow these steps on VM: virtual machine-manage-clone

Follow the figure below to complete the copy of the virtual machine.

2: Nic settings, IP settings

2.1 in order to prevent running too many virtual machines from causing too much burden on the physical machine, we first set the virtual machine to boot command line, do not start the graphical interface, edit the following file, and change 5 to 3

Vim / etc/inittab

2.2 Network Card Settings

Add the network card, as shown in the picture, and cancel the dhcp service

2.3 configure the virtual machine, as shown in the following figure. (four routers)

2.4Setting IP

Since we have cancelled the DHCP service, we need to manually set up the IP and configure the network card. (this step was introduced when cloning the virtual machine. I won't repeat it, let's just take a look at the file.)

DEVICE=eth2

TYPE=Ethernet

ONBOOT=yes

NM_CONTROLLED=yes

BOOTPROTO=static

IPADDR=1.1.1.251

NETMASK=255.0.0.0

HWADDR=00:0C:29:41:38:0B

DEFROUTE=yes

PEERDNS=yes

PEERROUTES=yes

IPV4_FAILURE_FATAL=yes

IPV6INIT=no

NAME= "System eth2"

In this way, our experimental environment is set up.

Third: the conception of drawing

IV: configure the route # route1route add-net 3.0.0.0etc/sysctl.conf 8 gw 2.2.2.252route add-net 4.0.0.0etc/sysctl.conf 8 gw 2.2.2.252route add-net 5.0.0.0net 8 gw 2.2.2.252vim / etc/sysctl.conf # enable route forwarding iptables-F#route2route add-net 1.0.0.0etc/sysctl.conf 8 gw 2.2.2.251route add-net 4.0.0.0etc/sysctl.conf 8 gw 3.3.3.253route add-net 5.0.0.0 3.3.3.253route add 8 gw 3.3.3.253vim / etc/sysctl.conf # enable route forwarding iptables-F#route3route add-net 1.0.0.0 gw 3.3.3.252route add-net 2.0.0.0 gw 3.3.3.252route add 8 gw 3.3.3.252route add-net 5.0.0.0 net 8 gw 4.4.4.254vim / etc/sysctl.conf # enable route forwarding Iptables-F#route4route add-net 1.0.0.0 net 8 gw 4.4.4.253route add-net 2.0.0.0 gw 4.4.4.253vim 8 gw 4.4.4.253route add-net 3.0.0.0 gw 4.4.4.253vim / etc/sysctl.conf # enable route forwarding iptables-F#PC1route add default gw 1.1.1.251#PC2route add default gw 5.5.5.254

The result is as follows:

Five: experimental results

Successfully connected to the network.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report