What is port number in linux

Linux for freshers

A port number is part of the addressing information used to identify the senders and receivers of messages. Port numbers are most commonly used with TCP/IP connections. Home network routers and computer software work with ports and sometimes allow you to configure port number settings. These port numbers allow different applications on the same computer to share network resources simultaneously.

Q. What is the range of ports or how many ports are there?
Port numbers can vary from 0 to 65535, so total we can get 65536 ports

Q. Why port numbers are just 65536?
This is because limitation in TCP/IP stack where the port field is just 16bit size. So we get only 2^16 port which is equal to 65536 ports

Port numbers have a range of 0..65535 (although often 0 has special meaning). In the original BSD TCP implementation, only root can bind to ports 1..1023, and dynamically assigned ports were assigned from the range 1024..5000; the others were available for unprivileged static assignment. These days 1024..5000 is often not enough dynamic ports, and IANA has now officially designated the range 49152..65535 for dynamic port assignment. However even that is not enough dynamic ports for some busy servers, so the range is usually configurable (by an administrator). On modern Linux and Solaris systems (often used as servers), the default dynamic range now starts at 32768. Mac OS X and Windows Vista default to 49152..65535.

[root@desktop12 ~]# cat /proc/sys/net/ipv4/ip_local_port_range 32768 61000 solaris$ /usr/sbin/ndd /dev/tcp tcp_smallest_anon_port tcp_largest_anon_port 32768 65535 macosx$ sysctl net.inet.ip.portrange.first net.inet.ip.portrange.last net.inet.ip.portrange.first: 49152 net.inet.ip.portrange.last: 65535 vista> netsh int ipv4 show dynamicport tcp Protocol tcp Dynamic Port Range Start Port : 49152 Number of Ports : 16384

Q.What are the well-known ports?
Well known ports are from 0 to 1023(total 2^10=1024 ports)

Used by specific service upon applications such as Oracle database listener (1521), MySql (3306), Microsoft Terminal server (3389) etc.

These ports can’t be registered by IANA. This is used for custom or temporary purposes and for automatic allocation of short-lived (or ephemeral ) ports which is used internally by application/processes. You can see these ports by running ‘netstat’ command under “Local address” column.

Q.What do you mean by default port?

Default port is a designated port for particular well-known server.

Q.Can we change default port for a service(example Apache, squid)?
Yes, we can change

Читайте также:  Linux посмотреть установленные службы

Q.What are the protocol numbers for TCP and UDP?
TCP protocol number:6
UDP protocol number:17

Q.How to find which ports are open?
You can find the ports in your linux server with the nmap command

#netstat -ntlp
here n -> display the host by numbers
t ->shows tcp protocols
u ->to check udp protocols
l ->listening ports
p -> displays which process controls the port
Q.How to find printer open ports ?

[root@desktop13 Desktop]# netstat -ntlp |grep cups
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1525/cupsd
tcp 0 0 ::1:631 . * LISTEN 1525/cupsd

Q. How to detect remote server openports?
[root@desktop13 Desktop]# nmap -sT 192.168.0.250
it will show like this
PORT STATE SERVICE
21/tcp open ftp
22/tcp open ssh
25/tcp open smtp
80/tcp open http
Q. How to change SSH port number?

[root@desktop13 Desktop]# netstat -ntlp | grep ssh
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1646/sshd
tcp 0 0 . 22 . * LISTEN 1646/sshd

[root@desktop13 Desktop]# netstat -ntlp | grep ssh
tcp 0 0 0.0.0.0:2200 0.0.0.0:* LISTEN 11904/sshd
tcp 0 0 . 2200 . * LISTEN 11904/sshd

