|
| 1 | +# vim: set ft=bird nofoldenable: |
| 2 | +ipv4 table main4; |
| 3 | +ipv6 table main6; |
| 4 | +ipv4 table client4; |
| 5 | +ipv6 table client6; |
| 6 | +ipv4 table server4; |
| 7 | +ipv6 table server6; |
| 8 | + |
| 9 | +protocol kernel kernel_main4 { |
| 10 | + kernel table 254; |
| 11 | + merge paths on; |
| 12 | + ipv4 { |
| 13 | + table main4; |
| 14 | + export all; |
| 15 | + }; |
| 16 | +} |
| 17 | + |
| 18 | +protocol kernel kernel_main6 { |
| 19 | + kernel table 254; |
| 20 | + merge paths on; |
| 21 | + ipv6 { |
| 22 | + table main6; |
| 23 | + export all; |
| 24 | + }; |
| 25 | +} |
| 26 | + |
| 27 | +protocol kernel kernel_client4 { |
| 28 | + kernel table 100; |
| 29 | + merge paths on; |
| 30 | + ipv4 { |
| 31 | + table client4; |
| 32 | + export all; |
| 33 | + }; |
| 34 | +} |
| 35 | +protocol kernel kernel_client6 { |
| 36 | + kernel table 100; |
| 37 | + merge paths on; |
| 38 | + ipv6 { |
| 39 | + table client6; |
| 40 | + export all; |
| 41 | + }; |
| 42 | +} |
| 43 | + |
| 44 | +protocol kernel kernel_server4 { |
| 45 | + kernel table 101; |
| 46 | + merge paths on; |
| 47 | + ipv4 { |
| 48 | + table server4; |
| 49 | + export all; |
| 50 | + }; |
| 51 | +} |
| 52 | + |
| 53 | +protocol kernel kernel_server6 { |
| 54 | + kernel table 101; |
| 55 | + merge paths on; |
| 56 | + ipv6 { |
| 57 | + table server6; |
| 58 | + export all; |
| 59 | + }; |
| 60 | +} |
| 61 | + |
| 62 | +protocol static static_main4 { |
| 63 | + ipv4 { |
| 64 | + table main4; |
| 65 | + }; |
| 66 | + igp table main4; |
| 67 | + igp table main6; |
| 68 | + |
| 69 | + route <%= node.dig(:show, :addresses).fetch(:client4_internal) %>/32 via fe80::b%'veth_c0'; |
| 70 | + route <%= node.dig(:show, :addresses).fetch(:server4_internal) %>/32 via fe80::b%'veth_s0'; |
| 71 | +} |
| 72 | +protocol static static_main6 { |
| 73 | + ipv6 { |
| 74 | + table main6; |
| 75 | + }; |
| 76 | + igp table main4; |
| 77 | + igp table main6; |
| 78 | + |
| 79 | + route <%= node.dig(:show, :addresses).fetch(:client6_internal) %>/128 via fe80::b%'veth_c0'; |
| 80 | + route <%= node.dig(:show, :addresses).fetch(:server6_internal) %>/128 via fe80::b%'veth_s0'; |
| 81 | +} |
| 82 | + |
| 83 | +protocol static static_client4 { |
| 84 | + ipv4 { |
| 85 | + table client4; |
| 86 | + }; |
| 87 | + |
| 88 | + route <%= node.dig(:show, :addresses).fetch(:client4) %> blackhole; |
| 89 | +} |
| 90 | +protocol static static_client6 { |
| 91 | + ipv6 { |
| 92 | + table client6; |
| 93 | + }; |
| 94 | + |
| 95 | + route <%= node.dig(:show, :addresses).fetch(:client6) %> blackhole; |
| 96 | +} |
| 97 | + |
| 98 | +protocol static static_server4 { |
| 99 | + ipv4 { |
| 100 | + table server4; |
| 101 | + }; |
| 102 | + |
| 103 | + route <%= node.dig(:show, :addresses).fetch(:server4) %>/32 blackhole; |
| 104 | +} |
| 105 | +protocol static static_server6 { |
| 106 | + ipv6 { |
| 107 | + table server6; |
| 108 | + }; |
| 109 | + |
| 110 | + route <%= node.dig(:show, :addresses).fetch(:server6) %>/128 blackhole; |
| 111 | + route <%= node.dig(:show, :addresses).fetch(:server6_cidr) %> blackhole; |
| 112 | +} |
| 113 | + |
| 114 | +# er |
| 115 | +<%- servers = node.dig(:show, :interfaces).fetch(:servers); servers.each_with_index do |server, i| -%> |
| 116 | +protocol bgp bgp_server<%= i %> { |
| 117 | + local as <%= server.fetch(:local_as) %>; |
| 118 | + neighbor <%= server.fetch(:link6).fetch(:peer) %> as <%= server.fetch(:peer_as) %>; |
| 119 | + |
| 120 | + ipv4 { |
| 121 | + table server4; |
| 122 | + import all; |
| 123 | + export filter { |
| 124 | + if proto = "static_server4" then accept; |
| 125 | + reject; |
| 126 | + }; |
| 127 | + }; |
| 128 | + ipv6 { |
| 129 | + table server6; |
| 130 | + import all; |
| 131 | + export filter { |
| 132 | + if proto = "static_server6" then accept; |
| 133 | + reject; |
| 134 | + }; |
| 135 | + }; |
| 136 | +} |
| 137 | +<%- end -%> |
| 138 | + |
| 139 | +# cs |
| 140 | +<%- client = node.dig(:show, :interfaces).fetch(:client) -%> |
| 141 | +protocol bgp bgp_client { |
| 142 | + local as <%= client.fetch(:local_as) %>; |
| 143 | + neighbor <%= client.fetch(:link6).fetch(:peer) %> as <%= client.fetch(:peer_as) %>; |
| 144 | + |
| 145 | + ipv4 { |
| 146 | + table client4; |
| 147 | + extended next hop on; |
| 148 | + import all; |
| 149 | + export filter { |
| 150 | + if proto = "static_client4" then accept; |
| 151 | + reject; |
| 152 | + }; |
| 153 | + }; |
| 154 | + ipv6 { |
| 155 | + table client6; |
| 156 | + import all; |
| 157 | + export filter { |
| 158 | + if proto = "static_client6" then accept; |
| 159 | + reject; |
| 160 | + }; |
| 161 | + }; |
| 162 | +} |
0 commit comments