In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
What is routing?
Routing refers to the activity of transmitting packets from the origin station to the destination station through interconnected networks. In the routing process, packets usually pass through one or more transit nodes (that is, routers). These routers forward the packet along an optimal path to the destination.
What is a router?
Routers are used to connect different networks and are the hub where networks are connected to each other. The main job of a router is to find an optimal transmission path for each packet that passes through the router and effectively transmit the data to its destination.
What is a gateway?
The gateway (GATEWAY) implements network interconnection above the network layer.
Lab 1: simulate a router so that two hosts who are not on the same network segment can communicate with ping
First, determine which virtual machine is going to be set up as a router, and add two network cards to the virtual machine. I am setting the server side as a router.
In the real machine, switch to the superuser root and enter the command: virt-manager
Double-click server and click "Light bulb"
Select Add Hardware-- > network-- > Device model: select virtio-- > Finish
Then set the ip for two different network segments. What I set here is 172.25.254.224 and 1.1.1.224.
Set the ip of another virtual machine to 1.1.1.124
Ping the virtual machine set as the router and the host on the same network segment to see if you can ping.
On the routing side:
Sysctl-a | grep ip_forward # # check whether kernel routing is enabled. 1 is enabled, 0 is not enabled, and if no communication is enabled, it is not enabled.
Not enabled, write in / etc/sysctl.conf file:
The purpose of sysctl-p is to make it work:
With the firewall on, turn on the 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, we tried the ping172.25.254 network segment on the client side and found that it was successful.
You can also log on to the real machine.
Over!
Lab 2: virtual machine networking
The main idea is to simulate the real machine as a router
Now that the real machine is connected to the Internet, you can ping Baidu to check the IP of the real machine.
Sysctl-a | grep ip_forward # # check whether kernel routing is enabled systemctl start firewalld # # enable firewall firewalld-cmd-- add-masquerade # # enable firewall camouflage
On the client side, set the ip to the same network segment as the real machine, and I set it to 172.25.254.124
Set the gateway to the real machine ip172.25.254.1 and restart
Ip183.232.231.172 of ping Baidu
You can access Baidu by entering an ip address.
Over!
Note: there are two ways to modify the gateway:
Vim / etc/sysconfig/network-scripts/ifcfg-eth0 # # set the gateway of a separate network card vim / etc/sysconfig/network # # set the global gateway
The global gateway is set to take effect on all network cards, and all packets are thrown to this gateway when accessing the external network. Restart the network after both settings are completed.
The above is the detailed integration of routing and virtual machine networking in Linux introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to the website!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.