From aca56a9eb5d0642b6b101240928c36d4f5583e77 Mon Sep 17 00:00:00 2001 From: Anthony Arnoux Date: Wed, 1 Feb 2023 16:52:36 +0100 Subject: [PATCH 1/2] mkvm.ps1 toute les vms OK --- scripts/mkvm.ps1 | 190 +++++++++++++++++++++++------------------------ 1 file changed, 94 insertions(+), 96 deletions(-) diff --git a/scripts/mkvm.ps1 b/scripts/mkvm.ps1 index ab87f38..d81246a 100644 --- a/scripts/mkvm.ps1 +++ b/scripts/mkvm.ps1 @@ -22,11 +22,10 @@ function create_vm{ param([string]$nomvm) function create_if{ param([string]$nomvm, [string]$nic, [int]$rang, [string]$reseau) #Création d'une interface if ($nomvm -and $nic -and $rang -and $reseau) { - #if ("1" -eq "1") { if ($nic -eq "bridge") { #Création d'une interface en pont & "$vboxmanage" modifyvm "$nomvm" --nic"$rang" bridged - & "$vboxmanage" modifyvm "$nomvm" --nictype"$rang" 82540EM + & "$vboxmanage" modifyvm "$nomvm" --nictype"$rang" virtio & "$vboxmanage" modifyvm "$nomvm" --cableconnected"$rang" on & "$vboxmanage" modifyvm "$nomvm" --nicpromisc"$rang" allow-all Write-Host "$nomvm : IF$rang $nic" @@ -35,7 +34,7 @@ function create_if{ param([string]$nomvm, [string]$nic, [int]$rang, [string]$res #Création d'une interface en reseau interne & "$vboxmanage" modifyvm "$nomvm" --nic"$rang" intnet & "$vboxmanage" modifyvm "$nomvm" --intnet"$rang" "$reseau" - & "$vboxmanage" modifyvm "$nomvm" --nictype"$rang" 82540EM + & "$vboxmanage" modifyvm "$nomvm" --nictype"$rang" virtio & "$vboxmanage" modifyvm "$nomvm" --cableconnected"$rang" on & "$vboxmanage" modifyvm "$nomvm" --nicpromisc"$rang" allow-all Write-Host "$nomvm : IF$rang $nic $reseau" @@ -43,6 +42,9 @@ function create_if{ param([string]$nomvm, [string]$nic, [int]$rang, [string]$res } } +function usage{ + Write-Host "usage : mkvm ${myInvocation.ScriptName} " +} if ($args[0] -eq "s-adm") { @@ -52,107 +54,103 @@ if ($args[0] -eq "s-adm") { } -elseif ($args[0] -eq "s-infra") { +elseif ($args[0] -eq "r-int") { create_vm $args[0] create_if $args[0] "int" 1 "n-adm" - create_if $args[0] "int" 2 "n-infra" - -#création de la première interface -& "$vboxmanage" modifyvm "s-infra" --nic1 intnet -& "$vboxmanage" modifyvm "s-infra" --intnet1 "n-adm" -& "$vboxmanage" modifyvm "s-infra" --nictype1 82540EM -& "$vboxmanage" modifyvm "s-infra" --cableconnected1 on -& "$vboxmanage" modifyvm "s-infra" --nicpromisc1 allow-all - -#création de la deuxième interface -& "$vboxmanage" modifyvm "s-infra" --nic2 intnet -& "$vboxmanage" modifyvm "s-infra" --intnet2 "n-infra" -& "$vboxmanage" modifyvm "s-infra" --nictype2 82540EM -& "$vboxmanage" modifyvm "s-infra" --cableconnected2 on -& "$vboxmanage" modifyvm "s-infra" --nicpromisc2 allow-all -} - -elseif ($args[0] -eq "r-int") { - - create_vm($args[0]) - -#interface 1 -& "$vboxmanage" modifyvm "r-int" --nic1 intnet -& "$vboxmanage" modifyvm "r-int" --intnet1 "n-adm" -& "$vboxmanage" modifyvm "r-int" --nictype1 82540EM -& "$vboxmanage" modifyvm "r-int" --cableconnected1 on -& "$vboxmanage" modifyvm "r-int" --nicpromisc1 allow-all - -#interface 2 -& "$vboxmanage" modifyvm "r-int" --nic2 intnet -& "$vboxmanage" modifyvm "r-int" --intnet2 "n-link" -& "$vboxmanage" modifyvm "r-int" --nictype2 82540EM -& "$vboxmanage" modifyvm "r-int" --cableconnected2 on -& "$vboxmanage" modifyvm "r-int" --nicpromisc2 allow-all - -#interface 3 -& "$vboxmanage" modifyvm "r-int" --nic3 intnet -& "$vboxmanage" modifyvm "r-int" --intnet3 "n-wifi" -& "$vboxmanage" modifyvm "r-int" --nictype3 82540EM -& "$vboxmanage" modifyvm "r-int" --cableconnected3 on -& "$vboxmanage" modifyvm "r-int" --nicpromisc3 allow-all - -#interface 4 -& "$vboxmanage" modifyvm "r-int" --nic4 intnet -& "$vboxmanage" modifyvm "r-int" --intnet4 "n-user" -& "$vboxmanage" modifyvm "r-int" --nictype4 82540EM -& "$vboxmanage" modifyvm "r-int" --cableconnected4 on -& "$vboxmanage" modifyvm "r-int" --nicpromisc4 allow-all - -#interface 5 -& "$vboxmanage" modifyvm "r-int" --nic5 intnet -& "$vboxmanage" modifyvm "r-int" --intnet5 "n-infra" -& "$vboxmanage" modifyvm "r-int" --nictype5 82540EM -& "$vboxmanage" modifyvm "r-int" --cableconnected5 on -& "$vboxmanage" modifyvm "r-int" --nicpromisc5 allow-all + create_if $args[0] "int" 2 "n-link" + create_if $args[0] "int" 3 "n-wifi" + create_if $args[0] "int" 4 "n-user" + create_if $args[0] "int" 5 "n-infra" } elseif ($args[0] -eq "r-ext") { - create_vm($args[0]) - -#interface 1 -& "$vboxmanage" modifyvm "r-ext" --nic1 intnet -& "$vboxmanage" modifyvm "r-ext" --intnet1 "n-adm" -& "$vboxmanage" modifyvm "r-ext" --nictype1 82540EM -& "$vboxmanage" modifyvm "r-ext" --cableconnected1 on -& "$vboxmanage" modifyvm "r-ext" --nicpromisc1 allow-all - -#interface 2 -& "$vboxmanage" modifyvm "r-ext" --nic2 intnet -& "$vboxmanage" modifyvm "r-ext" --intnet2 "n-dmz" -& "$vboxmanage" modifyvm "r-ext" --nictype2 82540EM -& "$vboxmanage" modifyvm "r-ext" --cableconnected2 on -& "$vboxmanage" modifyvm "r-ext" --nicpromisc2 allow-all - -#interface 3 -& "$vboxmanage" modifyvm "r-ext" --nic3 bridged -& "$vboxmanage" modifyvm "r-ext" --nictype3 82540EM -& "$vboxmanage" modifyvm "r-ext" --cableconnected3 on -& "$vboxmanage" modifyvm "r-ext" --nicpromisc3 allow-all - -#interface 4 -& "$vboxmanage" modifyvm "r-ext" --nic4 intnet -& "$vboxmanage" modifyvm "r-ext" --intnet4 "n-linkv" -& "$vboxmanage" modifyvm "r-ext" --nictype4 82540EM -& "$vboxmanage" modifyvm "r-ext" --cableconnected4 on -& "$vboxmanage" modifyvm "r-ext" --nicpromisc4 allow-all - -#interface 5 -& "$vboxmanage" modifyvm "r-ext" --nic5 intnet -& "$vboxmanage" modifyvm "r-ext" --intnet5 "n-link" -& "$vboxmanage" modifyvm "r-ext" --nictype5 82540EM -& "$vboxmanage" modifyvm "r-ext" --cableconnected5 on -& "$vboxmanage" modifyvm "r-ext" --nicpromisc5 allow-all + create_vm $args[0] + create_if $args[0] "int" 1 "n-adm" + create_if $args[0] "int" 2 "n-dmz" + create_if $args[0] "bridge" 3 "null" + create_if $args[0] "int" 4 "n-linkv" + create_if $args[0] "int" 5 "n-link" } -elseif ($args[0] -eq "test") { +elseif (((((((($args[0] -eq "s-elk") ` +-or ($args[0] -eq "s-mon") ` +-or ($args[0] -eq "s-backup") ` +-or ($args[0] -eq "s-appli") ` +-or ($args[0] -eq "s-infra") ` +-or ($args[0] -eq "s-proxy") ` +-or ($args[0] -eq "s-itil") ` +-or ($args[0] -eq "s-nxc") ` +))))))) { -fonction1 $args[0] $args[1] + create_vm $args[0] + create_if $args[0] "int" 1 "n-adm" + create_if $args[0] "int" 2 "n-infra" +} + +elseif ($args[0] -eq "s-fog") { + + create_vm $args[0] + create_if $args[0] "int" 1 "n-adm" + create_if $args[0] "int" 2 "n-infra" + create_if $args[0] "int" 3 "n-user" +} + +elseif ($args[0] -eq "s-agence") { + + create_vm $args[0] + create_if $args[0] "int" 1 "n-adm" + create_if $args[0] "int" 2 "n-agence" +} + +elseif ($args[0] -eq "s-lb") { + + create_vm $args[0] + create_if $args[0] "int" 1 "n-adm" + create_if $args[0] "int" 2 "n-dmz" + create_if $args[0] "int" 3 "n-dmz-lb" +} + +elseif (($args[0] -eq "s-lb-db") -or ($args[0] -eq "s-nas")) { + + create_vm $args[0] + create_if $args[0] "int" 1 "n-adm" + create_if $args[0] "int" 2 "n-dmz-db" +} + +elseif ((($args[0] -eq "s-lb-web1") -or ($args[0] -eq "s-lb-web2") -or ($args[0] -eq "s-lb-web3"))) { + + create_vm $args[0] + create_if $args[0] "int" 1 "n-adm" + create_if $args[0] "int" 2 "n-dmz-lb" + create_if $args[0] "int" 3 "n-dmz-db" +} + +elseif (($args[0] -eq "s-dns-ext") -or ($args[0] -eq "s-web-ext")) { + + create_vm $args[0] + create_if $args[0] "int" 1 "n-adm" + create_if $args[0] "int" 2 "n-infra" + create_if $args[0] "int" 3 "n-user" +} + +elseif ($args[0] -eq "r-vp1") { + + create_vm $args[0] + create_if $args[0] "int" 1 "n-adm" + create_if $args[0] "int" 2 "n-linkv" + create_if $args[0] "bridge" 3 "null" +} + +elseif ($args[0] -eq "r-vp2") { + + create_vm $args[0] + create_if $args[0] "int" 1 "n-adm" + create_if $args[0] "int" 2 "n-agence" + create_if $args[0] "bridge" 3 "null" +} + +else { + usage } \ No newline at end of file From be38bd02516ee458079b3ccef8c41ce455704acb Mon Sep 17 00:00:00 2001 From: Mathis Laceppe Date: Wed, 1 Feb 2023 17:16:04 +0100 Subject: [PATCH 2/2] ajout activation wg0 --- scripts/r-vp2-post.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/r-vp2-post.sh b/scripts/r-vp2-post.sh index 9317c75..665ef76 100644 --- a/scripts/r-vp2-post.sh +++ b/scripts/r-vp2-post.sh @@ -3,3 +3,5 @@ wget http://r-vp1.gsb.adm:8000/wg0-b.qconf #renomage fichier et mv mv ./wg0-b.conf /etc/wireguard/wg0.conf +#activation interface wg0 +systemctl enable wg-quick@wg0 && systemctl start wg-quick@wg0