一、VyOS由来
2005年,Vyatta公司成立,10月发布虚拟网络软件;
2006年,Vyatta发布商业订购版本,同时,开源了虚拟路由软件Open Flexible Router(OFR);
2012年,Brocade收购Vyatta,将虚拟路由软件更名为Brocade Vyatta 5400 vRouter,不再开源;独立开发人员从Vyatta Core 6.6 R1版fork一个分支继续进行开发,诞生了VyOS;
2017年,AT&T收购Brocade的网络Vyatta团队,推出dNOS(disaggregated Network Operating System)软件;
2021年,Ciena公司接手Vyatta团队。
二、VyOS特性
三、VyOS命令模式
Vyos命令模式与思科差不多,分为操作模式和配置模式。
默认情况下,VyOS处于操作模式,命令提示符显示$。执行命令configure,可进入配置模式,命令提示符显示#:
vyos@vyos$ configure
vyos@vyos#
配置完成后,执行命令commit、save,然后exit退出。
四、常用命令行
1.接口配置
外部/WAN接口是eth0,通过DHCP接收其接口地址。
内部/LAN接口是eth1,使用静态IP地址192.168.0.1/24。
执行命令:
set interfaces ethernet eth0 address dhcp
set interfaces ethernet eth0 description 'OUTSIDE'
set interfaces ethernet eth1 address '192.168.0.1/24'
set interfaces ethernet eth1 description 'INSIDE'
2.DHCP和DNS
配置DHCP和DNS服务,VyOS为相应的默认网关和DNS服务器。
默认网关和DNS递归地址为192.168.0.1/24,地址范围192.168.0.2/24-192.168.0.8/24保留并用于静态分配。
set service dhcp-server shared-network-name LAN subnet 192.168.0.0/24 default-router '192.168.0.1'
set service dhcp-server shared-network-name LAN subnet 192.168.0.0/24 name-server '192.168.0.1'
set service dhcp-server shared-network-name LAN subnet 192.168.0.0/24 domain-name 'vyos.net'
set service dhcp-server shared-network-name LAN subnet 192.168.0.0/24 lease '86400'
set service dhcp-server shared-network-name LAN subnet 192.168.0.0/24 range 0 start 192.168.0.9
set service dhcp-server shared-network-name LAN subnet 192.168.0.0/24 range 0 stop '192.168.0.254'
set service dns forwarding cache-size '0'
set service dns forwarding listen-address '192.168.0.1'
set service dns forwarding allow-from '192.168.0.0/24'
3.NAT
允许主机通过 IP 伪装通过外部/WAN 网络进行通信。
set nat source rule 100 outbound-interface 'eth0'
set nat source rule 100 source address '192.168.0.0/24'
set nat source rule 100 translation address masquerade
4.防火墙
阻止所有未首先从内部/LAN 端启动的流量。
set firewall name OUTSIDE-IN default-action 'drop'
set firewall name OUTSIDE-IN rule 10 action 'accept'
set firewall name OUTSIDE-IN rule 10 state established 'enable'
set firewall name OUTSIDE-IN rule 10 state related 'enable'
set firewall name OUTSIDE-LOCAL default-action 'drop'
set firewall name OUTSIDE-LOCAL rule 10 action 'accept'
set firewall name OUTSIDE-LOCAL rule 10 state established 'enable'
set firewall name OUTSIDE-LOCAL rule 10 state related 'enable'
set firewall name OUTSIDE-LOCAL rule 20 action 'accept'
set firewall name OUTSIDE-LOCAL rule 20 icmp type-name 'echo-request'
set firewall name OUTSIDE-LOCAL rule 20 protocol 'icmp'
set firewall name OUTSIDE-LOCAL rule 20 state new 'enable'
五、VyOS API接口
1.VyOS提供了HTTP API接口,进行查询、配置、重置等相关操作。
https://docs.VyOS.io/en/equuleus/automation/VyOS-api.html#VyOS-api
以配置为例:
curl -k --location --request POST 'https://vyos/configure' \\
--form data='{"op": "set", "path": ["interfaces", "dummy", "dum1", "address", "10.11.0.1/32"]}' \\
--form key='MY-HTTPS-API-PLAINTEXT-KEY'
response:
{
"success": true,
"data": null,
"error": null
}
2.VyOS支持通过ansible进行配置,以实现路由器的自动化配置。
六、配置示例
选用VyOS作为IaaS平台的网络服务软件,以防火墙配置为例。
配置以VyOS为视角,设定网络链路为:VyOS--VPCTest,则下图的入方向是指VyOS的入方向。业务网络的规则集如下:
进入到vyos后台,执行命令configure进入配置模式。Show ?
查看端口信息:
查看防火墙信息:show firewall
七、相关资料
https://www.sdnlab.com/25617.html
https://docs.vyos.io/en/equuleus/quick-start.html#quick-start
https://www.sdnlab.com/17348.html
全部0条评论
快来发表一下你的评论吧 !