实验:配置静态路由2

实验:配置静态路由2

IP地址规划如下:

实验:配置静态路由2

VMware实验环境下给网卡分配不同的VMnet以实现物理分隔广播域:
Client1-VMnet1:

实验:配置静态路由2

R1-VMnet1-VMnet2:

实验:配置静态路由2

R2-VMnet2-VMnet3:

实验:配置静态路由2

R3-VMnet3-VMnet4:

实验:配置静态路由2

Client2-VMnet4:

实验:配置静态路由2

注意,环境准备:
1、MAC地址不要有冲突,如果是复制的虚拟机,对于centos6需删除网卡定义文件rm -f /etc/udev/rules.d/70-persistent-net.rules
2、清空防火墙iptables -F(查看:iptables -vnL)
3、启用IP转发功能:echo 1 > /proc/sys/net/ipv4/ip_forward
4、关闭服务:service NetworkManager stop
可能用到的清理命令:
ip route flush default
ip a flush eht0
ip a flush eth1

方法1:(使用ifconfig和route命令)
Client1:
ifconfig eth0 172.16.0.10/16
route add default gw 172.16.0.11

实验:配置静态路由2

Client2:
ifconfig eth0 192.168.0.10/24
route add default gw 192.168.0.11

实验:配置静态路由2

R1:
ifconfig eth0 172.16.0.11/16
ifconfig eth1 10.1.0.10/16
#
route add -net 10.2.0.0/16 gw 10.1.0.11
route add -net 192.168.0.0/24 gw 10.1.0.11

实验:配置静态路由2

R2:
ifconfig eth0 10.1.0.11/16
ifconfig eth1 10.2.0.10/16
#
route add -net 172.16.0.0/16 gw 10.1.0.10
route add -net 192.168.0.0/24 gw 10.2.0.11

实验:配置静态路由2

R3:
ifconfig eth0 10.2.0.11/16
ifconfig eth1 192.168.0.11/24
#
route add -net 10.1.0.0/16 gw 10.2.0.10
route add -net 172.16.0.0/16 gw 10.2.0.10

实验:配置静态路由2


方法2:(使用ip命令)

Client1:
ip a add 172.16.0.10/16 dev eth0
ip route add default via 172.16.0.11

Client2:
ip a add 192.168.0.10/24 dev eth0
ip route add default via 192.168.0.11

R1:
ip a add 172.16.0.11/16 dev eth0
ip a add 10.1.0.10/16 dev eth1
ip route add 10.2.0.0/16 via 10.1.0.11
ip route add 192.168.0.0/24 via 10.1.0.11

R2:
ip a add 10.1.0.11/16 dev eth0
ip a add 10.2.0.10/16 dev eth1
ip route add 172.16.0.0/16 via 10.1.0.10
ip route add 192.168.0.0/24 via 10.2.0.11

R3:
ip a add 10.2.0.11/16 dev eth0
ip a add 192.168.0.11/24 dev eth1
ip route add 10.1.0.0/16 via 10.2.0.10
ip route add 172.16.0.0/16 via  10.2.0.10

原创文章,作者:Leion,如若转载,请注明出处:http://www.178linux.com/71842

(0)
LeionLeion
上一篇 2017-03-26 22:02
下一篇 2017-03-26 22:08

相关推荐

  • Linux主要发行版

    Redhat:三大发行版之一,由红帽公司维护,分支有fedora,centosDebian:社区维护,非商业维护,三大发行版之一,分支有Ubuntu,Mintslackware:三大发行版之一,分支有Suse,opensusearch Linux:轻量级行业新贵

    Linux干货 2018-03-03
  • 胡说八道计算机网络之什么是网络(一)?

    胡说八道计算机网络之什么是网络(一) 什么是网络? 网络通信的实现:tcp/ip协议 使用Wireshark抓包分析tcp/ip协议栈 什么是网络?      所谓网络,就是通过一定的形式连接起来的物体,物体与物体之间可以实现通信。     比如这样的,就称为计算机网络。它可以实现计算机之…

    Linux干货 2017-05-01
  • Linux网络属性配置的几个命令

    Linux网络属性配置命令 ifcfg命令家族:ifconfig,route,netstat ifconfig命令:接口及地址查看和管理 ifconfig [INTERFACE] #ifconfig -a : 显示所有接口,包括inactive状态的接口 ifconfig interface [aftype] options | address … #i…

    Linux干货 2017-05-09
  • 往死里苦练脚本啊啊啊啊啊啊啊~~~~~~~~~~~~~~~~

    1、写一个脚本,判断当前系统上所有用户的shell是否为可登录shell(即用户的shell不是/sbin/nologin);分别这两类用户的个数;通过字符串比较来实现; #脚本内容 [root@centos script]# cat week9_title1.sh  #!/bin/bash #Author …

    Linux干货 2017-02-16
  • Linux 基础(5)

    /etc/passwd           /etc/shadow         /etc/gpasswd (chage)            /etc/gshadow    usera…

    2017-07-22
  • LVM逻辑卷管理

    一、简述 什么是逻辑卷?LVM(Logical Volume Manager)利用Linux内核device-mapper实现存储系统的虚拟化。通过LVM,把底层存储硬件抽象化成存储逻辑块,再将这些逻辑块集合构成存储池,从存储池空间划分分区,可以简单地扩大或缩小分区,而不用担心硬盘没有足够的连续空间。 使用逻辑卷分区有什么用?使用逻辑卷分区重点在于可以弹性地…

    Linux干货 2016-09-06