安装和初始化 VyOS虚拟机

备注:本文中所有的配置均符合NSX-T管理与配置系列博文中T0网关的设置。

1. 安装VyOS系统

(1)进入系统安装界面

默认选项,按回车 Enter

在这里插入图片描述

进入系统加载界面。

在这里插入图片描述在这里插入图片描述在这里插入图片描述

2. 登录VyOS系统

用户名和密码均为:vyos

(1)安装 Image 镜像

在 CLI 中输入 install image

在这里插入图片描述

(2)进入初始话设置

具体填写信息,参考如下图所示:

①: yes
②: 直接按 Enter 回车。
③: 直接按 Enter 回车。
④: yes
⑤: 直接按 Enter 回车。
⑥: 直接按 Enter 回车。
⑦: 自定义vyos密码。
⑧: 确认yvos密码。
⑨: 直接按 Enter 回车。
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

文字描述
vyos@vyos:~$ install image
Welcome to the VyOS install program.  This script
will walk you through the process of installing the
VyOS image to a local hard drive.
Would you like to continue? (Yes/No) [Yes]: Yes
Probing drives: OK
Looking for pre-existing RAID groups...none found.
The VyOS image will require a minimum 2000MB root.
Would you like me to try to partition a drive automatically
or would you rather partition it manually with parted?  If
you have already setup your partitions, you may skip this step

Partition (Auto/Parted/Skip) [Auto]:

I found the following drives on your system:
 sda    4294MB

Install the image on? [sda]:

This will destroy all data on /dev/sda.
Continue? (Yes/No) [No]: Yes

How big of a root partition should I create? (2000MB - 4294MB) [4294]MB:

Creating filesystem on /dev/sda1: OK
Done!
Mounting /dev/sda1...
What would you like to name this image? [1.2.0-rolling+201809210337]:
OK.  This image will be named: 1.2.0-rolling+201809210337
Copying squashfs image...
Copying kernel and initrd images...
Done!
I found the following configuration files:
    /opt/vyatta/etc/config.boot.default
Which one should I copy to sda? [/opt/vyatta/etc/config.boot.default]:

Copying /opt/vyatta/etc/config.boot.default to sda.
Enter password for administrator account
Enter password for user 'vyos':
Retype password for user 'vyos':
I need to install the GRUB boot loader.
I found the following drives on your system:
 sda    4294MB

Which drive should GRUB modify the boot partition on? [sda]:

Setting up grub: OK
Done!
重启系统

在这里插入图片描述

重启后VyOS系统已经安装和初始化完成。

3. 配置路由

VyOS系统类似于Cisco的路由操作系统,但又不完全相同。

3.1 设置静态IP地址

IP地址拓扑:

网络接口IP地址
eth0192.168.1.10/24
eth11.1.1.1/24
eth22.2.2.1/24
vyos@vyos:~$ configure
[edit]
vyos@vyos# set interface ethernet eth0 address 192.168.1.10/24
[edit]
vyos@vyos# commit
[edit]
vyos@vyos# set interface ethernet eth0 address 1.1.1.1/24
[edit]
vyos@vyos# commit
[edit]
vyos@vyos# set interfaces ethernet eth2 address 2.2.2.1/24
[edit]
vyos@vyos# commit
[edit]
vyos@vyos# save
Saving configuration to '/config/config.boot'...
Done

3.2 SSH端口设置

vyos@vyos# set service ssh port '22'
[edit]
vyos@vyos# commit
[edit]
vyos@vyos# save
Saving configuration to '/config/config.boot'...
Done

在这里插入图片描述

3.3 删除网卡IP地址

现象:vyos的eth0网卡存在多个IP地址,需要将多余或错误配置的IP删除

在这里插入图片描述

vyos@vyos# delete interfaces ethernet eth0 address [按Tab]
Possible completions:
   192.168.1.10/24
   192.168.1.11/24
   192.168.10.60/24

[edit]
vyos@vyos# delete interfaces ethernet eth0 address 192.168.1.11/24
[edit]
vyos@vyos# delete interfaces ethernet eth0 address 192.168.10.60/24
[edit]
vyos@vyos# commit
[edit]
vyos@vyos# save
Saving configuration to '/config/config.boot'...
Done
[edit]
vyos@vyos#

验证

在这里插入图片描述

3.4 静态路由 / 默认路由

(1)设置静态路由 / 默认路由

vyos@vyos# set protocols static route 0.0.0.0/0 next-hop 192.168.1.21
[edit]
vyos@vyos# commit
[edit]
vyos@vyos# save
Saving configuration to '/config/config.boot'...
Done
[edit]

(2)查看静态路由

vyos@vyos# show protocols static

在这里插入图片描述

3.5 OSPF路由

(1)设置OSPF

vyos@vyos# set protocols ospf area 0  network 1.1.1.1/32
[edit]
vyos@vyos# commit
[edit]
vyos@vyos# save
Saving configuration to '/config/config.boot'...
Done
[edit]

(2)查看OSPF配置

vyos@vyos# show protocols ospf

在这里插入图片描述

(3)查看 OSPF 邻居

show ip ospf neighbor

在这里插入图片描述

(4)将静态路由重分布到OSPF中

vyos@vyos# edit protocols ospf
[edit protocols ospf]
vyos@vyos# set redistribute connected
[edit protocols ospf]
vyos@vyos# show
 area 0 {
     network 1.1.1.1/32
 }
+redistribute {
+    connected {
+    }
+}
[edit protocols ospf]
vyos@vyos# commit
[edit protocols ospf]
vyos@vyos# save
Saving configuration to '/config/config.boot'...
Done
[edit]
vyos@vyos#

(5)将默认路由重分布到OSPF中

vyos@vyos# edit protocols ospf
[edit protocols ospf]
vyos@vyos# set default-information originate always
[edit protocols ospf]

[edit protocols]
vyos@vyos# show
 ospf {
     area 0 {
         network 1.1.1.1/32
     }
     default-information {
         originate {
             always
         }
     }
     redistribute {
         connected {
         }
         static {
         }
     }
 }
 static {
     route 0.0.0.0/0 {
         next-hop 192.168.1.21 {
         }
     }
 }
[edit protocols]
vyos@vyos# commit
[edit protocols ospf]
vyos@vyos# save
Saving configuration to '/config/config.boot'...
Done
[edit]
vyos@vyos#

3.6 BGP 路由

(1)配置EBGP

set protocols bgp system-as 200
set protocols bgp neighbor 2.2.2.2 address-family ipv4-unicast
set protocols bgp neighbor 2.2.2.2 remote-as 100
vyos@vyos# commit
[edit]
vyos@vyos# save
Saving configuration to '/config/config.boot'...
Done
[edit]

在这里插入图片描述

参考资料

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