Gestión de Redes desde la Línea de Comandos - PowerShell
PowerShell y las utilidades clásicas de Windows permiten inspeccionar y gestionar ajustes de red y habilitar acceso remoto. 💻✨
🧩 Diagnóstico básico de red
-
ipconfig/ipconfig /all— mostrar IPs, gateways, DNS, DHCP. 🧾🌐 -
arp -a— ver caché ARP (IP → MAC). 🔍🖧 -
nslookup <host>— resolver nombres DNS. 🧭🔗 -
netstat -an— conexiones y puertos escuchando. 🔌📡
Ejemplo rápido:
ipconfig /all
arp -a
nslookup ACADEMY-ICL-DC
netstat -an
⚡ Cmdlets modernos de PowerShell (NetTCPIP / NetAdapter)
-
Get-NetIPInterface— listar interfaces y métricas. 🖥️📊 -
Get-NetIPAddress -InterfaceIndex <n>— ver IPs de una interfaz. 🌍 -
Set-NetIPInterface -InterfaceIndex <n> -Dhcp Disabled— desactivar DHCP. 🚫🏷️ -
Set-NetIPAddress -InterfaceIndex <n> -IPAddress 10.10.100.54 -PrefixLength 24— asignar IP estática. 📝🖧 -
Restart-NetAdapter -Name 'Ethernet 3'— reiniciar adaptador. 🔄⚡ -
Test-NetConnection -ComputerName <host>— ping/TCP/traceroute. ✅💡
Ejemplo práctico:
# Desactivar DHCP
Set-NetIPInterface -InterfaceIndex 25 -Dhcp Disabled 🚫🏷️
# Asignar IP manual
Set-NetIPAddress -InterfaceIndex 25 -IPAddress 10.10.100.54 -PrefixLength 24 📝🖧
# Reiniciar adaptador
Restart-NetAdapter -Name 'Ethernet 3' 🔄
# Probar conexión
Test-NetConnection -ComputerName 8.8.8.8 ✅
🔐 Acceso remoto (SSH y WinRM)
🟢 Habilitar OpenSSH
# Instalar cliente y servidor SSH
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 🖥️🔑
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 🖥️🔑
# Iniciar servicio SSH y ponerlo automático
Start-Service sshd 🚀
Set-Service -Name sshd -StartupType Automatic 🕹️
- Conexión:
ssh usuario@ip→ luegopowershellsi quieres sesión de PowerShell. ⚡💻
🟢 Habilitar WinRM
# Configuración rápida de remoting
winrm quickconfig 🌐🔧
Enable-PSRemoting -Force ⚡
- Probar conexión:
Test-WSMan -ComputerName <IP> 🔍
Test-WSMan -ComputerName <IP> -Authentication Negotiate ✅
- Sesión interactiva:
Enter-PSSession -ComputerName <IP> -Credential <user> -Authentication Negotiate 💻🔑
⚠️ Seguridad: usar HTTPS, TrustedHosts limitados y Kerberos en dominio. 🛡️🔒