[Debate] Consultas sobre el "firewall" del SP2 de XP.

05/04/2004 - 19:20 por JM Tella Llop [MVP Windows] | Informe spam
Tal y como comenté ayer, estaré por qeuí una hora o dos, y por tanto, las consultas que tengais sobre dicho cortafuegos, irlas exponiendo colgando de este mismo hilo. No se responderá a ningun mensaje que no sea del tema del cortafuegos. No se responderá tampoco a los mensajes del TROLL de turno.

Vuelvo a pegar debajo el articulo de ayer. La dinamica normal es que voy a poner un articulo semanal -de diversas indoles-, normalmente los Domingos, y al dia siguiente, duranto un par de horas, responder a las consultas.


CONFIGURACION DEL FIREWALL DE XP - SP2. MEDIANTE COMANDOS DE LINEA.
-

Independientemente de la configuración mediante el interface grafico que hemos visto en el articulo anterior, existen en XP - SP2, la posibilidad de configurarlo mediante comandos de linea. Esto añade potencia a ciertas opciones de configuracion -como por ejemplo añadir un rango de puertos, lo cual es pesado de hacer con el interface grafico- y sobre todo, es la herramienta imprescindible de los Administradores de red que necesitan cambiar remotamente opciones.

Recordemos, que el firewall del SP2, no solo controla entradas en nuestra maquina sino que además, controla en las salidas:

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

2) Permite definir que puertos están autorizados. Esto añade además el definir su alcance: si es para todas las IP's, si esa regla es solo para la subred local, o incluso definir manualmente el ambito (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 configuracion global para todas las interfaces y modificarse a nivel de interface en particular.

4) Control total y correcto del trafico multicast. (los actuales firewall de terceros solo actuan en trafico unicast, y se las ven y se las desean para multicast -protocolos de radiodifusion o de streaming de video).


TIP - SCRIPT de LINEA DE COMANDO PARA ABRIR / CERRAR UN RANGO DE PUERTOS


Podeis crearos un bat (o cmd), con las siguientes lineas:


@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 parametro. Es decir, TCP, UDP o ALL. Por defecto, si no le indicamos el segundo parametro, será ALL.

Igualmente el comando anterior, permite un tercer parámetro: DISABLE. Si indicamos ese tercer parametro, cerrará los puertos previamente abiertos.

Evidentemente las modificaciones se verán reflejadas inmediatamente en la interface grafica. Elñ comando anterior, lo he preparado para que cree las entradas P5000 P5001... P5100 en la interface grafica con esos nombres.


COMANDO DE LINEA NETSH
-

La implementacion del manejo del firewall mediante comando comando de linea, lo ha realizado Microsoft a traves del comandos NETSH. Dicho comando ya exitiá en el XP y XP SP1 normales, y permite la modificacion de parametros de la red, reinstalacion del stadck tcp, guardar una configuracion del tcp y poder restaurarla, etc. Es decir era un comando generico de control de red y sus interfaces. La implementacion del SP2 lo que hace es posibilitarle tambien la configuracion del firewall.

Si ejecutamos netsh en una ventan de comandos (cmd.exe), veremos un prompt:

netsh>

tecleando una interrogacion, 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 sy
ntax.

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


El resto de parámetro podeis comprobarlos y vereis que permiten la configuracion completa del firewall, inclusive mediante más opciones de las que da la propia interface grafica.




Jose Manuel Tella Llop
MVP - Windows
jmtella@compuserve.com
http://www.multingles.net/jmt.htm

Este mensaje se proporciona "como está" sin garantías de ninguna clase, y no otorga ningún derecho.

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.

Preguntas similare

Leer las respuestas

#21 Tomás
05/04/2004 - 21:07 | Informe spam
Detallo un pelin mas. Ambos equipos con su propia conexion a internet, por
ahora, via modem. Simplemente conectados para compartir datos.

Saludos


