Ultra commenting + echoing
Now only need testing...
This commit is contained in:
parent
4a39822b6d
commit
9b6510871a
@ -5,23 +5,36 @@
|
||||
# RTR-01 Only
|
||||
# Script done
|
||||
|
||||
# Change the poor machine name
|
||||
|
||||
|
||||
echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
|
||||
|
||||
### Change the poor machine name
|
||||
|
||||
echo "Changing Computer's name"
|
||||
Rename-computer RTR-01
|
||||
|
||||
# End of renaming
|
||||
|
||||
### Rename Adapters by parsing the VM device name
|
||||
|
||||
echo "Renaming adapters"
|
||||
$adapts = Get-NetAdapter
|
||||
foreach ($adapt in $adapts) {
|
||||
$HVName = (Get-NetAdapterAdvancedProperty -name $adapt.name -DisplayName "Hyper-v Network Adapter Name").DisplayValue
|
||||
Rename-Netadapter -name $adapt.name -NewName $HVName
|
||||
}
|
||||
#End
|
||||
|
||||
### Pausing to let things settle
|
||||
|
||||
echo "Sleeping 10s"
|
||||
Sleep 10
|
||||
#End
|
||||
|
||||
#Général IP configure
|
||||
### Général IP configure
|
||||
|
||||
echo "IP configuration"
|
||||
$MaskBits = 24 # This means subnet mask = 255.255.255.0
|
||||
$IPType = "IPv4"
|
||||
|
||||
@ -34,7 +47,7 @@ $adapter | New-NetIPAddress `
|
||||
-IPAddress $IP `
|
||||
-PrefixLength $MaskBits
|
||||
|
||||
#Arc-CLI
|
||||
#Arc-CLI conf
|
||||
|
||||
$adapter = Get-NetAdapter | ? {$_.Name -eq "Arc-CLI"}
|
||||
$IP = "192.168.12.254"
|
||||
@ -43,7 +56,7 @@ $adapter | New-NetIPAddress `
|
||||
-IPAddress $IP `
|
||||
-PrefixLength $MaskBits `
|
||||
|
||||
#WAN
|
||||
### WAN conf
|
||||
|
||||
$adapter = Get-NetAdapter | ? {$_.Name -eq "WAN"}
|
||||
$IP = "192.168.255.8"
|
||||
@ -53,26 +66,32 @@ $adapter | New-NetIPAddress `
|
||||
-PrefixLength $MaskBits `
|
||||
-DefaultGateway "192.168.255.254"
|
||||
|
||||
#DNS Conf for all InterfaceAlias
|
||||
|
||||
### DNS Conf for all InterfaceAlias ###
|
||||
|
||||
echo "DNS conf"
|
||||
foreach ($c in Get-NetAdapter) { write-host 'Setting DNS for' $c.interfaceName ; Set-DnsClientServerAddress -InterfaceIndex $c.interfaceindex -ServerAddresses ('9.9.9.9') }
|
||||
|
||||
# End of scriptlet
|
||||
|
||||
# Install Routing and necessary linked roles
|
||||
### Install Routing and necessary linked roles ###
|
||||
|
||||
echo "Installing Remote-Access, RSAT, Routing"
|
||||
Install-WindowsFeature RemoteAccess, RSAT-RemoteAccess-PowerShell, Routing -IncludeManagementTools
|
||||
|
||||
#Install VPN
|
||||
# End of scritlet
|
||||
|
||||
### Install VPN (necessary?) ###
|
||||
|
||||
echo "Installing VPN"
|
||||
echo "Install-remoteAccess -VpnType Vpn"
|
||||
Install-remoteAccess -VpnType Vpn
|
||||
Set-NetConnectionProfile -NetworkCategory Private
|
||||
$Params = @{
|
||||
"Name" = 'vm-monitoring-icmpv4'
|
||||
"Action" = 'Allow'
|
||||
}
|
||||
|
||||
Set-NetFirewallRule @Params
|
||||
# End of scritlet
|
||||
|
||||
# Activate NAT and DHCP Relay
|
||||
echo "Activate NAT and DHCP Relay"
|
||||
### Activate NAT and DHCP Relay ###
|
||||
|
||||
echo "Activating NAT and DHCP Relay"
|
||||
netsh routing ip relay install
|
||||
|
||||
netsh routing ip add interface name="Arc-SRV" state=enable
|
||||
@ -87,16 +106,27 @@ netsh routing ip relay add interface "Arc-SRV"
|
||||
netsh rout ip rel set int WAN min=0
|
||||
netsh routing ip relay add dhcpserver 192.168.8.1
|
||||
|
||||
### Activating remote-access role
|
||||
|
||||
set-service RemoteAccess -StartupType Automatic
|
||||
Start-Service RemoteAccess
|
||||
#END
|
||||
|
||||
netsh -f ./Arc-CLI.conf
|
||||
netsh -f ./Arc-SRV.conf
|
||||
netsh -f ./WAN.conf
|
||||
### Activating DHCP Relay (Useless?)
|
||||
|
||||
#netsh -f ./Arc-CLI.conf
|
||||
#netsh -f ./Arc-SRV.conf
|
||||
#netsh -f ./WAN.conf
|
||||
|
||||
# End of scriptlet
|
||||
|
||||
### Set connection as private ###
|
||||
echo "Set connection as private"
|
||||
Set-NetConnectionProfile -networkcategory private
|
||||
|
||||
# Change ZoneAlarm rule to accept incoming ICMP ipv4 probes
|
||||
### Change ZoneAlarm rule to accept incoming ICMP ipv4 probes ###
|
||||
|
||||
echo "Allowing ICMPv4 probes"
|
||||
$Params = @{
|
||||
"Name" = 'vm-monitoring-icmpv4'
|
||||
"Action" = 'Allow'
|
||||
@ -104,9 +134,15 @@ $Params = @{
|
||||
|
||||
Set-NetFirewallRule @Params
|
||||
|
||||
# Add routes
|
||||
# End of scritlet
|
||||
|
||||
### Add routes
|
||||
|
||||
echo "Adding route"
|
||||
route add -p 192.168.128.8/24 192.168.255.128
|
||||
route add -p 0.0.0.0/0 192.168.255.254
|
||||
|
||||
# End of scritlet
|
||||
|
||||
|
||||
Read-Host "Finished???"
|
||||
|
@ -2,26 +2,33 @@
|
||||
# GPLv3
|
||||
|
||||
# Script to install and configure a Fuckdows Server 2016 as a router
|
||||
# RTR-01 Only
|
||||
# Script done
|
||||
|
||||
# Change the poor machine name
|
||||
# RTR-02 Only
|
||||
|
||||
echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
|
||||
|
||||
Rename-computer RTR-02
|
||||
### Change VM name
|
||||
|
||||
echo "Changing computer Name"
|
||||
Rename-computer RTR-02
|
||||
#End
|
||||
|
||||
### Rename Adapters by parsing the VM device name
|
||||
$adapts = Get-NetAdapter
|
||||
foreach ($adapt in $adapts) {
|
||||
$HVName = (Get-NetAdapterAdvancedProperty -name $adapt.name -DisplayName "Hyper-v Network Adapter Name").DisplayValue
|
||||
Rename-Netadapter -name $adapt.name -NewName $HVName
|
||||
}
|
||||
# End
|
||||
|
||||
### Pausing to let things settle
|
||||
|
||||
echo "Sleeping 30s"
|
||||
Sleep 10
|
||||
#End
|
||||
|
||||
#Général IP configure
|
||||
### Général IP configure
|
||||
|
||||
echo "IP configuration"
|
||||
$MaskBits = 24 # This means subnet mask = 255.255.255.0
|
||||
$IPType = "IPv4"
|
||||
|
||||
@ -43,25 +50,47 @@ $adapter | New-NetIPAddress `
|
||||
-IPAddress $IP `
|
||||
-PrefixLength $MaskBits `
|
||||
|
||||
#DNS Conf for all InterfaceAlias
|
||||
# END
|
||||
|
||||
### DNS Conf for all InterfaceAlias
|
||||
echo "Configuring Dns"
|
||||
foreach ($c in Get-NetAdapter) { write-host 'Setting DNS for' $c.interfaceName ; Set-DnsClientServerAddress -InterfaceIndex $c.interfaceindex -ServerAddresses ('9.9.9.9') }
|
||||
#End
|
||||
|
||||
### Install Routing and necessary linked roles + autostart
|
||||
|
||||
# Install Routing and necessary linked roles
|
||||
echo "Installing Remote-Access, RSAT, Routing + Auto-start"
|
||||
Install-WindowsFeature RemoteAccess, RSAT-RemoteAccess-PowerShell, Routing -IncludeManagementTools
|
||||
set-service RemoteAccess -StartupType Automatic
|
||||
Start-Service RemoteAccess
|
||||
|
||||
#Install VPN
|
||||
echo "Install-remoteAccess -VpnType Vpn"
|
||||
#END
|
||||
|
||||
### Install VPN (?)
|
||||
|
||||
echo "installing VPN role"
|
||||
Install-remoteAccess -VpnType Vpn
|
||||
#End
|
||||
|
||||
### Set connection as Private
|
||||
|
||||
echo "Set connection as private"
|
||||
Set-NetConnectionProfile -NetworkCategory Private
|
||||
#END
|
||||
|
||||
### Activing ICMPv4 probes
|
||||
|
||||
echo "Activating ICMPv4 probes"
|
||||
$Params = @{
|
||||
"Name" = 'vm-monitoring-icmpv4'
|
||||
"Action" = 'Allow'
|
||||
}
|
||||
|
||||
Set-NetFirewallRule @Params
|
||||
#END
|
||||
|
||||
### Activate NAT and DHCP Relay
|
||||
|
||||
# Activate NAT and DHCP Relay
|
||||
echo "Activate NAT and DHCP Relay"
|
||||
netsh routing ip relay install
|
||||
|
||||
@ -75,24 +104,12 @@ netsh routing ip relay add interface "WAN"
|
||||
netsh rout ip rel set int WAN min=0
|
||||
netsh routing ip relay add dhcpserver 192.168.8.1
|
||||
|
||||
set-service RemoteAccess -StartupType Automatic
|
||||
Start-Service RemoteAccess
|
||||
#netsh -f ./WAN.conf
|
||||
#netsh -f ./Bou-LAN.conf
|
||||
|
||||
netsh -f ./WAN.conf
|
||||
netsh -f ./Bou-LAN.conf
|
||||
|
||||
Set-NetConnectionProfile -networkcategory private
|
||||
|
||||
# Change ZoneAlarm rule to accept incoming ICMP ipv4 probes
|
||||
$Params = @{
|
||||
"Name" = 'vm-monitoring-icmpv4'
|
||||
"Action" = 'Allow'
|
||||
}
|
||||
|
||||
Set-NetFirewallRule @Params
|
||||
|
||||
# Add routes
|
||||
### Add routes
|
||||
|
||||
echo "Adding routes"
|
||||
route add -p 192.168.8.0/24 192.168.255.8
|
||||
route add -p 192.168.12.0/24 192.168.255.8
|
||||
route add -p 0.0.0.0/0 192.168.255.254
|
||||
|
@ -2,26 +2,35 @@
|
||||
# GPLv3
|
||||
|
||||
# Script to install and configure a Fuckdows Server 2016 as a router
|
||||
# RTR-01 Only
|
||||
# RTR-03 Only
|
||||
# Script done
|
||||
|
||||
# Change the poor machine name
|
||||
|
||||
echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
|
||||
|
||||
Rename-computer RTR-03
|
||||
### Change the poor machine name
|
||||
|
||||
echo "Renaming Computer"
|
||||
Rename-computer RTR-03
|
||||
#END
|
||||
|
||||
### Rename Adapters by parsing the VM device name
|
||||
|
||||
echo "Renaming Computer"
|
||||
$adapts = Get-NetAdapter
|
||||
foreach ($adapt in $adapts) {
|
||||
$HVName = (Get-NetAdapterAdvancedProperty -name $adapt.name -DisplayName "Hyper-v Network Adapter Name").DisplayValue
|
||||
Rename-Netadapter -name "$adapt.name" -NewName "$HVName"
|
||||
}
|
||||
#End
|
||||
|
||||
### Pausing to let things settle
|
||||
|
||||
echo "Sleeping 30s"
|
||||
Sleep 10
|
||||
|
||||
#Général IP configure
|
||||
### Général IP configure
|
||||
|
||||
echo "IP Configuration"
|
||||
$MaskBits = 24 # This means subnet mask = 255.255.255.0
|
||||
$IPType = "IPv4"
|
||||
|
||||
@ -40,41 +49,54 @@ $adapter | New-NetIPAddress `
|
||||
$IP = "192.168.255.254"
|
||||
$adapter | Set-NetIPInterface -Dhcp Enabled
|
||||
|
||||
#DNS Conf for all InterfaceAlias
|
||||
### DNS Conf for all InterfaceAlias
|
||||
|
||||
echo "DNS conf"
|
||||
foreach ($c in Get-NetAdapter) { write-host 'Setting DNS for' $c.interfaceName ; Set-DnsClientServerAddress -InterfaceIndex $c.interfaceindex -ServerAddresses ('9.9.9.9') }
|
||||
#End
|
||||
|
||||
### Install Routing and necessary linked roles
|
||||
|
||||
# Install Routing and necessary linked roles
|
||||
echo "Installing Routing and necessary linked roles"
|
||||
Install-WindowsFeature RemoteAccess, RSAT-RemoteAccess-PowerShell, Routing -IncludeManagementTools
|
||||
|
||||
#Install VPN
|
||||
echo "Install-remoteAccess -VpnType Vpn"
|
||||
### Install VPN (?)
|
||||
|
||||
echo "Install Vpn"
|
||||
Install-remoteAccess -VpnType Vpn
|
||||
Set-NetConnectionProfile -NetworkCategory Private
|
||||
#End
|
||||
|
||||
### Change ZoneAlarm rule to accept incoming ICMP ipv4 probes ###
|
||||
|
||||
echo "Allowing ICMPv4 probes"
|
||||
$Params = @{
|
||||
"Name" = 'vm-monitoring-icmpv4'
|
||||
"Action" = 'Allow'
|
||||
}
|
||||
|
||||
Set-NetFirewallRule @Params
|
||||
#END
|
||||
|
||||
|
||||
|
||||
|
||||
### Activating remote-access role
|
||||
|
||||
echo "Activating remote-access role"
|
||||
set-service RemoteAccess -StartupType Automatic
|
||||
Start-Service RemoteAccess
|
||||
#End
|
||||
|
||||
netsh -f ./WAN.conf
|
||||
#netsh -f ./WAN.conf
|
||||
|
||||
### Set connection as Private
|
||||
|
||||
echo "Setting connection as private"
|
||||
Set-NetConnectionProfile -networkcategory private
|
||||
|
||||
# Change ZoneAlarm rule to accept incoming ICMP ipv4 probes
|
||||
$Params = @{
|
||||
"Name" = 'vm-monitoring-icmpv4'
|
||||
"Action" = 'Allow'
|
||||
}
|
||||
|
||||
Set-NetFirewallRule @Params
|
||||
#End
|
||||
|
||||
# Add routes
|
||||
|
||||
echo "Adding routes"
|
||||
route add -p 192.168.8.0/24 192.168.255.8
|
||||
route add -p 192.168.12.0/24 192.168.255.8
|
||||
route add -p 192.168.128.0/24 192.168.255.128
|
||||
|
@ -5,20 +5,29 @@
|
||||
# TODO : exclusion/attribution fields
|
||||
# Rename interfaces
|
||||
#
|
||||
|
||||
echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
|
||||
|
||||
#Rename this piece of garbage
|
||||
### Rename this piece of garbage
|
||||
|
||||
echo "Changing Computer's name"
|
||||
Rename-computer "SRV-1"
|
||||
# End
|
||||
|
||||
# Rename interfaces
|
||||
### Rename interfaces by parsing VM device name
|
||||
|
||||
echo "Renaming adapters"
|
||||
$HVName = (Get-NetAdapterAdvancedProperty -name "Ethernet" -DisplayName "Hyper-v Network Adapter Name").DisplayValue
|
||||
Rename-Netadapter -name Ethernet -NewName $HVName
|
||||
#End
|
||||
|
||||
# Pausing to let things settle
|
||||
|
||||
echo "Sleeping 30s"
|
||||
Sleep 10
|
||||
|
||||
# Set IP for pre-defined MAC addresses
|
||||
### Général IP configure
|
||||
# echo "IP configuration"
|
||||
|
||||
#Arc-SRV
|
||||
|
||||
@ -34,27 +43,38 @@ $adapter | New-NetIPAddress `
|
||||
-PrefixLength $MaskBits `
|
||||
-DefaultGateway 192.168.8.255
|
||||
|
||||
# Set DNS
|
||||
### DNS Conf for all InterfaceAlias ###
|
||||
|
||||
echo "DNS Conf"
|
||||
foreach ($c in Get-NetAdapter) { write-host 'Setting DNS for' $c.interfaceName ; Set-DnsClientServerAddress -InterfaceIndex $c.interfaceindex -ServerAddresses ('9.9.9.9') }
|
||||
|
||||
# Install the DHCP role (Management tools if you love Metrosexual UI)
|
||||
### Install the DHCP role (Management tools if you love Metrosexual UI)
|
||||
|
||||
echo "Installing DHCP role"
|
||||
Install-WindowsFeature DHCP -IncludeManagementTools
|
||||
|
||||
# Show all the interface via iproute2 - LOL no via a shitty lookalike
|
||||
netsh inter ipv4 show inter
|
||||
#END
|
||||
|
||||
### Setting connection as Private
|
||||
|
||||
echo "Setting connection as Private"
|
||||
Set-NetConnectionProfile -NetworkCategory Private
|
||||
|
||||
# Behold the LoserShell "cmdlet" to attribute static IP
|
||||
#New-NetIPAddress -IPAddress 192.168.8.1 -InterfaceAlias "Arc-SRV" `
#-DefaultGateway 192.168. -AddressFamily IPv4 -PrefixLength 24
|
||||
#Set-DnsClientServerAddress -InterfaceAlias "Arc-SRV" -ServerAddresses 9.9.9.9
|
||||
|
||||
# Create DHCP "security" groups
|
||||
### Create DHCP "security" groups
|
||||
|
||||
echo "Creating DHCP security groups"
|
||||
netsh dhcp add securitygroups
|
||||
|
||||
# Restart the DHCP server
|
||||
#END
|
||||
|
||||
### Restart the DHCP server
|
||||
|
||||
echo "Restarting DHCP server"
|
||||
Restart-Service dhcpserver
|
||||
|
||||
# END
|
||||
|
||||
###################Template#######################
|
||||
#Add-DhcpServerv4Scope -name "Corpnet" -StartRange 10.0.0.1 -EndRange 10.0.0.254 -SubnetMask 255.255.255.0 -State Active
|
||||
#Add-DhcpServerv4ExclusionRange -ScopeID 10.0.0.0 -StartRange 10.0.0.1 -EndRange 10.0.0.15
|
||||
@ -62,8 +82,9 @@ Restart-Service dhcpserver
|
||||
#Set-DhcpServerv4OptionValue -DnsDomain corp.contoso.com -DnsServer 10.0.0.2
|
||||
##################################################
|
||||
|
||||
# Create DHCP Scopes For Arc-CLI Arc-SRV Bou-Lan
|
||||
# Change on options after because this sucker seems to dislike if it's done now
|
||||
### Create DHCP Scopes For Arc-CLI Arc-SRV Bou-Lan
|
||||
|
||||
echo "Create DHCP Scopes For Arc-CLI Arc-SRV Bou-Lan"
|
||||
|
||||
Add-DhcpServerv4Scope -name "Arc-SRV" -StartRange 192.168.8.1 -EndRange 192.168.8.254 -SubnetMask 255.255.255.0 -State Active
|
||||
Add-DhcpServerv4ExclusionRange -ScopeID 192.168.8.0 -StartRange 192.168.8.1 -EndRange 192.168.8.63
|
||||
@ -76,30 +97,36 @@ Add-DhcpServerv4ExclusionRange -ScopeID 192.168.12.0 -StartRange 192.168.12.240
|
||||
Add-DhcpServerv4Scope -name "Bou-LAN" -StartRange 192.168.128.1 -EndRange 192.168.128.254 -SubnetMask 255.255.255.0 -State Active
|
||||
Add-DhcpServerv4ExclusionRange -ScopeID 192.168.128.0 -StartRange 192.168.128.1 -EndRange 192.168.128.63
|
||||
Add-DhcpServerv4ExclusionRange -ScopeID 192.168.128.0 -StartRange 192.168.128.240 -EndRange 192.168.128.254
|
||||
#END
|
||||
|
||||
# Change ZoneAlarm rule to accept incoming ICMP ipv4 probes
|
||||
### Change ZoneAlarm rule to accept incoming ICMP ipv4 probes
|
||||
|
||||
echo "Allowing ICMPv4 probes"
|
||||
$Params = @{
|
||||
"Name" = 'vm-monitoring-icmpv4'
|
||||
"Action" = 'Allow'
|
||||
}
|
||||
|
||||
Set-NetFirewallRule @Params
|
||||
# END
|
||||
|
||||
# Add routes for RTR-01
|
||||
### Add routes for RTR-01
|
||||
|
||||
echo "Add routes for RTR-01"
|
||||
route add -p 192.168.12.0/24 192.168.8.254
|
||||
route add -p 192.168.255.0/24 192.168.8.254
|
||||
route add -p 192.168.128.0/24 192.168.8.254
|
||||
route add -p 0.0.0.0/0 192.168.8.254
|
||||
# END
|
||||
|
||||
# Change DHCP server options
|
||||
### Change DHCP server options
|
||||
|
||||
Set-DhcpServerv4OptionValue -ScopeId 192.168.128.0 -OptionID 3 -Value 192.168.128.254
|
||||
echo "Adding DHCP server options"
|
||||
Set-DhcpServerv4OptionValue -ScopeId 192.168.128.0 -Router 192.168.128.254
|
||||
Set-DhcpServerv4OptionValue -ScopeId 192.168.128.0 -DnsServer 9.9.9.9
|
||||
Set-DhcpServerv4OptionValue -ScopeId 192.168.12.0 -OptionID 3 -Value 192.168.12.254
|
||||
Set-DhcpServerv4OptionValue -ScopeId 192.168.12.0 -Router 192.168.12.254
|
||||
Set-DhcpServerv4OptionValue -ScopeId 192.168.12.0 -DnsServer 9.9.9.9
|
||||
Set-DhcpServerv4OptionValue -ScopeId 192.168.8.0 -OptionID 3 -Value 192.168.8.254
|
||||
Set-DhcpServerv4OptionValue -ScopeId 192.168.8.0 -Router 192.168.8.254
|
||||
Set-DhcpServerv4OptionValue -ScopeId 192.168.8.0 -DnsServer 9.9.9.9
|
||||
|
||||
Read-Host "Finished"
|
||||
Read-Host "Finished?"
|
||||
|
@ -1,16 +1,19 @@
|
||||
## Tool to automate VM creation
|
||||
echo "Shamefully made by Alexandre Simao. Such a waste of time.`
|
||||
Pardon-me dear M. Stallman"
|
||||
echo "CC BY-NC-SA 4.0"
|
||||
# TODO: SRV-01, RTR-02, RTR-03
|
||||
# Done: RTR-01 Full auto
|
||||
|
||||
# Region SRV-01
|
||||
echo "Shamefully made by Alexandre Simao. Pardon-me dear M. Stallman"
|
||||
echo "GPLv3"
|
||||
|
||||
### Considered as finished. Need improvement VM side.
|
||||
|
||||
### Adding SRV-01
|
||||
|
||||
echo "Adding and configuring SRV-01"
|
||||
cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\SRV-01.vhdx
|
||||
|
||||
Mount-VHD d:\VHD\SRV-01.vhdx
|
||||
Copy-Item d:\Unattend\SRV-01.xml -Destination e:\Windows\Panther\Unattend.xml
|
||||
mkdir c:\Scripts
|
||||
Copy-items d:\Scripts\Guests\SRV-01.ps1
|
||||
Dismount-VHD d:\VHD\SRV-01.vhdx
|
||||
|
||||
$vms = @{
|
||||
@ -26,16 +29,21 @@ $vms = @{
|
||||
New-VM @vms
|
||||
Set-VMMemory SRV-01 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
|
||||
Set-VM -Name SRV-01 -ProcessorCount 2
|
||||
|
||||
echo "Configuring adapters"
|
||||
Rename-VMNetworkAdapter -VMName 'SRV-01' -NewName 'Arc-SRV'
|
||||
Set-VMNetworkAdapter -VMName 'SRV-01' -Name "Arc-SRV" -DeviceNaming on
|
||||
|
||||
|
||||
# RTR-01
|
||||
### Adding and configuring RTR-01
|
||||
|
||||
echo "Adding and configuring RTR-01"
|
||||
cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\RTR-01.vhdx
|
||||
|
||||
Mount-VHD d:\VHD\RTR-01.vhdx
|
||||
Copy-Item d:\Unattend\RTR-01.xml -Destination e:\Windows\Panther\Unattend.xml
|
||||
mkdir c:\Scripts
|
||||
Copy-items d:\Scripts\Guests\RTR-01.ps1
|
||||
Dismount-VHD d:\VHD\RTR-01.vhdx
|
||||
|
||||
$vms = @{
|
||||
@ -51,6 +59,7 @@ New-VM @vms
|
||||
Set-VMMemory RTR-01 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
|
||||
Set-VM -Name RTR-01 -ProcessorCount 2
|
||||
|
||||
echo "Configuring adapters"
|
||||
#Set-VMNetworkAdapter -VMNetworkAdapter $vmadapter[0] -Name "Arc-SRV" -DeviceNaming on
|
||||
Rename-VMNetworkAdapter -VMName 'RTR-01' -NewName 'Arc-SRV'
|
||||
Set-VMNetworkAdapter -VMName 'RTR-01' -Name "Arc-SRV" -DeviceNaming on
|
||||
@ -60,10 +69,13 @@ Add-VMNetworkAdapter -VMName "RTR-01" -SwitchName "WAN" -Name "WAN" -DeviceNamin
|
||||
|
||||
# RTR-02
|
||||
|
||||
echo "Adding and configuring RTR-02"
|
||||
cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\RTR-02.vhdx
|
||||
|
||||
Mount-VHD d:\VHD\RTR-02.vhdx
|
||||
Copy-Item d:\Unattend\RTR-02.xml -Destination e:\Windows\Panther\Unattend.xml
|
||||
mkdir c:\Scripts
|
||||
Copy-items d:\Scripts\Guests\RTR-02.ps1
|
||||
Dismount-VHD d:\VHD\RTR-02.vhdx
|
||||
|
||||
$vms = @{
|
||||
@ -80,6 +92,7 @@ New-VM @vms
|
||||
Set-VMMemory RTR-02 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
|
||||
Set-VM -Name RTR-02 -ProcessorCount 2
|
||||
|
||||
echo "Configuring adapters"
|
||||
Rename-VMNetworkAdapter -VMName 'RTR-02' -NewName 'Bou-Lan'
|
||||
Set-VMNetworkAdapter -VMName 'RTR-02' -Name "Bou-LAN" -DeviceNaming on
|
||||
Add-VMNetworkAdapter -VMName "RTR-02" -SwitchName "WAN" -Name "WAN" -DeviceNaming on
|
||||
@ -88,11 +101,13 @@ Add-VMNetworkAdapter -VMName "RTR-02" -SwitchName "WAN" -Name "WAN" -DeviceNamin
|
||||
|
||||
# RTR-03
|
||||
|
||||
|
||||
echo "Adding and configuring RTR-03"
|
||||
cp D:\VHD\Base_dif\Base_server_g2.vhdx D:\VHD\RTR-03.vhdx
|
||||
|
||||
Mount-VHD d:\VHD\RTR-03.vhdx
|
||||
Copy-Item d:\Unattend\RTR-03.xml -Destination e:\Windows\Panther\Unattend.xml
|
||||
mkdir c:\Scripts
|
||||
Copy-items d:\Scripts\Guests\RTR-03.ps1
|
||||
Dismount-VHD d:\VHD\RTR-03.vhdx
|
||||
|
||||
$vms = @{
|
||||
@ -109,11 +124,12 @@ New-VM @vms
|
||||
Set-VMMemory RTR-03 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
|
||||
Set-VM -Name RTR-03 -ProcessorCount 2
|
||||
|
||||
echo "Configuring adapters"
|
||||
Rename-VMNetworkAdapter -VMName 'RTR-03' -NewName 'WAN'
|
||||
Set-VMNetworkAdapter -VMName 'RTR-03' -Name "WAN" -DeviceNaming on
|
||||
Add-VMNetworkAdapter -VMName "RTR-03" -SwitchName "Aston" -Name "Aston" -DeviceNaming on
|
||||
|
||||
|
||||
|
||||
### Starting VMS
|
||||
echo "Starting VMs"
|
||||
Start-VM -Name RTR*
|
||||
Start-VM -Name SRV*
|
||||
|
@ -1,7 +1,7 @@
|
||||
Stop-VM RTR* -turnoff
|
||||
Stop-VM SRV* -turnoff
|
||||
Remove-VM RTR*
|
||||
Remove-VM SRV*
|
||||
|
||||
del d:\VHD\RTR*
|
||||
del d:\VHD\SRV*
|
||||
Stop-VM RTR* -turnoff
|
||||
Stop-VM SRV* -turnoff
|
||||
Remove-VM RTR* -Force
|
||||
Remove-VM SRV* -Force
|
||||
|
||||
del d:\VHD\RTR*
|
||||
del d:\VHD\SRV*
|
||||
|
110
Memo.ps1
110
Memo.ps1
@ -1,55 +1,55 @@
|
||||
#$VMNetAdap = Get-VMNetworkAdapter -VMName RTR-01|ft -Property Switchname,Macaddress -HideTableHeaders
|
||||
Get-VMNetworkAdapter -VMName RTR-01|Format-Table -Property Switchname,Macaddress -HideTableHeaders |Export-Csv D:\scripts\Guests\MACS\test.csv -NoTypeInformation
|
||||
#echo $VMNETADAP | out-file -FilePath D:\scripts\Guests\MACS\temp.txt
|
||||
|
||||
#Arc-SRV
|
||||
$IP = "192.168.8.1"
|
||||
$MaskBits = 24 # This means subnet mask = 255.255.255.0
|
||||
$Gateway = "192.168.8.254"
|
||||
$Dns = "9.9.9.9"
|
||||
$IPType = "IPv4"
|
||||
|
||||
$adapter | New-NetIPAddress `
|
||||
-AddressFamily $IPType `
|
||||
-IPAddress $IP `
|
||||
-PrefixLength $MaskBits `
|
||||
-DefaultGateway $Gateway
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$IP = "10.10.10.10"
|
||||
$MaskBits = 24 # This means subnet mask = 255.255.255.0
|
||||
$Gateway = "10.10.10.1"
|
||||
$Dns = "10.10.10.100"
|
||||
$IPType = "IPv4"
|
||||
# Retrieve the network adapter that you want to configure
|
||||
$adapter = Get-NetAdapter | ? {$_.Status -eq "up"}
|
||||
# Remove any existing IP, gateway from our ipv4 adapter
|
||||
If (($adapter | Get-NetIPConfiguration).IPv4Address.IPAddress) {
|
||||
$adapter | Remove-NetIPAddress -AddressFamily $IPType -Confirm:$false
|
||||
}
|
||||
If (($adapter | Get-NetIPConfiguration).Ipv4DefaultGateway) {
|
||||
$adapter | Remove-NetRoute -AddressFamily $IPType -Confirm:$false
|
||||
}
|
||||
# Configure the IP address and default gateway
|
||||
$adapter | New-NetIPAddress `
|
||||
-AddressFamily $IPType `
|
||||
-IPAddress $IP `
|
||||
-PrefixLength $MaskBits `
|
||||
-DefaultGateway $Gateway
|
||||
# Configure the DNS client server IP addresses
|
||||
$adapter | Set-DnsClientServerAddress -ServerAddresses $DNS
|
||||
|
||||
|
||||
Get-VMNetworkAdapter -VMName "Virtual 2008 1" | Where-Object -Property MacAddress -eq "00155D647100" | Rename-VMNetworkAdapter -NewName "vNIC1"
|
||||
|
||||
Get-NetAdapter |Where-Object {$_.MacAddress -eq 'XX-XX-XX-XX'} | Select-Object`
|
||||
-Property Name | Format-Table -HideTableHeaders
|
||||
|
||||
$adapts = Get-NetAdapter
|
||||
foreach ($adapt in $adapts) {
|
||||
$HWName = (Get-NetAdapterAdvancedProperty -name $adapt.name -DisplayName "Hyper-v Network Adapter Name").DisplayValue
|
||||
Rename-Netadapter -name $adapt.name -NewName $HWName
|
||||
}
|
||||
#$VMNetAdap = Get-VMNetworkAdapter -VMName RTR-01|ft -Property Switchname,Macaddress -HideTableHeaders
|
||||
Get-VMNetworkAdapter -VMName RTR-01|Format-Table -Property Switchname,Macaddress -HideTableHeaders |Export-Csv D:\scripts\Guests\MACS\test.csv -NoTypeInformation
|
||||
#echo $VMNETADAP | out-file -FilePath D:\scripts\Guests\MACS\temp.txt
|
||||
|
||||
#Arc-SRV
|
||||
$IP = "192.168.8.1"
|
||||
$MaskBits = 24 # This means subnet mask = 255.255.255.0
|
||||
$Gateway = "192.168.8.254"
|
||||
$Dns = "9.9.9.9"
|
||||
$IPType = "IPv4"
|
||||
|
||||
$adapter | New-NetIPAddress `
|
||||
-AddressFamily $IPType `
|
||||
-IPAddress $IP `
|
||||
-PrefixLength $MaskBits `
|
||||
-DefaultGateway $Gateway
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$IP = "10.10.10.10"
|
||||
$MaskBits = 24 # This means subnet mask = 255.255.255.0
|
||||
$Gateway = "10.10.10.1"
|
||||
$Dns = "10.10.10.100"
|
||||
$IPType = "IPv4"
|
||||
# Retrieve the network adapter that you want to configure
|
||||
$adapter = Get-NetAdapter | ? {$_.Status -eq "up"}
|
||||
# Remove any existing IP, gateway from our ipv4 adapter
|
||||
If (($adapter | Get-NetIPConfiguration).IPv4Address.IPAddress) {
|
||||
$adapter | Remove-NetIPAddress -AddressFamily $IPType -Confirm:$false
|
||||
}
|
||||
If (($adapter | Get-NetIPConfiguration).Ipv4DefaultGateway) {
|
||||
$adapter | Remove-NetRoute -AddressFamily $IPType -Confirm:$false
|
||||
}
|
||||
# Configure the IP address and default gateway
|
||||
$adapter | New-NetIPAddress `
|
||||
-AddressFamily $IPType `
|
||||
-IPAddress $IP `
|
||||
-PrefixLength $MaskBits `
|
||||
-DefaultGateway $Gateway
|
||||
# Configure the DNS client server IP addresses
|
||||
$adapter | Set-DnsClientServerAddress -ServerAddresses $DNS
|
||||
|
||||
|
||||
Get-VMNetworkAdapter -VMName "Virtual 2008 1" | Where-Object -Property MacAddress -eq "00155D647100" | Rename-VMNetworkAdapter -NewName "vNIC1"
|
||||
|
||||
Get-NetAdapter |Where-Object {$_.MacAddress -eq 'XX-XX-XX-XX'} | Select-Object`
|
||||
-Property Name | Format-Table -HideTableHeaders
|
||||
|
||||
$adapts = Get-NetAdapter
|
||||
foreach ($adapt in $adapts) {
|
||||
$HWName = (Get-NetAdapterAdvancedProperty -name $adapt.name -DisplayName "Hyper-v Network Adapter Name").DisplayValue
|
||||
Rename-Netadapter -name $adapt.name -NewName $HWName
|
||||
}
|
||||
|
@ -1,64 +1,64 @@
|
||||
# Alexandre SIMAO
|
||||
# GPLv3
|
||||
|
||||
# Script to install and configure a Fuckdows Server 2016 as a router
|
||||
# RTR-02 Only
|
||||
|
||||
echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
|
||||
|
||||
# Change the poor machine name
|
||||
Rename-computer "RTR-02"
|
||||
|
||||
Rename-NetAdapter -Name "Ethernet" -NewName "Bou-LAN"
|
||||
Rename-NetAdapter -Name "Ethernet 2" -NewName "WAN"
|
||||
|
||||
netsh interface ip set address "WAN" static 192.168.255.8 255.255.255.0 192.168.255.254
|
||||
netsh interface ip set address "Bou-LAN" static 192.168.128.254 255.255.255.0
|
||||
netsh interface ip set dns name="WAN" static 9.9.9.9.
|
||||
|
||||
# Install Routing and necessary linked roles
|
||||
Install-WindowsFeature RemoteAccess, RSAT-RemoteAccess-PowerShell, Routing -IncludeManagementTools
|
||||
set-service RemoteAccess -StartupType Automatic
|
||||
Start-Service RemoteAccess
|
||||
|
||||
# Display interfaces and active forwarding for all of thm via Regedit
|
||||
netsh inter show inter
|
||||
|
||||
|
||||
Set-NetConnectionProfile -NetworkCategory Private
|
||||
|
||||
$Params = @{
|
||||
"Name" = 'vm-monitoring-icmpv4'
|
||||
"Action" = 'Allow'
|
||||
}
|
||||
|
||||
Set-NetFirewallRule @Params
|
||||
|
||||
# Activate NAT and DHCP Relay
|
||||
netsh routing ip relay install
|
||||
|
||||
netsh routing ip add interface name="WAN" state=enable
|
||||
|
||||
netsh routing ip relay add interface "WAN"
|
||||
netsh rout ip rel set int ARC-CLI min=0
|
||||
netsh routing ip relay add interface "Bou-LAN"
|
||||
netsh rout ip rel set int ARC-SRV min=0
|
||||
|
||||
|
||||
netsh -f ./Bou-LAN.conf
|
||||
|
||||
# Change ZoneAlarm rule to accept incoming ICMP ipv4 probes
|
||||
$Params = @{
|
||||
"Name" = 'vm-monitoring-icmpv4'
|
||||
"Action" = 'Allow'
|
||||
}
|
||||
|
||||
Set-NetFirewallRule @Params
|
||||
|
||||
# Add routes
|
||||
|
||||
route add -p 192.168.8.0/24 192.168.255.8
|
||||
route add -p 192.168.12.0.24 192.168.255.8
|
||||
route add -p 192.168.255.0/24 192.168.255.128
|
||||
route add -p 192.168.128.0/24 192.168.128.254
|
||||
route add -p 0.0.0.0/0 192.168.255.254
|
||||
# Alexandre SIMAO
|
||||
# GPLv3
|
||||
|
||||
# Script to install and configure a Fuckdows Server 2016 as a router
|
||||
# RTR-02 Only
|
||||
|
||||
echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
|
||||
|
||||
# Change the poor machine name
|
||||
Rename-computer "RTR-02"
|
||||
|
||||
Rename-NetAdapter -Name "Ethernet" -NewName "Bou-LAN"
|
||||
Rename-NetAdapter -Name "Ethernet 2" -NewName "WAN"
|
||||
|
||||
netsh interface ip set address "WAN" static 192.168.255.8 255.255.255.0 192.168.255.254
|
||||
netsh interface ip set address "Bou-LAN" static 192.168.128.254 255.255.255.0
|
||||
netsh interface ip set dns name="WAN" static 9.9.9.9.
|
||||
|
||||
# Install Routing and necessary linked roles
|
||||
Install-WindowsFeature RemoteAccess, RSAT-RemoteAccess-PowerShell, Routing -IncludeManagementTools
|
||||
set-service RemoteAccess -StartupType Automatic
|
||||
Start-Service RemoteAccess
|
||||
|
||||
# Display interfaces and active forwarding for all of thm via Regedit
|
||||
netsh inter show inter
|
||||
|
||||
|
||||
Set-NetConnectionProfile -NetworkCategory Private
|
||||
|
||||
$Params = @{
|
||||
"Name" = 'vm-monitoring-icmpv4'
|
||||
"Action" = 'Allow'
|
||||
}
|
||||
|
||||
Set-NetFirewallRule @Params
|
||||
|
||||
# Activate NAT and DHCP Relay
|
||||
netsh routing ip relay install
|
||||
|
||||
netsh routing ip add interface name="WAN" state=enable
|
||||
|
||||
netsh routing ip relay add interface "WAN"
|
||||
netsh rout ip rel set int ARC-CLI min=0
|
||||
netsh routing ip relay add interface "Bou-LAN"
|
||||
netsh rout ip rel set int ARC-SRV min=0
|
||||
|
||||
|
||||
netsh -f ./Bou-LAN.conf
|
||||
|
||||
# Change ZoneAlarm rule to accept incoming ICMP ipv4 probes
|
||||
$Params = @{
|
||||
"Name" = 'vm-monitoring-icmpv4'
|
||||
"Action" = 'Allow'
|
||||
}
|
||||
|
||||
Set-NetFirewallRule @Params
|
||||
|
||||
# Add routes
|
||||
|
||||
route add -p 192.168.8.0/24 192.168.255.8
|
||||
route add -p 192.168.12.0.24 192.168.255.8
|
||||
route add -p 192.168.255.0/24 192.168.255.128
|
||||
route add -p 192.168.128.0/24 192.168.128.254
|
||||
route add -p 0.0.0.0/0 192.168.255.254
|
||||
|
@ -1,47 +1,47 @@
|
||||
# Alexandre SIMAO
|
||||
# GPLv3
|
||||
|
||||
### TODO ?
|
||||
|
||||
# Script to install and configure a Fuckdows Server 2016 as a router
|
||||
# RTR-03 Only
|
||||
echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
|
||||
|
||||
# Change the poor machine name
|
||||
Rename-computer "RTR-03"
|
||||
|
||||
Rename-NetAdapter -Name "Ethernet" -NewName "WAN"
|
||||
Rename-NetAdapter -Name "Ethernet 2" -NewName "Aston"
|
||||
|
||||
# Install Routing and necessary linked roles
|
||||
Install-WindowsFeature RemoteAccess, RSAT-RemoteAccess-PowerShell, Routing -IncludeManagementTools
|
||||
set-service RemoteAccess -StartupType Automatic
|
||||
Start-Service RemoteAccess
|
||||
|
||||
netsh interface ip set address "WAN" static 192.168.255.254 255.255.255.0
|
||||
netsh interface ip set dns name="WAN" static 9.9.9.9
|
||||
|
||||
# Activate NAT
|
||||
|
||||
netsh routing ip nat install
|
||||
netsh routing ip nat add interface name="WAN" mode=PRIVATE
|
||||
netsh routing ip nat add interface name="Aston" mode=FULL
|
||||
|
||||
# Change ZoneAlarm rule to accept incoming ICMP ipv4 probes
|
||||
|
||||
$Params = @{
|
||||
"Name" = 'vm-monitoring-icmpv4'
|
||||
"Action" = 'Allow'
|
||||
}
|
||||
|
||||
Set-NetFirewallRule @Params
|
||||
|
||||
Set-NetConnectionProfile -networkcategory private
|
||||
|
||||
|
||||
# Add routes
|
||||
|
||||
route add -p 192.168.8.0/24 192.168.255.8
|
||||
route add -p 192.168.12.0/24 192.168.255.8
|
||||
route add -p 192.168.128.0/24 192.168.255.128
|
||||
route add -p 192.168.255.0/24 192.168.255.254
|
||||
# Alexandre SIMAO
|
||||
# GPLv3
|
||||
|
||||
### TODO ?
|
||||
|
||||
# Script to install and configure a Fuckdows Server 2016 as a router
|
||||
# RTR-03 Only
|
||||
echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
|
||||
|
||||
# Change the poor machine name
|
||||
Rename-computer "RTR-03"
|
||||
|
||||
Rename-NetAdapter -Name "Ethernet" -NewName "WAN"
|
||||
Rename-NetAdapter -Name "Ethernet 2" -NewName "Aston"
|
||||
|
||||
# Install Routing and necessary linked roles
|
||||
Install-WindowsFeature RemoteAccess, RSAT-RemoteAccess-PowerShell, Routing -IncludeManagementTools
|
||||
set-service RemoteAccess -StartupType Automatic
|
||||
Start-Service RemoteAccess
|
||||
|
||||
netsh interface ip set address "WAN" static 192.168.255.254 255.255.255.0
|
||||
netsh interface ip set dns name="WAN" static 9.9.9.9
|
||||
|
||||
# Activate NAT
|
||||
|
||||
netsh routing ip nat install
|
||||
netsh routing ip nat add interface name="WAN" mode=PRIVATE
|
||||
netsh routing ip nat add interface name="Aston" mode=FULL
|
||||
|
||||
# Change ZoneAlarm rule to accept incoming ICMP ipv4 probes
|
||||
|
||||
$Params = @{
|
||||
"Name" = 'vm-monitoring-icmpv4'
|
||||
"Action" = 'Allow'
|
||||
}
|
||||
|
||||
Set-NetFirewallRule @Params
|
||||
|
||||
Set-NetConnectionProfile -networkcategory private
|
||||
|
||||
|
||||
# Add routes
|
||||
|
||||
route add -p 192.168.8.0/24 192.168.255.8
|
||||
route add -p 192.168.12.0/24 192.168.255.8
|
||||
route add -p 192.168.128.0/24 192.168.255.128
|
||||
route add -p 192.168.255.0/24 192.168.255.254
|
||||
|
Loading…
Reference in New Issue
Block a user