From 14fcb6e6a21aeaf0a43944dc13f1b66996cc00b6 Mon Sep 17 00:00:00 2001 From: Mark Gilbert <50398495+MarkProminic@users.noreply.github.com> Date: Mon, 11 Dec 2023 16:44:35 -0600 Subject: [PATCH] fix: update netplan --- lib/vagrant-zones/driver.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/vagrant-zones/driver.rb b/lib/vagrant-zones/driver.rb index 7810a80..bb41b87 100644 --- a/lib/vagrant-zones/driver.rb +++ b/lib/vagrant-zones/driver.rb @@ -527,12 +527,19 @@ def zonenicnatsetup_netplan(uii, opts, mac) uii.info(" #{vnic_name}") netplan1 = %(network:\n version: 2\n ethernets:\n #{vnic_name}:\n match:\n macaddress: #{mac}\n) netplan2 = %( dhcp-identifier: mac\n dhcp4: #{opts[:dhcp4]}\n dhcp6: #{opts[:dhcp6]}\n) - netplan3 = %( set-name: #{vnic_name}\n addresses: [#{ip}/#{shrtsubnet}]\n gateway4: #{defrouter}\n) + #netplan3 = %( set-name: #{vnic_name}\n addresses: [#{ip}/#{shrtsubnet}]\n gateway4: #{defrouter}\n) + netplan3 = %( set-name: #{vnic_name}\n addresses: [#{ip}/#{shrtsubnet}]\n routes:\n - to: default\n via: #{defrouter}\n) netplan4 = %( nameservers:\n addresses: [#{servers[0]['nameserver']} , #{servers[1]['nameserver']}] ) netplan = netplan1 + netplan2 + netplan3 + netplan4 cmd = "echo -e '#{netplan}' | sudo tee /etc/netplan/#{vnic_name}.yaml" uii.info(I18n.t('vagrant_zones.netplan_applied_static') + "/etc/netplan/#{vnic_name}.yaml") if ssh_run_command(uii, cmd) + + routes: + - to: default + via: {{ networks[0].gateway }} + + ## Apply the Configuration uii.info(I18n.t('vagrant_zones.netplan_applied')) if ssh_run_command(uii, 'sudo netplan apply') ## End of code block to move to Netplan function @@ -1146,7 +1153,8 @@ def zoneniczloginsetup_netplan(uii, opts, mac) netplan2 = %( dhcp-identifier: mac\n dhcp4: #{opts[:dhcp4]}\n dhcp6: #{opts[:dhcp6]}\n) if opts[:dhcp4] netplan3 = %( set-name: #{vnic_name}\n addresses: [#{ip}/#{shrtsubnet}]\n) netplan3 = %( set-name: #{vnic_name}\n) if opts[:dhcp4] - netplan4 = %( gateway4: #{defrouter}\n) + #netplan4 = %( gateway4: #{defrouter}\n) + netplan4 = %( routes:\n - to: default\n via: #{defrouter}\n) netplan5 = %( nameservers:\n addresses: [#{servers[0]['nameserver']} , #{servers[1]['nameserver']}] ) netplan = netplan1 + netplan2 + netplan3 + netplan5 if opts[:gateway].nil? netplan = netplan1 + netplan2 + netplan3 + netplan4 + netplan5 unless opts[:gateway].nil?