InicioInfoConfifiguracion del firewall win xp sp2 - Comandos en linea

Confifiguracion del firewall win xp sp2 - Comandos en linea

Info4/26/2009
Independientemente de la configuración mediante el interface gráfico, existe en XP - SP2 la posibilidad de configurarlo mediante comandos de línea. Esto añade potencia a ciertas opciones de configuración -como por ejemplo añadir un rango de puertos, lo cual es pesado de hacer con el interface gráfico- y sobre todo, es la herramienta imprescindible de los Administradores de red que necesitan cambiar remotamente opciones.
Recordemos, que el firewall del SP2, no sólo controla entradas en nuestra máquina sino que además, controla en las salidas:

1) Qué programas están autorizados (solicita permiso para cualquier programa que intenta por primera vez abrir un servicio en "LISTENING".

2) Permite definir qué puertos están autorizados. Esto añade además el definir su alcance: si es para todas las IP's, si esa regla es sólo para la subred local, o incluso definir manualmente el ámbito (SCOPE), por ejemplo: 157.0.0.1,172.0.0.0/8,10.0.0.0/255.0.0.0, LocalSubnet.

3) Control independiente por cada interface de red. Puede establecerse una configuración global para todas las interfaces y modificarse a nivel de interface en particular.

4) Control total y correcto del tráfico multicast. (los actuales firewall de terceros sólo actúan en tráfico unicast, y se las ven y se las desean para multicast -protocolos de radiodifusión o de streaming de vídeo).

LINEA DE COMANDO PARA ABRIR / CERRAR UN RANGO DE PUERTOS