20-FTP Data (For transferring FTP data) 21-FTP Control (For starting FTP connection) 22-SSH(For secure remote administration which uses SSL to encrypt the transmission) 23-Telnet (For insecure remote administration 25-SMTP(Mail Transfer Agent for e-mail server such as SEND mail) 53- DNS(Special service which uses both TCP and UDP) 68-DHCP 69-TFTP(Trivial file transfer protocol uses udp protocol for connection less transmission of data) 80 -HTTP/WWW(apache) 88-Kerberos
110-POP3(Mail delivery Agent) 123-NTP(Network time protocol used for time syncing uses UDP protocol) 137-NetBIOS(nmbd) 139,138,445-SMB-Samba(smbd) 143-IMAP 161-SNMP(For network monitoring) 389-LDAP(For centralized administration) 443-HTTPS(HTTP+SSL for secure web access) 514-Syslogd(udp port) 995-POP3s
 2049-NFS(nfsd, rpc.nfsd, rpc, portmap) 

*If protocol is not mention then the above port are solely for TCP. Some service use UDP as mention in above list.

Источник

Most Common Network Port Numbers for Linux

In computing, and more so, TCP/IP and UDP networks, a port is a logical address that is usually assigned to a specific service or running application on a computer. It is a connection endpoint that channels traffic to a specific service on the operating system. Ports are software-based and are usually associated with the IP address of the host.

The key role of a port is to ensure data transfer between a computer and an application. Specific services run on specific ports by default, for example, web traffic listens on port 80 (443 for encrypted traffic), DNS on port 53, and SSH on port 22. Ports are usually associated with the IP addresses of the host systems running the applications.

Port numbers range from 0-65535 and are divided into three network ranges as shown:

  • Ports that range from 1 to 1023 are known as system ports or well-known ports. These are ports that are reserved for running privileged services on a system.
  • Ports numbers in the range of 1024 to 49151 are referred to as registered ports and are mostly used by vendors for their applications. They are available for registration at IANA which is an authority that oversees global IP address allocation.
  • Ports numbers between 49151 and 65535 are referred to as dynamic ports. They cannot be registered with IANA and are mostly used for customized services.
Читайте также:  Linux vlan интерфейс поднять

In this guide, we will focus on the well-known ports and what services they are mostly associated with.

Commonly Use Network TCP Ports

Here is a summary documenting some of the commonly-used ports in a TCP/IP network.

Port Description
20 FTP ( File Transfer Protocol ) port for data transfer between client and server.
21 FTP ( File Transfer Protocol ) port for establishing a connection between two hosts. It’s referred to as the command or control port.
22 SSH (Secure Shell) port. This is a secure remote login service where data is encrypted.
23 Telnet. This is a remote login service that is unencrypted. Data is sent in plain text and is hence considered insecure. It was deprecated in favor of SSH.
25 SMTP (Simple Mail Transfer Protocol). A protocol used by mail servers to send and receive mail.
53 DNS (Domain Name Service) Responsible for resolving a domain name to machine-readable IP addresses.
67 (UDP) Used by the DHCP server (Dynamic Host Configuration Protocol).
68 (UDP) Used by a DHCP client.
80 HTTP (Hyper Text Transfer Protocol) is used for unsecured web traffic.
443 HTTPS (Hyper Text Transfer Protocol Secure) is used for encrypted web traffic.
110 POP3 (Post Office Protocol). Protocol for unencrypted access to a mail server.
995 POP3S (Post Office Protocol Secure). Provides encryption for POP3 protocol.
123 (UDP) NTP (Network Time Protocol).
137 NetBIOS protocol used for File and Print Sharing.
143 IMAP (Internet Messaging Application Protocol) Manages electronic mail messages on the mail server. Does not provide encryption.
161/162 SNMP protocol is used for sending commands and messages.
993 IMAPS (Internet Messaging Application Protocol Secure) Secure protocol for IMAP and provides SSL/TLS encryption.
445 SMB (Server Message Block) Port. Used for file sharing.
465 SMTPS (Simple Mail Transfer Protocol Secure). Provides encryption for the SMTP Protocol.
631 Internet Printing Protocol.

The table above has highlighted some of the most commonly used network port numbers in Linux. Did we miss something? Let us know in the comment section.

Источник

Linux Port numbers

Important Port numbers for the Linux system administrator

This is bit important post on understanding the ports, their details and numbers.

Some FAQ related PORTS

Q. What is a port?

A port is piece of software which is used as docking point in your machine, where remote application can communicate. This is analogy to the physical ports for entering in to a country from different sea ports.

Q. What is hardware port?

This is a physical peripheral connecting point to a machine from a physical device.

Q. What is a socket?

Socket is combination of software Port and IP address.

Q. What is the range of ports or how many ports are there?

Port numbers can vary from 0 to 65535, so total we can get 65536 ports

Q. Why port numbers are just 65536?

This is because limitation in TCP/IP stack where the port number field is just 16bit size. So we get only 2^16(2 to the power of 16) ports which are equal to 65536 available ports

Q. What are the well-known ports or assigned ports or default ports?

Well known ports are from 0 to 1023(total 2^10=1024 ports)

Читайте также:  Альт линукс форматирование флешки

Q. What do you mean by default port?

Default port is a designated port for particular well-known service such as web server, mail server, ftp server etc. By default FTP uses 21 port, DNS uses 53 and Apache uses 80 port.

Q. Can we change default port for a service(example Apache, squid)?

Yes, we can change. In Apache and DNS we can change this using listen configuration entry in httpd.conf and named.conf. Squid have port entry in it’s squid.conf file to mention port number.

Q. What are the protocol numbers for TCP and UDP?

Do not confuse this one with port numbers. TCP and UDP have their own numbers in TCP/IP stack.

TCP protocol number: 6

UDP protocol number: 17

Q. Is there any way I can see all the port information in Linux?

Yes, you can get that from /etc/services files.

Q. How can I see open ports in Linux?

Well known ports

20 – FTP Data (For transferring FTP data)

21 – FTP Control (For starting FTP connection)

22 – SSH (For secure remote administration which uses SSL to encrypt the transmission)

23 – Telnet (For insecure remote administration)

25 – SMTP (Mail Transfer Agent for e-mail server such as SEND mail)

53 – DNS (Special service which uses both TCP and UDP)

69 – TFTP (Trivial file transfer protocol uses udp protocol for connection less transmission of data)

80 – HTTP/WWW(Apache)

88 – Kerberos

110 – POP3 (Mail delivery Agent)

123 – NTP (Network time protocol used for time syncing uses UDP protocol)

137 – NetBIOS (nmbd)

139 – SMB-Samba (smbd)

161 – SNMP (For network monitoring)

389 – LDAP (For centralized administration)

443 – HTTPS (HTTP+SSL for secure web access)

514 – Syslogd (udp port)

636 – ldaps (both ctp and udp)

989 – FTPS-data

2049 – NFS (nfsd, rpc.nfsd, rpc, portmap)

2401 – CVS server

3306 – MySql

6000-6063-X11

Note 1: If protocol(TCP or UDP) is not mention then the above port are solely for TCP. Some service use UDP as mention in above list.

Note 2: X11 use 6000 to 6063.. ports for connecting X11 from remote server.

Surendra Anne

Mr Surendra Anne is from Vijayawada, Andhra Pradesh, India. He is a Linux/Open source supporter who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. He works as Devops Engineer with Taggle systems, an IOT automatic water metering company, Sydney . You can contact him at surendra (@) linuxnix dot com.

Latest posts by Surendra Anne (see all)

  • Docker: How to copy files to/from docker container — June 30, 2020
  • Anisble: ERROR! unexpected parameter type in action: Fix — June 29, 2020
  • FREE: JOIN OUR DEVOPS TELEGRAM GROUPS — August 2, 2019
  • Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) — August 27, 2018
  • How to use ohai/chef-shell to get node attributes — July 19, 2018

Источник

Оцените статью
Adblock
detector