实验目的:主机A访问主机B

网络拓扑图:

Linux与Window经路由器互相访问_路由转发

实验环境:Windows10(物理机)、VMware Workstation 12 Pro、Centos6(虚拟机)、Centos7(虚拟机)

 

主机A:Centos7.4

        一块仅主机模式网卡

            IP:192.168.27.100/24

            网关指向:192.168.27.200

 

主机B:windows10

        IP:172.18.4.185/16

        网关指向:172.18.0.200

 

Router0:Centos6.9模拟

            网卡eth0(192.168.27.200/24),选择仅主机模式    

            网卡eth1(10.0.0.200/8),选择自定义VMnet2模式

 

Router1:centos6.9

            网卡eth0(172.18.0.200/16),选择桥接模式

            网卡eth1(10.0.0.201/8),选择自定义VMnet2模式

 

实验流程:

 

A主机上操作

    ifconfig ens33 192.168.27.100/24   指定IP

    ifconfig   查看IP

    route add default gw 192.168.27.200  指定网关

    route -n 查看路由表

   

Router0上操作

    ifconfig eth0 192.168.27.200/24  指定IP

    ifconfig eth1 10.0.0.200/8   指定IP

      

    chkconfig iptables off  关闭iptable

    service iptables stop   停掉服务

    iptables-vnL   查看没启用

 

    setenforce 0  关闭SE策略

    getenforce  查看

 

route add -net 172.18.0.0/16 gw 10.0.0.201 dev eth1  配置R1路由表(直连网段不需要添加,自动生成路由记录)

    route -n  查看路由记录

   

    echo 1 > /proc/sys/net/ipv4/ip_forward  开启路由转发功能

 

Router1上操作

    ifconfig eth0 172.18.0.200/16 指定IP

    ifconfig eth1 10.0.0.201/8 指定IP

 

    chkconfig iptables off  关闭iptable

    service iptables stop   停掉服务

    iptables-vnL   查看没启用

 

    setenforce 0  关闭SE策略

    getenforce  查看

 

    route add -net 192.168.27.0/24 gw 10.0.0.200   配置R2路由表(接口可以忽略不写)

 

    echo 1 > /proc/sys/net/ipv4/ip_forward   开启路由转发

 

A主机上操作

    ping -I 192.168.27.100 172.18.4.185  可以ping通