#null routes subnets of other zones
if ($is_gateway) {
my $subnets = PVE::Network::SDN::Vnets::get_subnets();
+ my $cidrs = {};
foreach my $subnetid (sort keys %{$subnets}) {
my $subnet = $subnets->{$subnetid};
my $cidr = $subnet->{cidr};
my $zone = $subnet->{zone};
- push @controller_config, "ip route $cidr null0" if $zone ne $id;
+ my ($ip, $mask) = split(/\//, $cidr);
+ $cidrs->{$ip} = $mask if $zone ne $id;
+
+ }
+
+ my @sorted_ip =
+ map { $_->[0] }
+ sort { $a->[1] <=> $b->[1] }
+ map { [ $_, eval { Net::IP->new( $_ )->intip } ] }
+ keys %{$cidrs} if $cidrs;
+
+ foreach my $ip (@sorted_ip) {
+ my $ipversion = Net::IP::ip_is_ipv4($ip) ? 'ip' : 'ipv6';
+ push @controller_config, "$ipversion route $ip/$cidrs->{$ip} null0";
}
}
!
vrf vrf_myzone
vni 1000
+ ip route 10.0.0.0/24 null0
ip route 172.16.0.0/24 null0
ip route 172.16.1.0/24 null0
+ ip route 172.16.3.0/24 null0
exit-vrf
!
vrf vrf_myzone2
vni 1001
ip route 10.0.0.0/24 null0
+ ip route 192.168.0.1/24 null0
+ ip route 192.168.10.1/24 null0
+ ipv6 route 2b0f:1480::/64 null0
+ ipv6 route 2b0f:1480:4000:6000::/64 null0
+ ipv6 route 2b0f:1480:4000:8000::/64 null0
exit-vrf
!
router bgp 65000
auto myvnet
iface myvnet
address 10.0.0.1/24
+ address 192.168.0.1/24
+ address 192.168.10.1/24
+ address 2b0f:1480:4000:6000::1/64
+ address 2b0f:1480:4000:8000::1/64
+ address 2b0f:1480::1/64
bridge_ports vxlan_myvnet
bridge_stp off
bridge_fd 0
mtu 1450
ip-forward on
+ ip6-forward on
arp-accept on
vrf vrf_myzone
auto myvnet2
iface myvnet2
+ address 10.0.0.1/24
address 172.16.0.1/24
+ address 172.16.3.1/24
bridge_ports vxlan_myvnet2
bridge_stp off
bridge_fd 0
subnets => {
ids => {
+ 'myzone-192.168.10.1-24' => {
+ 'type' => 'subnet',
+ 'vnet' => 'myvnet',
+ 'gateway' => '192.168.10.1',
+ },
+ 'myzone-192.168.0.1-24' => {
+ 'type' => 'subnet',
+ 'vnet' => 'myvnet',
+ 'gateway' => '192.168.0.1',
+ },
'myzone-10.0.0.0-24' => {
'type' => 'subnet',
'vnet' => 'myvnet',
'gateway' => '10.0.0.1',
},
+ 'myzone2-10.0.0.0-24' => {
+ 'type' => 'subnet',
+ 'vnet' => 'myvnet2',
+ 'gateway' => '10.0.0.1',
+ },
+ 'myzone-2b0f:1480:4000:8000::-64' => {
+ 'type' => 'subnet',
+ 'vnet' => 'myvnet',
+ 'gateway' => '2b0f:1480:4000:8000::1',
+ },
+ 'myzone-2b0f:1480::-64' => {
+ 'type' => 'subnet',
+ 'vnet' => 'myvnet',
+ 'gateway' => '2b0f:1480::1',
+ },
'myzone2-172.16.0.0-24' => {
'type' => 'subnet',
'vnet' => 'myvnet2',
'gateway' => '172.16.0.1',
},
+ 'myzone2-172.16.3.0-24' => {
+ 'type' => 'subnet',
+ 'vnet' => 'myvnet2',
+ 'gateway' => '172.16.3.1',
+ },
+ 'myzone-2b0f:1480:4000:6000::-64' => {
+ 'type' => 'subnet',
+ 'vnet' => 'myvnet',
+ 'gateway' => '2b0f:1480:4000:6000::1',
+ },
'myzone2-172.16.1.0-24' => {
'type' => 'subnet',
'vnet' => 'myvnet2',