"JM Tella Llop [MVP Windows]" escribió en el mensaje
news:
Es que no tiene que hacer nada.. :-)
Puede modificar luego lo que quiera, pero ya vereis la confiuracion por
defecto. Ademas, se activa en TODAS las interface de red nada mas
instalarlo. Y en instalaciones integradas, lo mismo. Y si añadimos una
interface de red nueva, automaticamente la protegerá el firewall.

Y consumo de CPU cero.

Jose Manuel Tella Llop
MVP - Windows

http://www.multingles.net/jmt.htm

Este mensaje se proporciona "como está" sin garantías de ninguna clase, y no
otorga ningún derecho.

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.




"Tomás" wrote in message
news:
:-)

Ya Jose, pero te pregunto los motivos para un usuario doméstico. Y no me
refiero a que sea mas facil configurarlo en temas digamos ilegales, sino


en
configurarlo aceptablemente de una manera sencilla, entorno gráfico,
digamos, si conjuga seguridad, utilización pequeña de recursos,
sencillez.


Saludos



"JM Tella Llop [MVP Windows]" escribió en el mensaje
news:
Prefiero el del SP2.
Y sabes que yo soy, y he sido vicioso del Sygate, siendo ese el *unico*


que
aconsejaba.

Jose Manuel Tella Llop
MVP - Windows

http://www.multingles.net/jmt.htm

Este mensaje se proporciona "como está" sin garantías de ninguna clase, y


no
otorga ningún derecho.

This posting is provided "AS IS" with no warranties, and confers no


rights.
You assume all risk for your use.




"Tomás" wrote in message
news:
Hola Jose Manuel


En comparación con el Sygate por ejemplo, que ventajas o limitaciones


posee?

EL sygate está considerando de lo mejorcito, pero quizás sea un poco
complicado para usuarios caseros. Ofrece funcionalidades parecidas (o
mejores) y es mas sencillo de manejar?

Saludos y un placer verte por aquí de nuevo

Tomás



"JM Tella Llop [MVP Windows]" escribió en el mensaje
news:%
Tal y como comenté ayer, estaré por qeuí una hora o dos, y por tanto, las
consultas que tengais sobre dicho cortafuegos, irlas exponiendo colgando


de
este mismo hilo. No se responderá a ningun mensaje que no sea del tema




del
cortafuegos. No se responderá tampoco a los mensajes del TROLL de turno.

Vuelvo a pegar debajo el articulo de ayer. La dinamica normal es que voy




a
poner un articulo semanal -de diversas indoles-, normalmente los




Domingos,
y
al dia siguiente, duranto un par de horas, responder a las consultas.

-




-
CONFIGURACION DEL FIREWALL DE XP - SP2. MEDIANTE COMANDOS DE LINEA.
-

Independientemente de la configuración mediante el interface grafico que
hemos visto en el articulo anterior, existen en XP - SP2, la posibilidad


de
configurarlo mediante comandos de linea. Esto añade potencia a ciertas
opciones de configuracion -como por ejemplo añadir un rango de puertos,




lo
cual es pesado de hacer con el interface grafico- y sobre todo, es la
herramienta imprescindible de los Administradores de red que necesitan
cambiar remotamente opciones.

Recordemos, que el firewall del SP2, no solo controla entradas en nuestra
maquina sino que además, controla en las salidas:

1) Que programas están autorizados (solicita permiso para cualquier


programa
que intenta por primera vez abrir un servicio en "LISTENING").

2) Permite definir que puertos están autorizados. Esto añade además el
definir su alcance: si es para todas las IP's, si esa regla es solo para


la
subred local, o incluso definir manualmente el ambito (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
configuracion global para todas las interfaces y modificarse a nivel de
interface en particular.

4) Control total y correcto del trafico multicast. (los actuales firewall


de
terceros solo actuan en trafico unicast, y se las ven y se las desean




para
multicast -protocolos de radiodifusion o de streaming de video).


TIP - SCRIPT de LINEA DE COMANDO PARA ABRIR / CERRAR UN RANGO DE PUERTOS


Podeis crearos un bat (o cmd), con las siguientes lineas:


