zoukankan      html  css  js  c++  java
  • LAN路由

    一、实验的目的:
      实现不同子网之前的信息交流
        
    二、如果
    1、虚拟子网
    VMnet8:192.168.233.0/24
    VMnet1:172.16.1.0/24
    2、虚拟机vm1
    ip:192.168.233.3/24,属于子网VMnet8.
    三、clone虚拟机
    1、vm1未启动时。克隆两虚拟机。分别命名为gate和vm2。gate加入一以太网卡。


    2、启动vm2。设置
    ip:172.16.1.5/24,属于子网VMnet1。
    3、启动gate,设置
    eth0:192.168.233.6/24,属于子网VMnet8
    eth1:172.16.1.6/24,属于子网VMnet1
    4、启动vml,设置
    IP:192.168.233.5/24,属于子网VMnet8。


      [root@localhost root]# setup
       设置好ip和子网掩码
      [root@localhost root]# cd /etc/sysconfig/network-scripts
      [root@localhost network-scripts]# cat ifcfg-eth0
      DEVICE=eth0
      ONBOOT=yes
      BOOTPROTO=static
      IPADDR=192.168.233.6
      NETMASK=255.255.255.0
      
      [root@localhost network-scripts]# cp ifcfg-eth0 ifcfg-eth1
      cp:是否覆盖‘ifcfg-eth1’? y
      [root@localhost network-scripts]# vi ifcfg-eth1
      改动同以下一样i
      DEVICE=eth1
      ONBOOT=yes
      BOOTPROTO=static
      IPADDR=172.16.1.6
      NETMASK=255.255.255.0


    [root@localhost network-scripts]# service network restart
    正在关闭接口 eth0:                                        [  确定  ]
    正在关闭接口 eth1:                                        [  确定  ]
    关闭环回接口:                                             [  确定  ]
    禁用 IPv4 包转送:                                         [  确定  ]
    设置网络參数:                                             [  确定  ]
    弹出环回接口:                                             [  确定  ]
    弹出界面 eth0:                                            [  确定  ]
    弹出界面 eth1:                                            [  确定  ]


    四、启动转发和加入路由
    1、启动gate转发
    编辑/etc/sysctl.conf,设置
    net.ipv4.ip_forward=1
    运行:
    #sysctl -p
      [root@localhost network-scripts]# vi /etc/sysctl.conf
        把net.ipv4.ip_forward的值改为1
      [root@localhost network-scripts]# sysctl -p
      net.ipv4.ip_forward = 1
      net.ipv4.conf.default.rp_filter = 1
      kernel.sysrq = 0
      kernel.core_uses_pid = 1




    2vml加入路由
    #route add -net 172.16.1.0/24 gw 192.168.233.6
      [root@localhost root]#route add -net 172.16.1.0/24 gw 192.168.233.6


    3、vm2加入路由
    #route add -net 192.168.233.0/24 gw 172.16.1.6
      [root@localhost root]#route add -net 192.168.233.0/24 gw 172.16.1.6
    五、測试
    1、vm1中
    #ping 172.16.1.5
      [root@localhost root]# ping 172.16.1.5
      PING 172.16.1.5 (172.16.1.5) 56(84) bytes of data.
      64 bytes from 172.16.1.5: icmp_seq=1 ttl=63 time=2.07 ms
      64 bytes from 172.16.1.5: icmp_seq=2 ttl=63 time=1.21 ms
      64 bytes from 172.16.1.5: icmp_seq=3 ttl=63 time=0.485 ms
      64 bytes from 172.16.1.5: icmp_seq=4 ttl=63 time=0.649 ms
      64 bytes from 172.16.1.5: icmp_seq=5 ttl=63 time=0.488 ms
      
      通过


    2、vm2中
    #ping 192.168.233.5
    通了吗?
      [root@localhost root]# ping 192.168.233.5
      PING 192.168.233.5 (192.168.233.5) 56(84) bytes of data.
      64 bytes from 192.168.233.5: icmp_seq=1 ttl=63 time=1.59 ms
      64 bytes from 192.168.233.5: icmp_seq=2 ttl=63 time=0.539 ms
      64 bytes from 192.168.233.5: icmp_seq=3 ttl=63 time=0.498 ms
      64 bytes from 192.168.233.5: icmp_seq=4 ttl=63 time=0.725 ms
      64 bytes from 192.168.233.5: icmp_seq=5 ttl=63 time=0.514 ms


      通过




    六、显示路由表
    1、vm1中
    #route
      [root@localhost root]# route -n
      Kernel IP routing table
      Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
      172.16.1.0      192.168.233.6   255.255.255.0   UG    0      0        0 eth0
      192.168.233.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0
      169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0
      127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo


    2、gate中
    #route
     
      [root@localhost network-scripts]# route -n
      Kernel IP routing table
      Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
      172.16.1.0      0.0.0.0         255.255.255.0   U     0      0        0 eth1
      192.168.233.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0
      169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth1
      127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo


    七、画出本实验的拓扑图


        _____     ___       _eh0_____eth1      _____      ____
        |____|---|___|------|_____|____|------|_____|----|____|
         VM1      集线器     gate              集线器     VM2   
     




    八、实验的体会
        用记事本画拓扑图太难了,实验时搞乱了不同子网。导致putty连不上。

  • 相关阅读:
    VS2010 使用TeeChart画图控件
    程序猿接私活经验总结,来自csdn论坛语录
    锁(下)
    android4.4组件分析--service组件-bindService源代码分析
    黑客和敏捷开发
    编写你自己的单点登录(SSO)服务
    Cloudera impala简单介绍及安装具体解释
    ACdream群赛1112(Alice and Bob)
    八大排序算法总结
    垂死挣扎还是涅槃重生 -- Delphi XE5 公布会归来感想
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/5118856.html
Copyright © 2011-2022 走看看