今天给大家推荐一个好用的开源路由操作系统---VyOS,也是我个人非常喜欢的一款软路由器。VyOS 是基于 Debian GNU/Linux 的,提供了和其他诸如Cisco的IOS、Juniper的JUNOS类似的操作方式,配置起来感觉特别的舒服,尤其可以使用compare、rollback之类的命令,方便对比配置和错误回滚,深得我心。
由于之前用的Mikrotik RouterOS,在使用过程中逐渐发现了一些其性能和稳定性上的弊端,所以逐渐转向了VyOS,听一个资深linux老司机说,他曾经对VyOS进行过单纯的流量压力测试,一台VyOS虚机打到800M的流量没有任何压力。当然RouterOS提供了winbox之类的客户端管理工具,非常容易上手,如果没有特殊需求,完全够用。
一、简介
VyOS的前身是Vyatta,是Vyatta系统的社区fork版本;Vyatta公司在2002年提供了开源版本的虚拟路由,后来被博科收购。Vyatta是博通的企业级的产品,linux下知名的开源路由器项目,在其官方的测试中性能甚至超过了cisco 7200系列路由器,可以支持RIP、OSPF、BGP等路由协议以及VPN、NAT、HA等特性。企业路由的所有功能基本都支持,还支持虚拟机。
VyOS这个项目的第一个版本释放于2013年,目前还在持续活跃中。相对其他项目——像Juniper管理下的opencontrail,它有完整的使用与安装文档,更提供了API文档供开发者参考(这点也是我喜欢这个操作系统的原因之一)。可以用它来实现软件防火墙、路由器、vpn等功能。
二、特性
1、平台支持
-
32-bit x86
-
64-bit x86
-
KVM (virtio drivers included)
-
Xen HVM (including XenServer and EC2)
-
VMWare (open-vm-tools included)
-
Hyper-V (drivers included)
-
VirtualBox (guest additions not included)、
(默认情况下支持串口的终端是启用的)
2、路由
-
BGP (IPv4 and IPv6)
-
OSPFv2
-
OSPFv3 (incomplete)
-
RIP
-
RIPng
-
Policy-based routing
3、网络接口
-
Ethernet
-
802.1q VLAN, QinQ
-
NIC bonding
-
Bridges, STP (no RSTP or other extensions)
-
Port mirroring and redirection
-
Dummy interfaces (analogous to multiple loopbacks)
-
Pseudo-ethernet (aka MAC VLAN)
-
802.11 wireless (client and access point)
-
Some wireless modems (not very good support)
-
PPPoE
Note: No support for serial WAN, ISDN, dial-up, DSL cards. Use an external device for that.
4、防火墙与NAT
-
Stateful firewall
-
Network/address/port groups (IPv4 only for now)
-
Zone-based firewall
-
Source and destination NAT
5、VPN
-
Site-to-site IPsec (with pre-shared key or x.509 authentication)
-
VTI (Virtual Tunnel Interfaces)
-
OpenVPN (client, server, site-to-site)
-
GRE, IPIP, IPIP6, IP6IP6 tunnels
-
VXLAN
-
Unmanaged L2TPv3
-
L2TP/IPsec and PPTP remote access VPN
-
DMVPN (experimental)
6、网络服务
-
DHCP server and relay
-
Caching DNS server
-
Web proxy with some URL filtering support (no HTTPS filtering)
-
Telnet and SSH for remote management
-
IGMP proxy
-
QoS support
7、高可用
-
VRRP (IPv4 only for now)
-
Conntrack sync
-
WAN failover and load balancing
8、IPV6支持
-
IPv6 routing (static and dynamic)
-
Router advertisment
-
DHCPv6 client and server/relay
-
IPv6 firewall
9、系统维护和监控
-
Task scheduler
-
SNMP
-
Configuration versioning and remote archiving
-
Event handling
-
Remote syslog
其他特性详见链接:http://vyos.net/wiki/Feature_list
三、安装
官方推荐的配置是,2G磁盘空间,512M内存。其硬件要求很小,2G磁盘完全够用,如果不放心可以增加其内存的配置。比较好的一点,它提供了一种基于镜像的安装方式,这使得在同一机器上存在多个版本的软件成为可能,方便版本升级。
下载地址:http://packages.vyos.net/iso/release/选择你需要的版本,当前最新版本号1.1.7,另外其也提供了OVA的格式,可以直接部署到vmware等平台上。这里说下iso镜像安装方式,wiki上也有详细的安装手册:http://vyos.net/wiki/User_Guide
挂盘之后,进系统引导,会看到如下的界面,默认的用户名/密码是:vyos/vyos
这里有两种安装方式:install image和install system,推荐使用install image方式:
运行install image安装:
1
|
vyos@vyos:~$
install
image
|
安装过程很简单,基本一路回车用默认配置即可,中间需要配置vyos用户的密码,安装成功后用的就是vyos这个用户进行系统配置:
提示Setting up grub:OK,即安装成功,之后卸载CDROM,reboot重启之后就可以进行系统配置:
四、简单配置
VyOS CLI提供两种模式:operational mode和configuration mode.输入configure之后即进入configuration模式,跟路由器和其他linux发行版一样,支持[tab]补齐和?查看帮助信息。配置完之后用compare命令查看修改的配置,commit提交配置,save保存到/config/config.boot配置文件中。
show命令:
1
2
3
4
5
6
7
|
#查看全部配置
vyos@vyos
# show configuration
#匹配某个配置字段,类似思科交换机上的include或者linux上的grep
vyos@vyos:~$ show configuration commands | match eth1
set
interfaces ethernet eth1 address
'172.16.0.1/24'
set
interfaces ethernet eth1 description
'To Private Net'
set
interfaces ethernet eth1 hw-
id
'00:xx:xx:b9:xx:xx
|
简单NAT配置实例:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
set
interfaces ethernet eth0 address
'xx.xx.xx.34/xx'
#配置出网ip地址
set
interfaces ethernet eth0 description
'To Internet'
set
protocols static route 0.0.0.0
/0
next-hop
'xx.xx.xx.33'
#配置全局静态路由,33为网关
set
service
ssh
listen-address
'xx.xx.xx.34'
#设置ssh监听的本地地址
set
service
ssh
port
'2222'
# 更改vyos的ssh端口号
set
nat
source
rule 100 description
'NAT Outside'
#配置NAT source规则,内网映射出网
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
'xx.xx.xx.34'
set
nat destination rule 101 description
'To agent port 5045'
#配置NAT dest规则,映射到内网
set
nat destination rule 101 destination address
'xx.xx.xx.34'
set
nat destination rule 101 destination port
'5045'
set
nat destination rule 101 inbound-interface
'eth0'
set
nat destination rule 101 protocol
'tcp'
set
nat destination rule 101 translation address
'192.168.0.2'
set
nat destination rule 101 translation port
'5045'
|
配置完成之后,报存配置;
1
2
3
4
5
|
vyos@vyos
# compare #查看更改的配置
vyos@vyos
# commit #提交配置
vyos@vyos
#save #保存到文件,重启不失效
vyos@vyos
# exit #退出
vyos@vyos
# rollback 1 #如果发现错误,rollback回滚到指定时间的配置
|
参考链接:
http://vyos.net/wiki/Main_Page
本文出自 “xujpxm” 博客,请务必保留此出处http://xujpxm.blog.51cto.com/8614409/1791647
本文转自easy80851CTO博客,原文链接:http://blog.51cto.com/68240021/1974195 ,如需转载请自行联系原作者