Skip to content

Instantly share code, notes, and snippets.

@allexiusw
Last active March 1, 2020 03:28
Show Gist options
  • Save allexiusw/657197dcb9c836e8cc989b5ebae75143 to your computer and use it in GitHub Desktop.
Save allexiusw/657197dcb9c836e8cc989b5ebae75143 to your computer and use it in GitHub Desktop.
Install and configure DNS with Powershell. Working with zones and subdomains.
Install-WindowsFeature DNS -IncludeManagementTools
Get-Service -Name dns
Get-DnsClientServerAddress
Set-DnsClientServerAddress -InterfaceAlias "Ethernet0" -ServerAddresses 127.0.0.1,8.8.8.8
Set-DnsClientServerAddress -InterfaceAlias "Ethernet1" -ServerAddresses 127.0.0.1,8.8.8.8
Get-DnsClientServerAddress
$dominio = Read-Host "Ingresar el nombre del dominio"
Add-DnsServerPrimaryZone -Name "$dominio" -ZoneFile "db.$dominio"
$ip = Read-Host "Ingrese la IP del servidor"
Get-DnsServerResourceRecord -ZoneName "$dominio"
Add-DnsServerResourceRecord -ZoneName "$dominio" -A -Name "ventas" -AllowUpdateAny -IPv4Address "$ip" -TimeToLive 01:00:00 -AgeRecord
Add-DnsServerResourceRecord -ZoneName "$dominio" -A -Name "compras" -AllowUpdateAny -IPv4Address "$ip" -TimeToLive 01:00:00 -AgeRecord
Add-DnsServerResourceRecord -ZoneName "$dominio" -A -Name "@" -AllowUpdateAny -IPv4Address "$ip" -TimeToLive 01:00:00 -AgeRecord
mkdir C:\siteventasallex
echo "<h1>Sitio Ventas Allex</h1>" > C:\siteventasallex\index.html
New-IISSite -Name 'Site ventas allex' -PhysicalPath 'C:\siteventasallex\' -BindingInformation "*:80:ventas.allexiusw.com"
Get-IISSite
mkdir C:\sitecomprasallex
echo "<h1>Sitio Compras Allex</h1>" > C:\sitecomprasallex\index.html
New-IISSite -Name 'Site compras allex' -PhysicalPath 'C:\sitecomprasallex\' -BindingInformation "*:80:compras.allexiusw.com"
Get-IISSite
Write-Host "Emitir el comando ping ventas.allexiusw.com y ping compras.allexiusw.com, luego configurar el dns de la maquina cliente y acceder utilizando el navedor y los dominios para acceder a los sitios"
Write-Host "Nuestro sitio principal estara en allexiusw.com"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment