CentOS7下怎么配置虚拟路由器
发表于:2024-09-22 作者:千家信息网编辑
千家信息网最后更新 2024年09月22日,这篇文章主要介绍"CentOS7下怎么配置虚拟路由器",在日常操作中,相信很多人在CentOS7下怎么配置虚拟路由器问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答"Cen
千家信息网最后更新 2024年09月22日CentOS7下怎么配置虚拟路由器
这篇文章主要介绍"CentOS7下怎么配置虚拟路由器",在日常操作中,相信很多人在CentOS7下怎么配置虚拟路由器问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答"CentOS7下怎么配置虚拟路由器"的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
一、环境及需求说明
本地测试环境,由于win7+vmware这台机器网卡太新,无法被vmware exsi识别,无奈之下就直接装了个win7,然后再上面基于vmware workstation 12开启了一些临时测试的虚拟机。其次本地直连网段192.168.1.0 ip有限,而又希望直接从本机(如图win10) ssh连接到这些虚拟机,因此考虑使用linux的ip转发功能来实现。
上述图片中已经列出了各个节点的ip信息,红色的虚拟机充当软路由,配置好之后,实现win10 直接ssh到虚拟机。
二、虚拟路由服务器配置
###查看网卡信息[root@centos7-router ~]# ip addr1: lo:mtu 65536 qdisc noqueue state unknown link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever2: eno16777728: 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###查看路由表[root@centos7-router ~]# route -nkernel ip routing table ###缺省情况下,每块网卡都有一个基于本网段的路由记录destination gateway genmask flags metric ref use iface0.0.0.0 192.168.1.1 0.0.0.0 ug 100 0 0 eno33554960172.24.8.0 0.0.0.0 255.255.255.0 u 100 0 0 eno16777728192.168.1.0 0.0.0.0 255.255.255.0 u 100 0 0 eno33554960###使用ip命令方式查看路由[root@centos7-router ~]# ip route listdefault via 192.168.1.1 dev eno33554960 proto static metric 100 172.24.8.0/24 dev eno16777728 proto kernel scope link src 172.24.8.254 metric 100 192.168.1.0/24 dev eno33554960 proto kernel scope link src 192.168.1.175 metric 100 ###开启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 ###如不生效重启一下os
三、centos7-a主机下添加路由
###查看当前主机ip 信息[root@centos7-a ~]# ip addr list1: lo:mtu 65536 qdisc noqueue state unknown link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever2: eno16777728: mtu 1500 qdisc pfifo_fast state up qlen 1000 link/ether 00:0c:29:57:26:9d brd ff:ff:ff:ff:ff:ff inet 172.24.8.131/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###查看当前主机路由信息 [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.0/24 dev eno16777728 proto kernel scope link src 172.24.8.131 metric 100 ###测试到虚拟路由器网关ip连通性[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/0.285/0.302/0.017 ms###测试到虚拟路由器ip连通性[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/0.459/0.475/0.016 ms
四、windows 10下配置路由
###当前环境c:\>systeminfo | findstr buildos version: 10.0.14393 n/a build 14393os build type: multiprocessor free###查看当前的路由信息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###添加持久化路由 c:\>route add 172.24.8.0 mask 255.255.255.0 192.168.1.175 -pok!c:\>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.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.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: ###以下为添加的持久化路由记录 network address netmask gateway address metric 172.24.8.0 255.255.255.0 192.168.1.175 1 ===========================================================================
五、验证两边连通性
###从linux端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/1.404/1.707/0.303 ms###从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
注,如果测试有问题,请考虑是否被防火墙拦住。
到此,关于"CentOS7下怎么配置虚拟路由器"的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注网站,小编会继续努力为大家带来更多实用的文章!
路由
配置
路由器
信息
测试
学习
主机
环境
网卡
更多
网段
问题
帮助
实用
接下来
功能
命令
图片
情况
文章
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
医院网络安全工作季度总结
手机软件开发就业发展前景怎样
db后缀的数据库怎么打开
有 北京合成网络技术公司
2016软件开发就业前景
格力软件开发是做什么的
网络技术月工作总结范文
苏州阿里云服务器中小型
社交软件开发选择 青岗科技
日本水资源数据库
智慧网络安全
海底服务器散热优化
办公管理软件开发风险
国家网络安全的重要性及意义
软件开发有形化手册教程书籍
做软件开发的出路在哪
打游戏网络安全
公司画图用服务器
软件开发选哪项对词项
计算机服务器打不开怎么办
常州交联互联网科技有限公司
如何获得天猫的数据库
数据库课设 公交车运行
物易网络技术有限公司
军营网络安全黑板报
网络安全准入控制公司
战地5开社区服服务器地址是国外
面向对象软件开发的三大原则
纵目科技产业互联网融资
博士德软件选择服务器