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

How to configure Virtual Router under CentOS7

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to configure virtual router under CentOS7". In daily operation, I believe that many people have doubts about how to configure virtual router under CentOS7. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to configure virtual router under CentOS7". Next, please follow the editor to study!

I. description of environment and requirements

In the local test environment, because the win7+vmware network card is too new to be recognized by vmware exsi, we have no choice but to install a win7 directly, and then turn on some temporary test virtual machines based on vmware workstation 12. Secondly, the local directly connected network segment 192.168.1.0 ip is limited, and you want to connect to these virtual machines directly from the local (figure win10) ssh, so consider using the ip forwarding function of linux.

The ip information of each node is listed in the above picture, and the red virtual machine acts as a soft route. after configuration, the win10 is directly ssh to the virtual machine.

II. Virtual routing server configuration

# View the network card information [root@centos7-router ~] # ip addr1: lo: mtu 65536 qdisc noqueue state unknown link/loopback 0000 qdisc pfifo_fast state up qlen 0000 brd 0000 brd 0000 inet 127.0.0.1 8 scope host lo valid_lft forever preferred_lft forever inet6:: 1eno16777728: mtu 1500 qdisc pfifo_fast state up qlen 1000 link/ether 00:0c:29:9c : eb:2d brd ff:ff:ff:ff:ff:ff inet 172.24.8.254/24 brd 172.24.8.255 scope global eno16777728 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe9c:eb2d/64 scope link valid_lft forever preferred_lft forever3: eno33554960: mtu 1500 qdisc pfifo_fast state up qlen 1000 link/ether 00:0c:29:9c:eb:37 brd ff:ff:ff:ff:ff:ff inet 192.168.1.175/24 Brd 192.168.1.255 scope global dynamic eno33554960 valid_lft 82384sec preferred_lft 82384sec inet6 fe80::20c:29ff:fe9c:eb37/64 scope link valid_lft forever preferred_lft forever### View routing table [root@centos7-router ~] # route-nkernel ip routing table # by default Each network card has a routing record based on this network segment destination gateway genmask flags metric ref use iface0.0.0.0 192.168.1.1 0.0.0.0 ug 10000 eno33554960172.24.8.0 0.0.0.0 255.255.255.0 u 10000 eno16777728192.168.1.0 0.0.0.0 255.255.255.255.0 u 10000 eno33554960### using ip command View route [root@centos7-router ~] # ip route listdefault via 192.168.1.1 dev eno33554960 proto static metric 100172.24.8.0 metric 10172.24.8.254 metric 100 192.168.1.0 ip forward 192.168.1.175 metric 100 # Open ip forward [root@centos7-router] # cp / usr/lib/sysctl.d/50-default.conf / usr/lib/sysctl.d / 50-default.conf.bk [root@centos7-router ~] # echo "net.ipv4.ip_forward = 1" > > / usr/lib/sysctl.d/50-default.conf [root@centos7-router ~] # grep ip_forward / usr/lib/sysctl.d/50-default.confnet.ipv4.ip_forward = 1 [root@centos7-router ~] # sysctl-p # restart os if it doesn't work

Add routes under the centos7-a host

# View the current ip information of the host [root@centos7-a ~] # ip addr list1: lo: mtu 65536 qdisc noqueue state unknown link/loopback 0000 qdisc pfifo_fast state up qlen 1000 link/ether 00100 brd 0000 00 inet 127.0.0.1 8 scope host lo valid_lft forever preferred_lft forever inet6:: 1scope host valid_lft forever preferred_lft forever2: eno16777728: mtu 1500 qdisc pfifo_fast state up qlen 1000 link/ether 00lance 0c : 29VV 57VV 26v 9d brd ff:ff:ff:ff:ff:ff inet 172.24.8.131 scope global dynamic eno16777728 valid_lft 1088sec preferred_lft 1088sec inet6 fe80::20c:29ff:fe57:269d/64 scope link valid_lft forever preferred_lft forever### 24 brd 172.24.8.255 scope global dynamic eno16777728 valid_lft 1088sec preferred_lft 1088sec inet6 fe80::20c:29ff:fe57:269d/64 scope link valid_lft forever preferred_lft forever### View current host routing information [root@centos7-a ~] # ip route list172.24.8.0/24 dev eno16777728 proto kernel scope link src 172.24 .8.131 metric 100 [root@centos7-a ~] # # author: leshami [root@centos7-a ~] # blog: http://blog.csdn.net/leshami[root@centos7-a ~] # ip route add default via 172.24.8.254 [root@centos7-a ~] # ip route listdefault via 172.24.8.254 dev eno16777728 172.24.8.0lash 24 dev eno16777728 proto kernel scope link src 172.24.8.131 metric # tested to virtual Router gateway ip connectivity [root@centos7-a ~] # ping 172.24.8.254-c 2 ping 172.24.8.254 (172.24.8.254) 56 (84) bytes of data.64 bytes from 172.24.8.254: icmp_seq=1 ttl=64 time=0.268 ms64 bytes from 172.24.8.254: icmp_seq=2 ttl=64 time=0.302 ms--- 172.24.8.254 ping statistics-- 2 packets transmitted 2 received, 0 packet loss Time 1000msrtt min/avg/max/mdev = 0.268 bytes of data.64 bytes from 0.285 ms### test to virtual router ip connectivity [root@centos7-a ~] # ping 192.168.1.175-c 2ping 192.168.1.175 (192.168.1.175) 56 (84) bytes of data.64 bytes from 192.168.1.175: icmp_seq=1 ttl=64 time=0.475 ms64 bytes from 192.168.1.175: icmp_seq=2 ttl=64 time=0. 443 ms--- 192.168.1.175 ping statistics-2 packets transmitted 2 received, 0% packet loss, time 1000msrtt min/avg/max/mdev = 0.443 ms 0.459 ms

