开发者

What does changing your URI port number do?

开发者 https://www.devze.com 2023-03-12 19:05 出处:网络
I don\'t really understand the differences between the different ports. I couldn\'t find any useful resources online that would go into detail 开发者_Go百科about it. From what I can understand, it act

I don't really understand the differences between the different ports. I couldn't find any useful resources online that would go into detail 开发者_Go百科about it. From what I can understand, it acts as some kind of filter that blocks out any other request not using the same port number.

When will I, if ever, need to change the port number when typing in a website in my browser? What about if I am running my own website? Are there any risks I take when using port 80? As in, are there ways to use different port numbers to hack into a website?

And since a Simple Mail Transfer Protocol uses port 25, could I use this knowledge to send emails using self written programs?


By conventions and standards, defined protocols generally listen on defined ports by default. You can set any service to listen on any port you want, just be aware that changing from a standard port means that standard tools would need to be explicitly told to use your non-standard port.

For example, if you run a web server then by default it's probably listening on port 80. So all someone needs to do to visit your server is use the address:

http://www.yourserver.com

However, if you change it to listen on a non-standard port, such as 81, then any user who wants to visit your site will need to specify the port number:

http://www.yourserver.com:81

The standard convention of just using the address wouldn't be sufficient, because you've broken convention. Now, this is fine if you don't want people randomly using your site and only want it to be available to people to whom you've told the port number. This is called "security through obscurity." It doesn't actually secure your site in any way or filter out anything, it just adds an additional step to the use of the site.

As for SMTP, yes, you can write programs to connect to port 25 on SMTP services and send data to those services. You may indeed be able to spoof emails in this manner. However, most services have other built-in checks and balances to prevent such spoofing.


TCP/IP supports 2^16 ports on a machine. A server program is said to listen on a specific port; other machines contact a server program at a machine using the port number and the name of the machine. It's like the address on a letter.

Some port numbers are "well known", which just means they're officially assigned for a particular service: port 80 is for web servers, port 25 for SMTP, port 25 for telnet, etc.

But any server can run on any port; it's just a matter of changing the code or the configuration. Sometimes you may way to run two separate web servers on one machine; one might listen on port 80, and the second one on some other port (8080 is a common choice for servers used during development.)

So the client can't meaningfully change the port to some random number: there has to be something listening on that port, on that machine, or it doesn't do anything.


There is no 'difference' between running a web server on any port number, from a purely technical perspective, as long as the client and the server both know which port to use. When the client connects to the server, it has to know the IP address as well as the port.

By convention, several ports are used by standard services. For example, port 25 is SMTP, port 80 is the http port, 22 is the ssh port, etc. Because of these conventions, ports less than 1024 are reserved by the operating systems and can only be opened by a root process.

Unless there is a specfiic reason, it is generally a good idea to stick with the standard port numbers. Advanced port scanners/ analysis tools will try all ports on a system, so there isn't much benefit to running a service on a non-standard port.


The port numbers are a way of multiplexing communications over IP links. This is commonly used to provide specific services on accepted port numbers. HTTP servers have been allocated port 80 for listening for incoming client connections, though this is not a lock - there is nothing stopping you constructing/configuring an HTTP server that listens on port 9001, or whatever. If you did use a non-standard port number for your server, then you would have to specifically instruct a browser to connect to that port, rather than defaulting to 80 as it normally does.

SMTP in port 25 using your own program - sure, you can do this. Any mail app is some developers' 'own program' .

Rgds, Martin

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号