Gotcha. Suggestion was to use virtual interfaces (vifs) and not use the dummy interfaces since those are causing the conflict on your network. When you commit the changes they end up squashing your static route pointing down to your switch this resulting in you losing internet connectivity.
With the dum interfaces on router
vyos@vyos:~$ sh ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
F - PBR, f - OpenFabric,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
S>* 10.0.0.0/16 [1/0] via 10.0.255.1, eth0, weight 1, 00:00:03
C>* 10.0.20.0/24 is directly connected, dum0, 01:26:38
C>* 10.0.40.0/24 is directly connected, dum1, 01:26:37
C>* 10.0.255.0/24 is directly connected, eth0, 01:42:10
Switch#sh run | inc route
ip route 0.0.0.0 0.0.0.0 10.0.255.254
Switch#ping 10.0.255.254 source vlan 20
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.255.254, timeout is 2 seconds:
Packet sent with a source address of 10.0.20.1
.....
Success rate is 0 percent (0/5)
Switch#ping 10.0.255.254 source vlan 40
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.255.254, timeout is 2 seconds:
Packet sent with a source address of 10.0.40.1
.....
Success rate is 0 percent (0/5)
Without
vyos@vyos:~$ sh ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
F - PBR, f - OpenFabric,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
S>* 10.0.0.0/16 [1/0] via 10.0.255.1, eth0, weight 1, 00:06:38
C>* 10.0.255.0/24 is directly connected, eth0, 01:48:45
Switch#ping 10.0.255.254 source vlan 20
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.255.254, timeout is 2 seconds:
Packet sent with a source address of 10.0.20.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 3/8/28 ms
Switch#ping 10.0.255.254 source vlan 40
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.255.254, timeout is 2 seconds:
Packet sent with a source address of 10.0.40.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 3/4/6 ms
Let me know how it goes! I would suspect it works .