IV. Configure routing under windows 10

# current environment c:\ > systeminfo | findstr buildos version: 10.0.14393 n build 14393os build type: multiprocessor free### to view the current routing information c:\ > route print-4====interface list 7.. 54 ab 3a xx b8 ea .intel (r) ethernet connection i219-v21...ac 2b 6e 5f 3b 57 .Microsoft wi-fi direct virtual adapter. = ipv4 route table====active Routes:network destination netmask gateway interface metric 0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.242 35 127.0.0.0 255.0.0.0 on-link 127.0.0.1 331 127.0.0.1 255.255.255.255 on-link 127.0.0.1 331 127.255.255.255 255.255.255.255 on- Link 127.0.0.1 331 172.24.10.0 255.255.255.0 on-link 172.24.10.1 291 172.24.10.1 255.255.255.255 on-link 172.24.10.1 291 172.24.10.255 255.255.255.255 on-link 172.24.10.1 291 192.168.1.0 255.255.255.0 on-link 192.168.1.242 291 192.168.1.242 255.255.255.255 on-link 192.168.1.242 291 192.168.1.255 255.255.255.255 on-link 192.168.1.242 291 192.168.16.0 255.255.255.0 on-link 192.168.16.1 291 192.168.16.1 255.255.255.255 on-link 192.168.16.1 291 192.168.16.255 255.255.255.255 On-link 192.168.16.1 291 224.0.0.0 240.0.0.0 on-link 127.0.0.1 331 224.0.0.0 240.0.0.0 on-link 192.168.1.242 291 224.0.0.0 240.0.0.0 on-link 192.168.16.1 291 224.0.0.0 240.0.0.0 on-link 172.24.10.1 291 255.255.255.255 255.255.255.255 on-link 127.0.0.1 331 255.255.255.255 255.255.255.255 on-link 192.168.1.242 291 255.255.255.255 255.255.255.255 on-link 192.168.16.1 291 255.255.255.255 255.255.255.255 on-link 172.24.10.1 291====persistent routes: none## # add persistent route c:\ > route add 172.24.8.0 mask 255.255.255.192.168.1.175-pokaccounc:\ > route print-4ipv4 route table====active routes:network destination netmask gateway interface metric 0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.242 35 127.0.0 255.0.0.0 on-link 127.0.0. 1 331 127.0.0.1 255.255.255.255 on-link 127.0.0.1 331 127.255.255.255 255.255.255.255 on-link 127.0.0.1 331 172.24.8.0 255.255.255.0 192.168.1.175 192.168.1.242 36 172.24.10.0 255.255.255.0 on-link 172.24.10.1 291 172.24. 10.1 255.255.255.255 on-link 172.24.10.1 291 172.24.10.255 255.255.255.255 on-link 172.24.10.1 291 192.168.1.0 255.255.255.0 on-link 192.168.1.242 291 192.168.1.242 255.255.255.255 on-link 192.168.1.242 291 192.168.1.255 255.255.255.255 on- Link 192.168.1.242 291 192.168.16.0 255.255.255.0 on-link 192.168.16.1 291 192.168.16.1 255.255.255.255 on-link 192.168.16.1 291 192.168.16.255 255.255.255.255 on-link 192.168.16.1 291 224.0.0.0 240.0.0.0 on-link 127.0.0.1 331 224.0.0.0 240.0.0.0 on-link 192.168.1.242 291 224.0.0.0 240.0.0.0 on-link 192.168.16.1 291 224.0.0.0 240.0.0.0 on-link 172.24.10.1 291 255.255.255.255 255.255.255.255 on-link 127.0.0.1 331 255.255.255.255 255 .255.255.255 on-link 192.168.1.242 291 255.255.255.255.255.255.255 on-link 192.168.16.1 291 255.255.255.255.255.255.255 on-link 172.24.10.1 291====persistent routes: # # the following is the added persistent routing record network address netmask gateway address metric 172.24.8.0255.255.255.192.168.1.175

Verify the connectivity between the two sides

# from ping windows 10 [root@centos7-a ~] # ping 192.168.1.242-c 2 ping 192.168.1.242 (192.168.1.242) 56 (84) bytes of data.64 bytes from 192.168.1.242: icmp_seq=1 ttl=63 time=1.70 ms64 bytes from 192.168.1.242: icmp_seq=2 ttl=63 time=1.10 ms--- 192.168.1.242 ping statistics-- 2 packets transmitted, 2 received, 0 packet loss Time 1002msrtt min/avg/max/mdev = 1.101 with 1.404 ms### 0.303 from windows 10 ping linuxc:\ > ping 172.24.8.131-tpinging 172.24.8.131 with 32 bytes of data:reply from 172.24.8.131: bytes=32 time=1ms ttl=63reply from 172.24.8.131: bytes=32 time=1ms ttl=63

Note, if there is a problem with the test, please consider whether it is stopped by the firewall.

At this point, the study on "how to configure a virtual router under CentOS7" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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

Development

Wechat

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

12
Report