OVS使用记录(二)

6 篇文章 0 订阅
4 篇文章 0 订阅

搭建复杂网络

搭建如下图所示网络(VAP仅作为二层交换机使用):
在这里插入图片描述

基于lxd容器搭建多主机网络

  1. 在记录一中已经创建了VAP、host1、host2节点以及相应流表,能互相ping通。现在基于记录一,再创建一个主机节点。添加host3节点,lxc launch <template> host3 ,
  2. 创建网桥连接host3的eth0接口以及VAP的eth2接口,并进入host3节点,配置其ip地址。
    lxc network create n3 
    lxc network attach n3 host3 eth0
    lxc network attach n3 VAP eth2
    #登进host3
    lxc exec host3 bash
    #修改配置文件
    vi /etc/network/interfaces
    #添加如下内容
    auto eth0
    iface eth0 inet static
    address 192.168.10.13
    netmask 255.255.255.0
    #保存,重启服务
    service networking restart

  1. 进入VAP交换机,挂载eth2端口,启动端口,配置流表。
   lxc exec VAP bash
   #挂载端口
   ovs-vsctl add-port br0 eth3
   #启动端口
   ip link set eth3 up
   #添加流表
   ovs-ofctl add-flow br0 in_port=4,actions=all
   

之前只有两个主机,设置的流表为从某端口进的从某端口出,现在可以直接改为广播
例如将1端口的改为广播模式:ovs-ofctl mod-flows br0 in_port=1,actions=all

  1. 此时host3便可以与其它主机通信。

搭建路由网络

  1. 创建R1节点以及host4节点,创建过程之前讲过,这里再次写出
  lxc launch <template> host4
  #其中<template>为lxc中的一种镜像文件lxc image list可查看全部,若没有,需要先下载
  lxc launch <template> R1
  #创建网桥连接host4的eth0端口与R1的eth0端口,与上面host3步骤相同
  lxc network create n4 
  lxc network attach n4 host4 eth0
  lxc network attach n4 R1 eth0
  lxc exec host4 bash
  vi /etc/network/interfaces
  #编辑内容,需要添加网关,即R1的eth0端口ip
  auto eth0
  iface eth0 inet static
  address 192.168.11.11
  netmask 255.255.255.0
  gateway 192.168.11.253
  #重启
  service networking restart
  #进入路由器R1,先配置端口ip,再配置rip协议
  lxc exec R1 bash
  vi /etc/network/interfaces
  #编辑内容
  auto eth0
  iface eth0 inet static
  address 192.168.11.253
  netmask 255.255.255.0
  auto eth1
  iface eth1 inet static
  address 192.168.10.14
  netmask 255.255.255.0
  service networking restart
  vi /usr/local/etc/ripd.conf
  #添加如下内容,表示eth0、eth1端口都参与对外通信
  router rip
  version 2
  network eth0
  network eth1
  #保存后启动路由器以及rip
  zebra -d
  ripd -d
  
  1. 创建网桥,连接VAP的eth3端口与R1的eth1端口,过程同上
  2. 进入VAP,挂载eth3端口,并启动端口,添加流表,过程同上
  3. 此时host1、2、3能ping通路由器的eth1接口,但找不到host4,因为它们没有配置网关。
    分别进入host1、2、3的配置文件vi /etc/network/interfaces,在netmask后面一行添加网关地址即路由器eth1的ip地址:gateway 192.168.10.14。
  4. 此时,各主机之间都能ping通了。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

FlowerMin

还是一枚学生,希望多多鼓励~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值