Browse Source

Merge "Modify the network to ensure their more restrictive"

Zuul 6 months ago
parent
commit
873ae46e82
1 changed files with 4 additions and 2 deletions
  1. 4
    2
      tasks/nspawn_networking.yml

+ 4
- 2
tasks/nspawn_networking.yml View File

@@ -102,9 +102,11 @@
102 102
           {%-       set _ = start_commands.append('-/sbin/ip link set dev ' + mv_interface + ' up') %}
103 103
           {%        if hostvars[inventory_hostname][key.split('_')[0] + '_cidr'] is defined and (value.address is undefined) %}
104 104
           {%          set net_cidr = hostvars[inventory_hostname][key.split('_')[0] + '_cidr'] %}
105
-          {%          set _ = start_commands.append('-/sbin/ip route add ' + net_cidr + ' dev ' + (value.routed_interface | default(nspawn_primary_interface)) + ' metric 100 proto kernel scope link table local') %}
105
+          {%          set _ = start_commands.append('-/sbin/ip route add ' ~ net_cidr ~ ' dev ' ~ (value.routed_interface | default(nspawn_primary_interface)) ~ ' metric 100 proto kernel scope link table local') %}
106 106
           {%        elif (value.address is defined) and ((interface_data['ipv4'] | default({'address': none}))['address'] != value.address) and ((value.host_only | default(false)) | bool) %}
107
-          {%          set _ = start_commands.append('-/sbin/ip address add ' + value.address + '/' + (value.netmask | default('32')) + ' dev ' + mv_interface + ' scope host') %}
107
+          {%          set net_cidr = (value.address ~ '/' ~ (value.netmask | default('32'))) %}
108
+          {%          set _ = start_commands.append('-/sbin/ip address add ' ~ net_cidr ~ ' dev ' ~ mv_interface ~ ' scope host noprefixroute') %}
109
+          {%          set _ = start_commands.append('-/sbin/ip route add ' ~ net_cidr ~ '/' ~ (value.netmask | default('32')) ~ ' dev ' ~ mv_interface ~ ' metric 100 proto kernel scope link table local') %}
108 110
           {%-       endif %}
109 111
           {%-     endif %}
110 112
           {%-   endif %}

Loading…
Cancel
Save