@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 parametro. Es decir, TCP, UDP o ALL. Por defecto, si no le


indicamos
el segundo parametro, será ALL.

Igualmente el comando anterior, permite un tercer parámetro: DISABLE. Si
indicamos ese tercer parametro, cerrará los puertos previamente abiertos.

Evidentemente las modificaciones se verán reflejadas inmediatamente en la
interface grafica. Elñ comando anterior, lo he preparado para que cree




las
entradas P5000 P5001... P5100 en la interface grafica con esos nombres.


COMANDO DE LINEA NETSH
-

La implementacion del manejo del firewall mediante comando comando de


linea,
lo ha realizado Microsoft a traves del comandos NETSH. Dicho comando ya
exitiá en el XP y XP SP1 normales, y permite la modificacion de




parametros
de la red, reinstalacion del stadck tcp, guardar una configuracion del




tcp
y
poder restaurarla, etc. Es decir era un comando generico de control de




red
y
sus interfaces. La implementacion del SP2 lo que hace es posibilitarle
tambien la configuracion del firewall.

Si ejecutamos netsh en una ventan de comandos (cmd.exe), veremos un


prompt:

netsh>

tecleando una interrogacion, 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 sy
ntax.

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


El resto de parámetro podeis comprobarlos y vereis que permiten la
configuracion completa del firewall, inclusive mediante más opciones de


las
que da la propia interface grafica.




Jose Manuel Tella Llop
MVP - Windows

http://www.multingles.net/jmt.htm

Este mensaje se proporciona "como está" sin garantías de ninguna clase, y


no
otorga ningún derecho.

This posting is provided "AS IS" with no warranties, and confers no


rights.
You assume all risk for your use.









Respuesta Responder a este mensaje
#22 Verhexen
05/04/2004 - 21:07 | Informe spam
pues ya tardas en enviarlas...

Verhexen.
XP Pro SP 2 v.2082


"JM Tella Llop [MVP Windows]" wrote in message news:
Primero por lo ultimo: el modo GUI es sencillismo e intuitivo. Tengo un articulo con capturas de pantalla, que en cuanto me las reduzca una "bruxa" que aparece por aquí :-), lo publicaré. Más facil e intuitivo no podian haberlo realizado.
Respuesta Responder a este mensaje
#23 JM Tella Llop [MVP Windows]
05/04/2004 - 21:08 | Informe spam
lo dejo para estas fiestas, para tenerte ocupada. :-)

Jose Manuel Tella Llop
MVP - Windows

http://www.multingles.net/jmt.htm

Este mensaje se proporciona "como está" sin garantías de ninguna clase, y no otorga ningún derecho.

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.




"Verhexen" wrote in message news:c4sak5$2ll49m$
pues ya tardas en enviarlas...

Verhexen.
XP Pro SP 2 v.2082


"JM Tella Llop [MVP Windows]" wrote in message news:
Primero por lo ultimo: el modo GUI es sencillismo e intuitivo. Tengo un articulo con capturas de pantalla, que en cuanto me las reduzca una "bruxa" que aparece por aquí :-), lo publicaré. Más facil e intuitivo no podian haberlo realizado.
Respuesta Responder a este mensaje
#24 JM Tella Llop [MVP Windows]
05/04/2004 - 21:09 | Informe spam
Efectivamente. Se configura solito :-)
Y reconoce la subred local.

Jose Manuel Tella Llop
MVP - Windows

http://www.multingles.net/jmt.htm

Este mensaje se proporciona "como está" sin garantías de ninguna clase, y no otorga ningún derecho.

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.




"Tomás" wrote in message news:
Ah, eso me recuerda, en conexiones de red domésticas se configura solo?
Ahora mismo lo tengo desactivado, porque (creo que es él) impide la conexion
entre los equipos

Saludos




"JM Tella Llop [MVP Windows]" escribió en el mensaje
news:
Es que no tiene que hacer nada.. :-)
Puede modificar luego lo que quiera, pero ya vereis la confiuracion por
defecto. Ademas, se activa en TODAS las interface de red nada mas
instalarlo. Y en instalaciones integradas, lo mismo. Y si añadimos una
interface de red nueva, automaticamente la protegerá el firewall.

