48 votes
Accepted

How to remove access to a port using firewall on Centos7?

Solution: Do not forget the --runtime-to-permanent $ firewall-cmd --zone=public --remove-port=10050/tcp $ firewall-cmd --runtime-to-permanent $ firewall-cmd --reload
mcv's user avatar
  • 955
45 votes
Accepted

What happens if two local systems download the same resource on same port?

A TCP connection (which underlies HTTP and many other protocols) is uniquely (at a given point in time) defined by 4 parameters: The local IP The local port The remote IP The remote port Even if you ...
jcaron's user avatar
  • 1,095
41 votes
Accepted

SElinux error :ValueError: Port tcp/5000 already defined

So I found that another service had a defined status for TCP port 5000. But by replacing the -a option with -m for modify, added tcp port 5000 to http_port_t So the command that worked was: # ...
panickedprocrastinator's user avatar
37 votes

How to check if a port is blocked on a Windows machine?

Since PowerShell 4.0 you can use the command Test-NetConnection If you want to test Port 3306 as in your example the command is Test-NetConnection -ComputerName localhost -Port 3306 TechNet Test-...
Marcel Janus's user avatar
  • 1,135
33 votes

How to check if a port is blocked on a Windows machine?

NETSTAT will tell you if the port is listening but it will not tell you if the port is open to the outside world. What I mean by this is that NETSTAT may show that the 0.0.0.0 is LISTENING on port ...
Tim Penner's user avatar
  • 1,929
30 votes

Is it a good idea to open up a database port for everyone?

Do not make your database publicly accessible. One bug in the database or weak passwords and someone deletes / steals / changes everything. Your mobile app shouldn't access the database directly, it ...
Tim's user avatar
  • 32.7k
29 votes

Prevent port change on redirect in nginx

In my case, nginx listens to port 80 inside a docker container, but it's mapped to port 8080 (or any random port) outside the container. There is no reverse proxy in-between that can add proper ...
Luxian's user avatar
  • 431
29 votes
Accepted

Preventing other applications from binding to port 80 and 443

You can't prevent a port from being bound by the wrong service. In your case, just remove apache from autostart and you should be good. For 16.04 and newer: sudo systemctl disable apache2 For older ...
Gerald Schneider's user avatar
27 votes

Preventing other applications from binding to port 80 and 443

If you really aren't using apache2, and it's PHP 7.0 that's requiring it, then it looks like you have libapache2-mod-php7.0 installed. That package is useless without Apache. Since you're using nginx, ...
muru's user avatar
  • 601
24 votes

Check if port is open or closed on a Linux server?

I use the combo of netstat and lsof: netstat -an | grep <portnumber> lsof -i:<portnumber> To see if the port is being used, and what is using it.
warren's user avatar
  • 18.7k
23 votes

When specifying a "host name", do we still need to specify a port?

Host names do not correspond to an {ipaddress,port} tuple. A host name is only the name of a server, which should be resolvable to one or more IP addresses. Ports have nothing to do with host names at ...
Jenny D's user avatar
  • 28.1k
19 votes

netstat shows a listening port with no pid but lsof does not

Based on hint from @user202173 and others I have been able to use the following to track down the process that owns a port even when it is listed as - in netstat. Here was my starting situation. sudo ...
studgeek's user avatar
  • 323
15 votes

What is the maximum port number in Linux?

Although 1-65535 are legit TCP ports and it is true that 1-1023 are for well known port services. You may run into random issues with your own services if they are started after an ephemeral port is ...
Stephen Mathews's user avatar
15 votes

Multiport Server NIC ports?

These devices are typically seen in the OS as four separate network devices and they can be used just like the four separate NICs you had before.
Sven's user avatar
  • 99.5k
15 votes
Accepted

SSH: What's the difference between -L and -R?

It's right there, in the man page: -L Specifies that connections to the given TCP port or Unix socket on the local (client) host are to be forwarded to the given host and port, or Unix socket, on the ...
Gerald Schneider's user avatar
14 votes

