aboutsummaryrefslogtreecommitdiffstats
path: root/examples/tg23/templates/core-dynamic-networks.conf
blob: 2f06e7b0a67f0632f116d0a5fa47b18f7f15203e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
{%- set floor_distros = [
    'd1.floor',
    'd2.floor',
    'd3.floor',
    'd4.floor',
    'd5.floor',
    'd6.floor',
    ]
%}

{% set ae10_networks = [] %} {# networks via roof #}
{% set ae11_networks = [] %} {# networks via ring #}

{% for key, switchname in v.tree['d1.ring'].items() %}
{# some switches might not have networks. For instance wifi or "utskutt-distro" #}
    {% if switchname in v.distro_networks %}
        {% do ae11_networks.append(v.distro_networks[switchname]) %}
    {% endif %}
    {% if "distro-utskutt" in objects["public/switches"].switches[switchname].tags %}
        {% if switchname in v.tree %}
            {% for key, switchname2 in v.tree[switchname].items() %}
                {% do ae11_networks.append(v.distro_networks[switchname2]) %}
            {% endfor %}
        {% endif %}
    {% endif %}
{% endfor %}


{% for distro in floor_distros %}
    {% if v.tree[distro] %}
        {% for key, switchname in v.tree[distro].items() %}
            {% do ae10_networks.append(v.distro_networks[switchname]) %}
        {% endfor %}
    {% endif %}
{% endfor %}


{# NAT stuff gulvet #}
routing-instances {
    NAT-LAN {
{% for distro in floor_distros %}
    {% if v.tree[distro] %}
        {% for key, switchname in v.tree[distro].items() %}
            {% if "nat" in objects["public/switches"].switches[switchname].tags %}
                {% set network = v.distro_networks[switchname] %}
        interface ae10.{{ network.vlan }};
            {% endif %}
        {% endfor %}
    {% endif %}
{% endfor %}

{# NAT stuff ringen #}
{% if v.tree['d1.ring'] %}
    {% for key, switchname in v.tree['d1.ring'].items() %}
        {% set network = v.distro_networks[switchname] %}
        {% if "nat" in objects["public/switches"].switches[switchname].tags %}
        interface ae11.{{ network.vlan }};
        {% endif %}
    {% endfor %}
{% endif %}
    }
}
{# Roof / Floor stuff #}
interfaces {
    ae10 {
        {% for network in ae10_networks %}
        unit {{ network.vlan }} {
            description "C: {{ network.name }} - VLAN {{ network.vlan }}";
            no-traps;
            vlan-tags outer {{ network.vlan }};
            family inet {
                no-redirects;
                address {{ network.gw4 }}/{{ network.subnet4|cidr }};
            }
            family inet6 {
                address {{ network.gw6 }}/{{ network.subnet6|cidr }};
            }
        }
        {% endfor %}
    }
}

protocols {
    router-advertisement {
        {% for network in ae10_networks %}
        interface ae10.{{ network.vlan }} {
            max-advertisement-interval 30;
            managed-configuration;
            other-stateful-configuration;
        }
        {% endfor %}
    }
}

forwarding-options {
    dhcp-relay {
        dhcpv6 {
            group all-networks {
                {% for network in ae10_networks %}
                interface ae10.{{ network.vlan }};
                {% endfor %}
            }
        }
        group all-networks {
            {% for network in ae10_networks %}
            interface ae10.{{ network.vlan }};
            {% endfor %}
        }
    }
}

{# Ring stuff #}
{% if v.tree['d1.ring'] %}
interfaces {
    ae11 {
        {% for network in ae11_networks %}
        unit {{ network.vlan }} {
            description "C: {{ network.name }} - VLAN {{ network.vlan }}";
            no-traps;
            vlan-tags outer {{ network.vlan }};
            family inet {
                no-redirects;
                address {{ network.gw4 }}/{{ network.subnet4|cidr }};
            }
            family inet6 {
                address {{ network.gw6 }}/{{ network.subnet6|cidr }};
            }
        }
        {% endfor %}
    }
}
protocols {
    router-advertisement {
        {% for network in ae11_networks %}
        interface ae11.{{ network.vlan }} {
            max-advertisement-interval 30;
            managed-configuration;
            other-stateful-configuration;
        }
        {% endfor %}
    }
}

forwarding-options {
    dhcp-relay {
        dhcpv6 {
            group all-networks {
                {% for network in ae11_networks %}
                interface ae11.{{ network.vlan }};
                {% endfor %}
            }
        }
        group all-networks {
            {% for network in ae11_networks %}
            interface ae11.{{ network.vlan }};
            {% endfor %}
        }
    }
}
{% endif %}