Y consumo de CPU cero.

Jose Manuel Tella Llop
MVP - Windows

http://www.multingles.net/jmt.htm

Este mensaje se proporciona "como está" sin garantías de ninguna clase, y no
otorga ningún derecho.

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.




"Tomás" wrote in message
news:
:-)

Ya Jose, pero te pregunto los motivos para un usuario doméstico. Y no me
refiero a que sea mas facil configurarlo en temas digamos ilegales, sino


en
configurarlo aceptablemente de una manera sencilla, entorno gráfico,
digamos, si conjuga seguridad, utilización pequeña de recursos,
sencillez.


Saludos



"JM Tella Llop [MVP Windows]" escribió en el mensaje
news:
Prefiero el del SP2.
Y sabes que yo soy, y he sido vicioso del Sygate, siendo ese el *unico*


que
aconsejaba.

Jose Manuel Tella Llop
MVP - Windows

http://www.multingles.net/jmt.htm

Este mensaje se proporciona "como está" sin garantías de ninguna clase, y


no
otorga ningún derecho.

This posting is provided "AS IS" with no warranties, and confers no


rights.
You assume all risk for your use.




"Tomás" wrote in message
news:
Hola Jose Manuel


En comparación con el Sygate por ejemplo, que ventajas o limitaciones


posee?

EL sygate está considerando de lo mejorcito, pero quizás sea un poco
complicado para usuarios caseros. Ofrece funcionalidades parecidas (o
mejores) y es mas sencillo de manejar?

Saludos y un placer verte por aquí de nuevo

Tomás



"JM Tella Llop [MVP Windows]" escribió en el mensaje
news:%
Tal y como comenté ayer, estaré por qeuí una hora o dos, y por tanto, las
consultas que tengais sobre dicho cortafuegos, irlas exponiendo colgando


de
este mismo hilo. No se responderá a ningun mensaje que no sea del tema




del
cortafuegos. No se responderá tampoco a los mensajes del TROLL de turno.

Vuelvo a pegar debajo el articulo de ayer. La dinamica normal es que voy




a
poner un articulo semanal -de diversas indoles-, normalmente los




Domingos,
y
al dia siguiente, duranto un par de horas, responder a las consultas.

-




-
CONFIGURACION DEL FIREWALL DE XP - SP2. MEDIANTE COMANDOS DE LINEA.
-

Independientemente de la configuración mediante el interface grafico que
hemos visto en el articulo anterior, existen en XP - SP2, la posibilidad


de
configurarlo mediante comandos de linea. Esto añade potencia a ciertas
opciones de configuracion -como por ejemplo añadir un rango de puertos,




lo
cual es pesado de hacer con el interface grafico- y sobre todo, es la
herramienta imprescindible de los Administradores de red que necesitan
cambiar remotamente opciones.

Recordemos, que el firewall del SP2, no solo controla entradas en nuestra
maquina sino que además, controla en las salidas:

1) Que programas están autorizados (solicita permiso para cualquier


programa
que intenta por primera vez abrir un servicio en "LISTENING").

2) Permite definir que puertos están autorizados. Esto añade además el
definir su alcance: si es para todas las IP's, si esa regla es solo para


la
subred local, o incluso definir manualmente el ambito (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
configuracion global para todas las interfaces y modificarse a nivel de
interface en particular.

4) Control total y correcto del trafico multicast. (los actuales firewall


de
terceros solo actuan en trafico unicast, y se las ven y se las desean




para
multicast -protocolos de radiodifusion o de streaming de video).


TIP - SCRIPT de LINEA DE COMANDO PARA ABRIR / CERRAR UN RANGO DE PUERTOS


Podeis crearos un bat (o cmd), con las siguientes lineas:


@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 parametro. Es decir, TCP, UDP o ALL. Por defecto, si no le


indicamos
el segundo parametro, será ALL.

