53 lines
1.5 KiB
PowerShell
53 lines
1.5 KiB
PowerShell
$name = Read-host "Nouveau nom d'hôte?"
|
|
Rename-computer $name
|
|
Install-WindowsFeature Routing
|
|
netsh inter show inter
|
|
Set-ItemProperty -path 'HKLM:\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet`
|
|
\Services\Tcpip\Parameters' -Name 'IPEnableRouter' -Value '0x00000001'
|
|
Set-NetConnectionProfile -NetworkCategory Private
|
|
|
|
# IP address or DnsHostName of your Dhcp Server
|
|
$dhcpServer = '192.168.8.1'
|
|
|
|
# Name of the network adapter to enable DHCP on
|
|
$Inter1 = Read-Host "First interface name"
|
|
$Inter2 = Read-Host "Second interface name"
|
|
|
|
$routerNetAdapterName1 = '$Inter1'
|
|
$routerNetAdapterName1 = '$Inter2'
|
|
|
|
|
|
$dhcpAddress = [Net.Dns]::GetHostEntry($dhcpServer)
|
|
if(!$dhcpAddress){
|
|
Write-Warning "Unable to identify IP address of [$dhcpServer]"
|
|
break
|
|
}else{
|
|
$dhcpServerIP = $dhcpAddress.AddressList[0]
|
|
}
|
|
|
|
$netshDhcpRelay=@"
|
|
pushd routing ip relay
|
|
install
|
|
set global loglevel=ERROR
|
|
add dhcpserver $($dhcpServerIP.IPAddressToString)
|
|
add interface name="$routerNetAdapterName1"
|
|
set interface name="$routerNetAdapterName1" relaymode=enable maxhop=6 minsecs=6
|
|
add interface name="$routerNetAdapterName2"
|
|
set interface name="$routerNetAdapterName2" relaymode=enable maxhop=6 minsecs=6
|
|
popd
|
|
"@
|
|
|
|
$netshDhcpRelayPath="$ENV:TEMP\netshDhcpRelay"
|
|
|
|
# Create netsh script file
|
|
New-Item -Path $netshDhcpRelayPath `
|
|
-Type File `
|
|
-ErrorAction SilentlyContinue | Out-Null
|
|
|
|
# Populate contents of the script
|
|
Set-Content -Path $netshDhcpRelayPath `
|
|
-Value $netshDhcpRelay.Split("`r`n") `
|
|
-Encoding ASCII
|
|
|
|
# run it
|
|
netsh -f $netshDhcpRelayPath |