Xxb

Linux,crypto,mining,hexo,unraid

0%

ubnt edgeSwitch 交换机三层 VLAN 路由配置

ubnt edgeSwitch 交换机官方宣传全面支持高级的2层交换功能和协议,并提供3层路由功能。

虽然性能不如大几万的三层交换机,做三层时带几百台还是可以的,具体命令行配置方法如下:

VLAN 配置

  1. 创建 VLAN1101 和 VLAN1102

(注,如果没有vlan routing,将登录不了 interface vlan)

1
2
3
4
5
6
7
8
(UBNT EdgeSwitch S01) >enable
(UBNT EdgeSwitch S01) #vlan database
(UBNT EdgeSwitch S01) (Vlan)#vlan 1101
(UBNT EdgeSwitch S01) (Vlan)#vlan 1102
(UBNT EdgeSwitch S01) (Vlan)#vlan routing 1
(UBNT EdgeSwitch S01) (Vlan)#vlan routing 1101
(UBNT EdgeSwitch S01) (Vlan)#vlan routing 1102
(UBNT EdgeSwitch S01) (Vlan)#exit
  1. 分别为 VLAN 1101和 1102 设置 ip
1
2
3
4
5
6
(UBNT EdgeSwitch S01) #configure
(UBNT EdgeSwitch S01) (Config)#interface vlan 1101
(UBNT EdgeSwitch S01) (Interface vlan 10)#ip address 10.11.10.254 255.255.252.0
(UBNT EdgeSwitch S01) (Interface vlan 10)#interface vlan 1102
(UBNT EdgeSwitch S01) (Interface vlan 20)#ip address 10.11.20.254 255.255.252.0
(UBNT EdgeSwitch S01) (Interface vlan 20)#exit
  1. 为 VLAN 1101 设置 0/1-0/5 口,并将默认的 VLAN 1 踢出
1
2
3
4
5
(UBNT EdgeSwitch S01) (Config)#interface 0/1-0/5
(UBNT EdgeSwitch S01) (Interface 0/1)#vlan pvid 1101
(UBNT EdgeSwitch S01) (Interface 0/1)#vlan participation exclude 1
(UBNT EdgeSwitch S01) (Interface 0/1)#vlan participation include 1101
(UBNT EdgeSwitch S01) (Interface 0/1)#exit


用同样方法设置 VLAN 1102

创建 DHCP 服务和地址池

1
2
3
4
5
(UBNT EdgeSwitch S01) (Config)#ip dhcp pool "vlan1101"
(UBNT EdgeSwitch S01) (Config-dhcp-pool)#default-router 10.11.10.254
(UBNT EdgeSwitch S01) (Config-dhcp-pool)#network 10.11.10.0 255.255.252.0
(UBNT EdgeSwitch S01) (Config-dhcp-pool)#dns-server 8.8.8.8
(UBNT EdgeSwitch S01) (Config-dhcp-pool)#exit


用同样方法为 VLAN 1102 也设置一遍,然后用命令 service dhcp 使其生效

1
(UBNT EdgeSwitch S01) (Config)#service dhcp

设置三层路由网关

  1. 设置 VLAN 1 的 静态IP 地址 192.168.81.254 ,方便管理

(注,此处有坑,如果交换机已经通过DHCP获得该网段地址,将会报错,解决方案是先不要连接路由器,用默认的备用 ip 192.168.1.2 登录管理交换机)

1
2
3
(UBNT EdgeSwitch S01) #configure
(UBNT EdgeSwitch S01) (Config)#interface vlan 1
(UBNT EdgeSwitch S01) (Interface vlan 1)#ip address 192.168.81.211 255.255.255.0


此处会断开,因为之前是用192.168.1.x的网段登录的,现在要改为192.168.81.x重新登录

  1. 重新登录后先保存固定ip的设置,否则无法设置默认路由表
1
2
3
(UBNT EdgeSwitch S01) >enable
Password:*********
(UBNT EdgeSwitch S01) #write memory
  1. 设置默认路由表,网关为路由器内网 IP
1
2
3
(UBNT EdgeSwitch S01) #configure
(UBNT EdgeSwitch S01) (Config)#ip routing
(UBNT EdgeSwitch S01) (Config)#ip route 0.0.0.0 0.0.0.0 192.168.81.1
  1. 最后保存配置,使修改重启后亦生效
1
2
(UBNT EdgeSwitch S01) (Config)#end
(UBNT EdgeSwitch S01) #write memory