How do you free up a port being held open by dead process?

Open command prompt as admin C:\WINDOWS\system32>netstat -ano | findstr :7895 *** Repeat step 2 until there are no more child process C:\WINDOWS\system32>wmic process where (ParentProcessId=1091 ...
Srinivas's user avatar
  • 141
14 votes
Accepted

Setting sub domain DNS to route default port 80 to custom port

For general HTTP purposes (web browsing, etc.), DNS cannot be used to direct a browser to use a specific port. Browsers are hard-codes to assume 80 for HTTP and 443 for HTTPS. You "could" host ...
Greg W's user avatar
  • 776
14 votes
Accepted

How do I specify a port other than 80 when adding SSL certificate using Certbot?

There is no way to specify a different port than defaults (80/443). I recommend you to use the acme-dns validation. I use it and it works fine. More details here : https://www.digitalocean.com/...
Thomas Coche's user avatar
13 votes

How to remove access to a port using firewall on Centos7?

# firewall-cmd --zone=public --remove-port=12345/tcp --permanent # firewall-cmd --reload Replace 12345 with the port you want to remove.
Zing Lee's user avatar
  • 231
12 votes
Accepted

Non standard ssh port: should I edit /etc/services?

I don't think it makes sense to edit /etc/services in such a case. The world will not change ssh ports with you, and all programs that look up service names to port numbers on your machine would get ...
Håkan Lindqvist's user avatar
11 votes

SElinux error :ValueError: Port tcp/5000 already defined

On the systems I have to hand (C6, C7 and F24), tcp port 5000 has an SELinux context of commplex_port_t. This will be why, when you try to add it you get the error message /usr/sbin/semanage: Port ...
user9517's user avatar
  • 116k
11 votes

What happens if two local systems download the same resource on same port?

The NAT table knows that the source port on each client is different, so it won't accidentally send the wrong packet to the wrong internal client. The NAT device also assigns different outbound ports, ...
mfinni's user avatar
  • 36.2k
11 votes

Is it a good idea to open up a database port for everyone?

Is it a good idea to open up a database port for everyone? ... this feels like it's not a good practice. No it isn't. Access control and security are of course big issues there. From an application ...
HBruijn's user avatar
  • 80.3k
10 votes
Accepted

How can I set the source port for an SSH command-line client?

You have to use nc as ProxyCommand. SSH only supports to specify the bind address of the SSH client. ssh -o 'ProxyCommand nc -p 2345 %h %p' $MY_SERVER Something like this should work.
Florin Asăvoaie's user avatar
10 votes
Accepted

Make wireguard listen on multiple port

Something like this should do the trick iptables -t nat -I PREROUTING -i eth0 -d <yourIP/32> -p udp -m multiport --dports 53,80,4444 -j REDIRECT --to-ports 15351
user9517's user avatar
  • 116k
9 votes

Check if port is open or closed on a Linux server?

If you need to script such a test, the solution by Serhii Popov (see comment to question) is probably the best since nc is capable of searching the TCP stack for an open port³ instead of attempting an ...
Alexis Wilke's user avatar
  • 2,278
9 votes

Non standard ssh port: should I edit /etc/services?

The file /etc/services contains the IANA assigned port numbers and there is not a single technical requirement to modify that file to be able to you run your services on a non-standard port. When you ...
HBruijn's user avatar
  • 80.3k
9 votes

When specifying a "host name", do we still need to specify a port?

A "virtual host" is simply a feature of a piece of software which takes advantage of extra context in a request to act differently. An important thing to note is that TCP/IP itself does not know ...
IMSoP's user avatar
  • 500
8 votes

Why do netcat scans for UDP ports always succeed?

UDP is a "connectionless" protocol. If you send a packet and you don't get a rejection (via ICMP), regardless of whether you get a reply or not, it's considered successful. Something quite ...
84104's user avatar
  • 13k
8 votes
Accepted

Bind Set Port for Forwarders

You need to use port keyword. forwarders { 127.0.0.1 port 2053; };
holypapa's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible