]> git.openstreetmap.org Git - chef.git/blob - cookbooks/networking/templates/default/network.erb
Use source routing to pick the correct external network on faffy
[chef.git] / cookbooks / networking / templates / default / network.erb
1 [Match]
2 Name=<%= @interface[:interface] %>
3
4 [Network]
5 <% if @interface.dig(:inet6, :dhcp) -%>
6 DHCP=ipv6
7 <% end -%>
8 <% if @interface[:inet] -%>
9 Address=<%= @interface[:inet][:address] %>/<%== @interface[:inet][:prefix] %>
10 <% end -%>
11 <% if @interface[:inet6] -%>
12 Address=<%= @interface[:inet6][:address] %>/<%== @interface[:inet6][:prefix] %>
13 <% end -%>
14 IPv6AcceptRA=no
15 <% Array(@interface[:vlans]).sort.uniq.each do |vlan| -%>
16 VLAN=<%= @interface[:interface] %>.<%= vlan %>
17 <% end -%>
18 <% if @interface.dig(:inet6, :dhcp) -%>
19
20 [DHCPv6]
21 <% if @interface[:inet6][:dhcp][:duidtype] -%>
22 DUIDType=<%= @interface[:inet6][:dhcp][:duidtype] %>
23 <% end -%>
24 <% if @interface[:inet6][:dhcp][:duidrawdata] -%>
25 DUIDRawData=<%= @interface[:inet6][:dhcp][:duidrawdata] %>
26 <% end -%>
27 WithoutRA=solicit
28 <% end -%>
29 <% if @interface.dig(:inet, :gateway) && @interface[:inet][:gateway] != @interface[:inet][:address] -%>
30
31 [Route]
32 Gateway=<%= @interface[:inet][:gateway] %>
33 GatewayOnLink=true
34 <% if @interface[:metric] -%>
35 Metric=<%= @interface[:metric] %>
36 <% end -%>
37 <% if @interface[:source_route_table] -%>
38
39 [Route]
40 Gateway=<%= @interface[:inet][:gateway] %>
41 GatewayOnLink=true
42 <% if @interface[:metric] -%>
43 Metric=<%= @interface[:metric] %>
44 <% end -%>
45 Table=<%= @interface[:source_route_table] %>
46
47 [RoutingPolicyRule]
48 From=<%= @interface[:inet][:address] %>
49 Table=<%= @interface[:source_route_table] %>
50 <% end -%>
51 <% end -%>
52 <% if @interface.dig(:inet6, :gateway) && @interface[:inet6][:gateway] != @interface[:inet6][:address] -%>
53
54 [Route]
55 Gateway=<%= @interface[:inet6][:gateway] %>
56 GatewayOnLink=true
57 <% if @interface[:metric] -%>
58 Metric=<%= @interface[:metric] %>
59 <% end -%>
60 <% if @interface[:source_route_table] -%>
61
62 [Route]
63 Gateway=<%= @interface[:inet6][:gateway] %>
64 GatewayOnLink=true
65 <% if @interface[:metric] -%>
66 Metric=<%= @interface[:metric] %>
67 <% end -%>
68 Table=<%= @interface[:source_route_table] %>
69
70 [RoutingPolicyRule]
71 From=<%= @interface[:inet6][:address] %>
72 Table=<%= @interface[:source_route_table] %>
73 <% end -%>
74 <% end -%>
75 <% Hash(@interface.dig(:inet, :routes)).sort.each do |destination, details| -%>
76 <% unless details[:via] == @interface[:inet][:address] -%>
77
78 [Route]
79 <% if details[:via] -%>
80 Gateway=<%= details[:via] %>
81 <% end -%>
82 Destination=<%= destination %>
83 <% if details[:metric] -%>
84 Metric=<%= details[:metric] %>
85 <% end -%>
86 <% if details[:type] -%>
87 Type=<%= details[:type] %>
88 <% end -%>
89 <% end -%>
90 <% end -%>
91 <% Hash(@interface.dig(:inet6, :routes)).sort.each do |destination, details| -%>
92 <% unless details[:via] == @interface[:inet6][:address] -%>
93
94 [Route]
95 <% if details[:via] -%>
96 Gateway=<%= details[:via] %>
97 <% end -%>
98 Destination=<%= destination %>
99 <% if details[:metric] -%>
100 Metric=<%= details[:metric] %>
101 <% end -%>
102 <% if details[:type] -%>
103 Type=<%= details[:type] %>
104 <% end -%>
105 <% end -%>
106 <% end -%>