Igualmente el comando anterior, permite un tercer parámetro: DISABLE. Si
indicamos ese tercer parametro, cerrará los puertos previamente abiertos.

Evidentemente las modificaciones se verán reflejadas inmediatamente en la
interface grafica. Elñ comando anterior, lo he preparado para que cree




las
entradas P5000 P5001... P5100 en la interface grafica con esos nombres.


COMANDO DE LINEA NETSH
-

La implementacion del manejo del firewall mediante comando comando de


linea,
lo ha realizado Microsoft a traves del comandos NETSH. Dicho comando ya
exitiá en el XP y XP SP1 normales, y permite la modificacion de




parametros
de la red, reinstalacion del stadck tcp, guardar una configuracion del




tcp
y
poder restaurarla, etc. Es decir era un comando generico de control de




red
y
sus interfaces. La implementacion del SP2 lo que hace es posibilitarle
tambien la configuracion del firewall.

Si ejecutamos netsh en una ventan de comandos (cmd.exe), veremos un


prompt:

netsh>

tecleando una interrogacion, 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 sy
ntax.

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


El resto de parámetro podeis comprobarlos y vereis que permiten la
configuracion completa del firewall, inclusive mediante más opciones de


las
que da la propia interface grafica.




Jose Manuel Tella Llop
MVP - Windows

http://www.multingles.net/jmt.htm

Este mensaje se proporciona "como está" sin garantías de ninguna clase, y


no
otorga ningún derecho.

This posting is provided "AS IS" with no warranties, and confers no


rights.
You assume all risk for your use.













Respuesta Responder a este mensaje
#25 JM Tella Llop [MVP Windows]
05/04/2004 - 21:10 | Informe spam
Ahora ya no me entero. Describe la arquitectura.

Jose Manuel Tella Llop
MVP - Windows

http://www.multingles.net/jmt.htm

Este mensaje se proporciona "como está" sin garantías de ninguna clase, y no otorga ningún derecho.

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.




"Tomás" wrote in message news:
Detallo un pelin mas. Ambos equipos con su propia conexion a internet, por
ahora, via modem. Simplemente conectados para compartir datos.

Saludos


"JM Tella Llop [MVP Windows]" escribió en el mensaje
news:
Es que no tiene que hacer nada.. :-)
Puede modificar luego lo que quiera, pero ya vereis la confiuracion por
defecto. Ademas, se activa en TODAS las interface de red nada mas
instalarlo. Y en instalaciones integradas, lo mismo. Y si añadimos una
interface de red nueva, automaticamente la protegerá el firewall.

Y consumo de CPU cero.

Jose Manuel Tella Llop
MVP - Windows

http://www.multingles.net/jmt.htm

Este mensaje se proporciona "como está" sin garantías de ninguna clase, y no
otorga ningún derecho.

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.




"Tomás" wrote in message
news:
:-)

Ya Jose, pero te pregunto los motivos para un usuario doméstico. Y no me
refiero a que sea mas facil configurarlo en temas digamos ilegales, sino


en
configurarlo aceptablemente de una manera sencilla, entorno gráfico,
digamos, si conjuga seguridad, utilización pequeña de recursos,
sencillez.


Saludos



"JM Tella Llop [MVP Windows]" escribió en el mensaje
news:
Prefiero el del SP2.
Y sabes que yo soy, y he sido vicioso del Sygate, siendo ese el *unico*


que
aconsejaba.

Jose Manuel Tella Llop
MVP - Windows

http://www.multingles.net/jmt.htm

Este mensaje se proporciona "como está" sin garantías de ninguna clase, y


no
otorga ningún derecho.

This posting is provided "AS IS" with no warranties, and confers no


rights.
You assume all risk for your use.




"Tomás" wrote in message
news:
Hola Jose Manuel


En comparación con el Sygate por ejemplo, que ventajas o limitaciones


posee?

EL sygate está considerando de lo mejorcito, pero quizás sea un poco
complicado para usuarios caseros. Ofrece funcionalidades parecidas (o
mejores) y es mas sencillo de manejar?

