How to open TCP ports in Windows 10


Last Updated on 3 de Abril, 2020 by Vítor Fernandes

In computer networks, a port is a communication endpoint. At the software level, within an operating system, a port is a logical construction that identifies a specific process or type of network service. The most common protocols that use port numbers are the Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP).

wikipedia

You don’t want to repeat the same ports, right?! So first open your firewall settings and see if you have any ports there before execute the below code. If you see any there, remove them!

Opening the Windows Firewall Defender panel

wf.msc

Open port 80 (HTTP)

This will open port 80 with the name HTTP 80 (incoming and outgoing communication)

netsh advfirewall firewall add rule name="HTTP 80" dir=in action=allow protocol=TCP localport=80
netsh advfirewall firewall add rule name="HTTP 80" dir=out action=allow protocol=TCP localport=80

Open port 443 (HTTPS)

This will open port 443 with the name HTTPS 443 (incoming and outgoing communication)

netsh advfirewall firewall add rule name="HTTPS 443" dir=in action=allow protocol=TCP localport=443
netsh advfirewall firewall add rule name="HTTPS 443" dir=out action=allow protocol=TCP localport=443

Open port 25 (SMTP)

This will open port 25 with the name SMTP 25 (incoming and outgoing communication)

netsh advfirewall firewall add rule name="SMTP 25" dir=in action=allow protocol=TCP localport=25
netsh advfirewall firewall add rule name="SMTP 25" dir=out action=allow protocol=TCP localport=25

Open port 110 (POP3)

This will open port 110 with the name POP3 110 (incoming and outgoing communication)

netsh advfirewall firewall add rule name="POP3 110" dir=in action=allow protocol=TCP localport=110
netsh advfirewall firewall add rule name="POP3 110" dir=out action=allow protocol=TCP localport=110

Open port 143 (POP3S)

This will open port 143 with the name IMAP 143 (incoming and outgoing communication)

netsh advfirewall firewall add rule name="IMAP 143" dir=in action=allow protocol=TCP localport=143
netsh advfirewall firewall add rule name="IMAP 143" dir=out action=allow protocol=TCP localport=143

Open port 465 (SMTPS)

This will open port 465 with the name SMTPS 465 (incoming and outgoing communication)

netsh advfirewall firewall add rule name="SMTPS 465" dir=in action=allow protocol=TCP localport=465
netsh advfirewall firewall add rule name="SMTPS 465" dir=out action=allow protocol=TCP localport=465

Open port 587 (SUBMISSION)

This will open port 587 with the name SUB 587 (incoming and outgoing communication)

netsh advfirewall firewall add rule name="SUB 587" dir=in action=allow protocol=TCP localport=587
netsh advfirewall firewall add rule name="SUB 587" dir=out action=allow protocol=TCP localport=587

Open port 993 (IMAP 993)

This will open port 993 with the name IMAP 993 (incoming and outgoing communication)

netsh advfirewall firewall add rule name="IMAP 993" dir=in action=allow protocol=TCP localport=993
netsh advfirewall firewall add rule name="IMAP 993" dir=out action=allow protocol=TCP localport=993

Open port 995 (POP3S)

This will open port 995 with the name POP3S (incoming and outgoing communication)

netsh advfirewall firewall add rule name="POP3S 995" dir=in action=allow protocol=TCP localport=995
netsh advfirewall firewall add rule name="POP3S 995" dir=out action=allow protocol=TCP localport=995

Don’t want to copy and past line after line. Just create a Script with the below code!

Open a text file, paste the below code and save the file to eg: FIREWALL.bat

@echo off

::Autor: Vítor Fernandes
::Página web: https://duploclique.pt
::Data: 27-OUT-2020

title ABRE PORTAS SMTP, SMTPS, IMAP E POP3 ^| duploclique.pt

mode 70,3
chcp 850 > nul
color F

> nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"

if '%errorlevel%' NEQ '0' (
    goto AbrirUAC
) else ( goto AbrirBatch )

:AbrirUAC
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B

:AbrirBatch
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%cd%"
cd /d "%~dp0"

set PATH=%~dp0;%PATH%

echo A DEFINIR PORTA SMTP 25...
timeout 1 /nobreak > nul
netsh advfirewall firewall add rule name="SMTP" dir=in action=allow protocol=TCP localport=25
netsh advfirewall firewall add rule name="SMTP" dir=out action=allow protocol=TCP localport=25
cls
echo A DEFINIR PORTA SMTP 25... OK^!
timeout 2 /nobreak > nul
cls
echo A DEFINIR PORTA SMTP 587...
timeout 1 /nobreak > nul
netsh advfirewall firewall add rule name="Submission" dir=in action=allow protocol=TCP localport=587
netsh advfirewall firewall add rule name="Submission" dir=out action=allow protocol=TCP localport=587
cls
echo A DEFINIR PORTA SMTP 587... OK^!
timeout 1 /nobreak > nul
cls
echo A DEFINIR PORTA SMTPS 465...
timeout 1 /nobreak > nul
netsh advfirewall firewall add rule name="SMTPS" dir=in action=allow protocol=TCP localport=465
netsh advfirewall firewall add rule name="SMTPS" dir=out action=allow protocol=TCP localport=465
cls
echo A DEFINIR PORTA SMTPS 465... OK^!
timeout 1 /nobreak > nul
cls
echo A DEFINIR PORTA IMAP 993...
timeout 1 /nobreak > nul
netsh advfirewall firewall add rule name="IMAP" dir=in action=allow protocol=TCP localport=993
netsh advfirewall firewall add rule name="IMAP" dir=out action=allow protocol=TCP localport=993
cls
echo A DEFINIR PORTA IMAP 993... OK^!
timeout 1 /nobreak > nul
cls
echo A DEFINIR PORTA POP3S 995...
timeout 1 /nobreak > nul
netsh advfirewall firewall add rule name="POP3S" dir=in action=allow protocol=TCP localport=995
netsh advfirewall firewall add rule name="POP3S" dir=out action=allow protocol=TCP localport=995
cls
echo A DEFINIR PORTA POP3S 995... OK^!
timeout 1 /nobreak > nul
cls
echo PROCESSO FINALIZADO... A FECHAR JANELA^!
timeout 1 /nobreak > nul & exit /b 0

Deixe uma resposta

O seu endereço de email não será publicado. Campos obrigatórios marcados com *