What is routing? Routing refers to the activity of transmitting data packets from the source station to the destination station through interconnected networks. During the routing process, data packets usually pass through one or more transit nodes (i.e. routers). These routers along the way will forward the data packets along the best path to the destination. What is a Router? A router is used to connect different networks and is the hub that connects networks to each other. The main job of a router is to find an optimal transmission path for each data packet passing through the router and transmit the data to the destination efficiently. What is a Gateway? Gateway (GATEWAY) realizes network interconnection above the network layer. Experiment 1: Simulate a router to allow two hosts that are not in the same network segment to ping each other First, determine which virtual machine will be set up as a router and add two network cards to this virtual machine. I set the server as a router. Double-click server and click the "light bulb" Select Add Hardware ——>network——>Device model: Select virtio——>Finish Then set two IP addresses in different network segments. I set them to 172.25.254.224 and 1.1.1.224. Set the IP address of another virtual machine to 1.1.1.124 Ping the virtual machine set as a router and the host in the same network segment to see if they can ping through. On the router side: sysctl -a | grep ip_forward ##Check whether kernel routing is enabled, 1 is enabled, 0 is disabled. If communication is not possible, it means it is disabled. If it is not enabled, write in the /etc/sysctl.conf file: The purpose of sysctl -p is to make it take effect: With the firewall turned on, enable permanent firewall camouflage: The gateway is not set on the client at this time. We set the gateway (1.1.1.224) in /etc/sysconfig/network and restart the network. Finally, I tried to ping the 172.25.254 network segment on the client and found that it was successful. Can also log in to the real machine over! Experiment 2: Virtual Machine Networking The main idea is to simulate the real machine as a router. At this time, the real machine is connected to the Internet, and you can ping Baidu to view the IP address of the real machine. sysctl -a | grep ip_forward ##Check whether the kernel routing function is enabled systemctl start firewalld ##Open the firewall firewalld-cmd --add-masquerade ##Open the firewall masquerade On the client, set the IP address to the same network segment as the real machine. I set it to 172.25.254.124 Set the gateway to the real machine ip172.25.254.1 and restart Ping Baidu's IP address 183.232.231.172 You can access Baidu by entering the IP address! over! vim /etc/sysconfig/network-scripts/ifcfg-eth0 ##Set the gateway of a separate network card vim /etc/sysconfig/network ##Set the global gateway Setting the global gateway will take effect on all network cards, and all data packets will be sent to this gateway when accessing the external network. After completing both settings, you need to restart the network. The above is a detailed introduction to setting up routing and virtual machine networking in Linux. I hope it will be helpful to everyone. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: Vue implements picture verification code when logging in
>>: mysql5.7.14 decompression version installation and configuration method graphic tutorial (win10)
I would like to quote an article by Zhang Xinxu a...
The sort command is very commonly used, but it al...
We all know that the performance of applications ...
Table of contents Business requirements: Solution...
Preface Under Linux, compilation and linking requ...
In the MySQL database, after tables are associate...
Preface: Because many business tables use design ...
1. Leading fuzzy query cannot use index (like ...
Preface In WeChat applet, you can use globalData ...
1. Test environment name Version centos 7.6 docke...
Table of contents Preface 1. insert ignore into 2...
⑴ Content determines form. First enrich the conten...
Here, clever use of CSS techniques allows you to g...
This article uses examples to illustrate common b...
Table of contents 1. Implementation process 2. Di...