Saludos y un placer verte por aquí de nuevo

Tomás



"JM Tella Llop [MVP Windows]" escribió en el mensaje
news:%
Tal y como comenté ayer, estaré por qeuí una hora o dos, y por tanto, las
consultas que tengais sobre dicho cortafuegos, irlas exponiendo colgando


de
este mismo hilo. No se responderá a ningun mensaje que no sea del tema




del
cortafuegos. No se responderá tampoco a los mensajes del TROLL de turno.

Vuelvo a pegar debajo el articulo de ayer. La dinamica normal es que voy




a
poner un articulo semanal -de diversas indoles-, normalmente los




Domingos,
y
al dia siguiente, duranto un par de horas, responder a las consultas.

-




-
CONFIGURACION DEL FIREWALL DE XP - SP2. MEDIANTE COMANDOS DE LINEA.
-

Independientemente de la configuración mediante el interface grafico que
hemos visto en el articulo anterior, existen en XP - SP2, la posibilidad


de
configurarlo mediante comandos de linea. Esto añade potencia a ciertas
opciones de configuracion -como por ejemplo añadir un rango de puertos,




lo
cual es pesado de hacer con el interface grafico- y sobre todo, es la
herramienta imprescindible de los Administradores de red que necesitan
cambiar remotamente opciones.

Recordemos, que el firewall del SP2, no solo controla entradas en nuestra
maquina sino que además, controla en las salidas:

1) Que programas están autorizados (solicita permiso para cualquier


programa
que intenta por primera vez abrir un servicio en "LISTENING").

2) Permite definir que puertos están autorizados. Esto añade además el
definir su alcance: si es para todas las IP's, si esa regla es solo para


la
subred local, o incluso definir manualmente el ambito (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
configuracion global para todas las interfaces y modificarse a nivel de
interface en particular.

4) Control total y correcto del trafico multicast. (los actuales firewall


de
terceros solo actuan en trafico unicast, y se las ven y se las desean




para
multicast -protocolos de radiodifusion o de streaming de video).


TIP - SCRIPT de LINEA DE COMANDO PARA ABRIR / CERRAR UN RANGO DE PUERTOS


Podeis crearos un bat (o cmd), con las siguientes lineas:


@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 parametro. Es decir, TCP, UDP o ALL. Por defecto, si no le


indicamos
el segundo parametro, será ALL.

Igualmente el comando anterior, permite un tercer parámetro: DISABLE. Si
indicamos ese tercer parametro, cerrará los puertos previamente abiertos.

Evidentemente las modificaciones se verán reflejadas inmediatamente en la
interface grafica. Elñ comando anterior, lo he preparado para que cree




las
entradas P5000 P5001... P5100 en la interface grafica con esos nombres.


COMANDO DE LINEA NETSH
-

La implementacion del manejo del firewall mediante comando comando de


linea,
lo ha realizado Microsoft a traves del comandos NETSH. Dicho comando ya
exitiá en el XP y XP SP1 normales, y permite la modificacion de




parametros
de la red, reinstalacion del stadck tcp, guardar una configuracion del




tcp
y
poder restaurarla, etc. Es decir era un comando generico de control de




red
y
sus interfaces. La implementacion del SP2 lo que hace es posibilitarle
tambien la configuracion del firewall.

Si ejecutamos netsh en una ventan de comandos (cmd.exe), veremos un


prompt:

netsh>

tecleando una interrogacion, 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 sy
ntax.

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


El resto de parámetro podeis comprobarlos y vereis que permiten la
configuracion completa del firewall, inclusive mediante más opciones de


las
que da la propia interface grafica.




Jose Manuel Tella Llop
MVP - Windows

http://www.multingles.net/jmt.htm

Este mensaje se proporciona "como está" sin garantías de ninguna clase, y


no
otorga ningún derecho.

This posting is provided "AS IS" with no warranties, and confers no


rights.
You assume all risk for your use.













Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaSiguiente AnteriorRespuesta Tengo una respuesta
Search Busqueda sugerida