Podéis crearos un bat (o cmd), con las siguientes líneas:
@echo off
setlocal enabledelayedexpansion
set protocol=%2
if "%protocol%." == "." set protocol=ALL
for /f "tokens=1,2 delims=-" %%i in ("%1" do set /a var1=%%i&set /a var2=%%j
for /l %%i in (%var1%,1,%var2%) do netsh firewall set portopening %protocol% %%i P%%i %3 >nul
endlocal
goto :EOF
Imaginemos que le llamamos tcpopen.bat. Esto, admite la sintaxis:
tcpopen 5000-5100 [TCP | UDP | ALL]
lo anterior, abrirá los puertos del 5000 al 5100 en lo indicado en el segundo parámetro. Es decir, TCP, UDP o ALL. Por defecto, si no le indicamos el segundo parámetro, será ALL.
Igualmente, el comando anterior permite un tercer parámetro: DISABLE. Si indicamos ese tercer parámetro, cerrará los puertos previamente abiertos.
Evidentemente las modificaciones se verán reflejadas inmediatamente en la interface gráfica. El comando anterior, lo he preparado para que cree las entradas P5000 P5001... P5100 en la interface gráfica con esos nombres.

COMANDO DE LINEA NETSH


La implementación del manejo del firewall mediante comando de línea, lo ha realizado Microsoft a través del comandos NETSH. Dicho comando ya existía en el XP y XP SP1 normales, y permite la modificación de parámetros de la red, reinstalación del stadck tcp, guardar una configuración del TCP y poder restaurarla, etc. Es decir era un comando genérico de control de red y sus interfaces. La implementación del SP2 lo que hace es posibilitarle también la configuración del firewall.
Si ejecutamos netsh en una ventan de comandos (cmd.exe), veremos un prompt:
netsh>
tecleando una interrogación, nos muestra los comandos posibles:
The following commands are available:
Commands in this context:
.. - Goes up one context level.
? - Displays a list of commands.
abort - Discards changes made while in offline mode.
add - Adds a configuration entry to a list of entries.
alias - Adds an alias.
bridge - Changes to the `netsh bridge' context.
bye - Exits the program.
commit - Commits changes made while in offline mode.
delete - Deletes a configuration entry from a list of entries.
diag - Changes to the `netsh diag' context.
dump - Displays a configuration script.
exec - Runs a script file.
exit - Exits the program.
firewall - Changes to the `netsh firewall' context.
help - Displays a list of commands.
interface - Changes to the `netsh interface' context.
offline - Sets the current mode to offline.
online - Sets the current mode to online.
p2p - Changes to the `netsh p2p' context.
popd - Pops a context from the stack.
pushd - Pushes current context on stack.
quit - Exits the program.
ras - Changes to the `netsh ras' context.
routing - Changes to the `netsh routing' context.
set - Updates configuration settings.
show - Displays information.
unalias - Deletes an alias.
winsock - Changes to the `netsh winsock' context.
The following sub-contexts are available:
bridge diag firewall interface p2p ras routing winsock
To view help for a command, type the command, followed by a space, and then type ?.
En particular, el comando firewall. Si tecleamos firewall, nos mostrará:
netsh firewall>
y con una ?:
Commands in this context:
? - Displays a list of commands.
add - Adds firewall configuration.
delete - Deletes firewall configuration.
dump - Displays a configuration script.
help - Displays a list of commands.
reset - Resets firewall configuration to default.
set - Sets firewall configuration.
show - Shows firewall configuration.
To view help for a command, type the command, followed by a space, and then type ?.
Es especialmente potente el comando ADD:
netsh firewall>add portopening
The syntax supplied for this command is not valid. Check help for the correct syntax.
add portopening
[ protocol = ] TCP|UDP|ALL
[ port = ] 1-65535
[ name = ] name
[ [ mode = ] ENABLE|DISABLE
[ scope = ] ALL|SUBNET|CUSTOM
[ addresses = ] addresses
[ profile = ] CURRENT|DOMAIN|STANDARD|ALL
[ interface = ] name ]
Adds firewall port configuration.
Parameters:
protocol - Port protocol.
TCP - Transmission Control Protocol (TCP).
UDP - User Datagram Protocol (UDP).
ALL - All protocols.
port - Port number.
name - Port name.
mode - Port mode (optional).
ENABLE - Allow through firewall (default).
DISABLE - Do not allow through firewall.
scope - Port scope (optional).
ALL - Allow all traffic through firewall (default).
SUBNET - Allow only local network (subnet) traffic through firewall.
CUSTOM - Allow only specified traffic through firewall.
addresses - Custom scope addresses (optional).
profile - Configuration profile (optional).
CURRENT - Current profile (default).
DOMAIN - Domain profile.
STANDARD - Standard profile.
ALL - All profiles.
interface - Interface name (optional).
Remarks: 'profile' and 'interface' may not be specified together.
'scope' and 'interface' may not be specified together.
'scope' must be 'CUSTOM' to specify 'addresses'.
Examples:
add portopening TCP 80 MyWebPort
add portopening UDP 500 IKE ENABLE ALL
add portopening ALL 53 DNS ENABLE CUSTOM
157.0.0.1,172.0.0.0/8,10.0.0.0/255.0.0.0,LocalSubnet
add portopening protocol = TCP port = 80 name = MyWebPort
add portopening protocol = UDP port = 500 name = IKE mode = ENABLE scope = ALL
add portopening protocol = ALL port = 53 name = DNS mode = ENABLE
scope = CUSTOM
addresses = 157.0.0.1,172.0.0.0/8,10.0.0.0/255.0.0.0,LocalSubnet

Podéis comprobar el resto de parámetros y veréis que permiten la configuración completa del firewall, inclusive mediante más opciones de las que da la propia interface gráfica

Academias Cisco
Datos archivados del Taringa! original
15puntos
1,378visitas
0comentarios
Actividad nueva en Posteamelo
0puntos
2visitas
0comentarios
Dar puntos:

Dejá tu comentario

0/2000

Autor del Post

0
0rdnael🇦🇷
Usuario
Puntos0
Posts2
Ver perfil →
PosteameloArchivo Histórico de Taringa! (2004-2017). Preservando la inteligencia colectiva de la internet hispanohablante.

CONTACTO

18 de Septiembre 455, Casilla 52

Chillán, Región de Ñuble, Chile

Solo correo postal

© 2026 Posteamelo.com. No afiliado con Taringa! ni sus sucesores.

Contenido preservado con fines históricos y culturales.