]> git.openstreetmap.org Git - chef.git/blob - cookbooks/networking/templates/default/network.erb
Use correct gateway for additional routes
[chef.git] / cookbooks / networking / templates / default / network.erb
1 [Match]
2 Name=<%= @interface[:interface] %>
3
4 [Network]
5 <% if @interface[:inet] -%>
6 Address=<%= @interface[:inet][:address] %>/<%== @interface[:inet][:prefix] %>
7 <% end -%>
8 <% if @interface[:inet6] -%>
9 Address=<%= @interface[:inet6][:address] %>/<%== @interface[:inet6][:prefix] %>
10 <% end -%>
11 IPv6AcceptRA=no
12 <% Array(@interface[:vlans]).sort.uniq.each do |vlan| -%>
13 VLAN=<%= @interface[:interface] %>.<%= vlan %>
14 <% end -%>
15 <% if @interface.dig(:inet, :gateway) && @interface[:inet][:gateway] != @interface[:inet][:address] -%>
16
17 [Route]
18 Gateway=<%= @interface[:inet][:gateway] %>
19 GatewayOnLink=true
20 <% if @interface[:metric] -%>
21 Metric=<%= @interface[:metric] %>
22 <% end -%>
23 <% end -%>
24 <% if @interface.dig(:inet6, :gateway) && @interface[:inet6][:gateway] != @interface[:inet6][:address] -%>
25
26 [Route]
27 Gateway=<%= @interface[:inet6][:gateway] %>
28 GatewayOnLink=true
29 <% if @interface[:metric] -%>
30 Metric=<%= @interface[:metric] %>
31 <% end -%>
32 <% end -%>
33 <% Hash(@interface.dig(:inet, :routes)).sort.each do |destination, details| -%>
34
35 [Route]
36 <% if details[:via] -%>
37 Gateway=<%= details[:via] %>
38 <% end -%>
39 Destination=<%= destination %>
40 <% if details[:metric] -%>
41 Metric=<%= details[:metric] %>
42 <% end -%>
43 <% if details[:type] -%>
44 Type=<%= details[:type] %>
45 <% end -%>
46 <% end -%>
47 <% Hash(@interface.dig(:inet6, :routes)).sort.each do |destination, details| -%>
48
49 [Route]
50 <% if details[:via] -%>
51 Gateway=<%= details[:via] %>
52 <% end -%>
53 Destination=<%= destination %>
54 <% if details[:metric] -%>
55 Metric=<%= details[:metric] %>
56 <% end -%>
57 <% if details[:type] -%>
58 Type=<%= details[:type] %>
59 <% end -%>
60 <% end -%>