Skip to content

Commit cdc73d4

Browse files
committed
Closes #8080: Link to NAT IPs for device/VM primary IPs
1 parent d1e8c06 commit cdc73d4

File tree

4 files changed

+39
-38
lines changed

4 files changed

+39
-38
lines changed

docs/release-notes/version-3.1.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Enhancements
66

77
* [#7665](https://github.com/netbox-community/netbox/issues/7665) - Add toggle to show only available child prefixes
8+
* [#8080](https://github.com/netbox-community/netbox/issues/8080) - Link to NAT IPs for device/VM primary IPs
89

910
### Bug Fixes
1011

netbox/templates/dcim/device.html

+18-18
Original file line numberDiff line numberDiff line change
@@ -179,31 +179,31 @@ <h5 class="card-header">
179179
<tr>
180180
<th scope="row">Primary IPv4</th>
181181
<td>
182-
{% if object.primary_ip4 %}
183-
<a href="{% url 'ipam:ipaddress' pk=object.primary_ip4.pk %}">{{ object.primary_ip4.address.ip }}</a>
184-
{% if object.primary_ip4.nat_inside %}
185-
<span>(NAT for {{ object.primary_ip4.nat_inside.address.ip }})</span>
186-
{% elif object.primary_ip4.nat_outside %}
187-
<span>(NAT: {{ object.primary_ip4.nat_outside.address.ip }})</span>
188-
{% endif %}
189-
{% else %}
190-
<span class="text-muted">&mdash;</span>
182+
{% if object.primary_ip4 %}
183+
<a href="{% url 'ipam:ipaddress' pk=object.primary_ip4.pk %}">{{ object.primary_ip4.address.ip }}</a>
184+
{% if object.primary_ip4.nat_inside %}
185+
(NAT for <a href="{{ object.primary_ip4.nat_inside.get_absolute_url }})">{{ object.primary_ip4.nat_inside.address.ip }}</a>)
186+
{% elif object.primary_ip4.nat_outside %}
187+
(NAT: <a href="{{ object.primary_ip4.nat_outside.get_absolute_url }}">{{ object.primary_ip4.nat_outside.address.ip }}</a>)
191188
{% endif %}
189+
{% else %}
190+
<span class="text-muted">&mdash;</span>
191+
{% endif %}
192192
</td>
193193
</tr>
194194
<tr>
195195
<th scope="row">Primary IPv6</th>
196196
<td>
197-
{% if object.primary_ip6 %}
198-
<a href="{% url 'ipam:ipaddress' pk=object.primary_ip6.pk %}">{{ object.primary_ip6.address.ip }}</a>
199-
{% if object.primary_ip6.nat_inside %}
200-
<span>(NAT for {{ object.primary_ip6.nat_inside.address.ip }})</span>
201-
{% elif object.primary_ip6.nat_outside %}
202-
<span>(NAT: {{ object.primary_ip6.nat_outside.address.ip }})</span>
203-
{% endif %}
204-
{% else %}
205-
<span class="text-muted">&mdash;</span>
197+
{% if object.primary_ip6 %}
198+
<a href="{% url 'ipam:ipaddress' pk=object.primary_ip6.pk %}">{{ object.primary_ip6.address.ip }}</a>
199+
{% if object.primary_ip6.nat_inside %}
200+
(NAT for <a href="{{ object.primary_ip6.nat_inside.get_absolute_url }}">{{ object.primary_ip6.nat_inside.address.ip }}</a>)
201+
{% elif object.primary_ip6.nat_outside %}
202+
(NAT: <a href="{{ object.primary_ip6.nat_outside.get_absolute_url }}">{{ object.primary_ip6.nat_outside.address.ip }}</a>)
206203
{% endif %}
204+
{% else %}
205+
<span class="text-muted">&mdash;</span>
206+
{% endif %}
207207
</td>
208208
</tr>
209209
{% if object.cluster %}

netbox/templates/ipam/ipaddress.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ <h5 class="card-header">
8787
<th scope="row">NAT (inside)</th>
8888
<td>
8989
{% if object.nat_inside %}
90-
<a href="{% url 'ipam:ipaddress' pk=object.nat_inside.pk %}">{{ object.nat_inside }}</a>
90+
<a href="{{ object.nat_inside.get_absolute_url }}">{{ object.nat_inside }}</a>
9191
{% if object.nat_inside.assigned_object %}
9292
(<a href="{{ object.nat_inside.assigned_object.parent_object.get_absolute_url }}">{{ object.nat_inside.assigned_object.parent_object }}</a>)
9393
{% endif %}
@@ -100,7 +100,7 @@ <h5 class="card-header">
100100
<th scope="row">NAT (outside)</th>
101101
<td>
102102
{% if object.nat_outside %}
103-
<a href="{% url 'ipam:ipaddress' pk=object.nat_outside.pk %}">{{ object.nat_outside }}</a>
103+
<a href="{{ object.nat_outside.get_absolute_url }}">{{ object.nat_outside }}</a>
104104
{% else %}
105105
<span class="text-muted">None</span>
106106
{% endif %}

netbox/templates/virtualization/virtualmachine.html

+18-18
Original file line numberDiff line numberDiff line change
@@ -59,31 +59,31 @@ <h5 class="card-header">
5959
<tr>
6060
<th scope="row">Primary IPv4</th>
6161
<td>
62-
{% if object.primary_ip4 %}
63-
<a href="{% url 'ipam:ipaddress' pk=object.primary_ip4.pk %}">{{ object.primary_ip4.address.ip }}</a>
64-
{% if object.primary_ip4.nat_inside %}
65-
<span>(NAT for {{ object.primary_ip4.nat_inside.address.ip }})</span>
66-
{% elif object.primary_ip4.nat_outside %}
67-
<span>(NAT: {{ object.primary_ip4.nat_outside.address.ip }})</span>
68-
{% endif %}
69-
{% else %}
70-
<span class="text-muted">&mdash;</span>
62+
{% if object.primary_ip4 %}
63+
<a href="{% url 'ipam:ipaddress' pk=object.primary_ip4.pk %}">{{ object.primary_ip4.address.ip }}</a>
64+
{% if object.primary_ip4.nat_inside %}
65+
(NAT for <a href="{{ object.primary_ip4.nat_inside.get_absolute_url }}">{{ object.primary_ip4.nat_inside.address.ip }}</a>)
66+
{% elif object.primary_ip4.nat_outside %}
67+
(NAT: <a href="{{ object.primary_ip4.nat_outside.get_absolute_url }}">{{ object.primary_ip4.nat_outside.address.ip }}</a>)
7168
{% endif %}
69+
{% else %}
70+
<span class="text-muted">&mdash;</span>
71+
{% endif %}
7272
</td>
7373
</tr>
7474
<tr>
7575
<th scope="row">Primary IPv6</th>
7676
<td>
77-
{% if object.primary_ip6 %}
78-
<a href="{% url 'ipam:ipaddress' pk=object.primary_ip6.pk %}">{{ object.primary_ip6.address.ip }}</a>
79-
{% if object.primary_ip6.nat_inside %}
80-
<span>(NAT for {{ object.primary_ip6.nat_inside.address.ip }})</span>
81-
{% elif object.primary_ip6.nat_outside %}
82-
<span>(NAT: {{ object.primary_ip6.nat_outside.address.ip }})</span>
83-
{% endif %}
84-
{% else %}
85-
<span class="text-muted">&mdash;</span>
77+
{% if object.primary_ip6 %}
78+
<a href="{% url 'ipam:ipaddress' pk=object.primary_ip6.pk %}">{{ object.primary_ip6.address.ip }}</a>
79+
{% if object.primary_ip6.nat_inside %}
80+
(NAT for <a href="{{ object.primary_ip6.nat_inside.get_absolute_url }}">{{ object.primary_ip6.nat_inside.address.ip }}</a>)
81+
{% elif object.primary_ip6.nat_outside %}
82+
(NAT: <a href="{{ object.primary_ip6.nat_outside.get_absolute_url }}">{{ object.primary_ip6.nat_outside.address.ip }}</a>)
8683
{% endif %}
84+
{% else %}
85+
<span class="text-muted">&mdash;</span>
86+
{% endif %}
8787
</td>
8888
</tr>
8989
</table>

0 commit comments

Comments
 (0)