Linux Interview Questions - PORT Related: PART 7



PORT Related interview questions in Linux:

1. 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.

2. What is hardware port?
This is physical peripheral connection point to a machine from a physical device.

3. What is a socket?
Socket is combination of software Port+IP address.

A socket is just a logical endpoint for communication. They exist on the transport layer. You can send and receive things on a socket, you can bind and listen to a socket. 
A socket is specific to a protocol, machine, and port, and is addressed as such in the header of a packet.

4. 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

5. 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 ports which are equal to 65536 available ports

6.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)

7.What do you mean by default port?
Default port is a designated port for particular well-known server.

8.Can we change default port for a service(example Apache, squid)?
Yes, we can change. In most apache and DNS we can change this using listen configuration entry in httpd.conf and . Squid have port entry in its squid.conf file to mention port number.

9.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

10. Is there any way I can see all the port information in Linux?
Yes, you can get that from /etc/services files.

11. How can I see open ports in Linux?
use nmap , lsof or netstat commands.

Ex: #lsof -i
Ex: #netstat -tulpn
Ex: #nmap -sT -O localhost

12.Which port is used by Ping command?

The answer is none. No ports required for Ping as it uses icmp packets 

It needs to allow icmp 'echo-request' (type 8) packets out and icmp 'echo-reply' (type 0) packets in.  

Ping Use ICMP to comminicate and ICMP is a protocol not a service. Hence it does not use a specific port 

FLOW :
ICMP Echo Request
|
Type (8) Code (0)

Checksum

Identification

Sequence
 |
Test Data 




Ports and corresponding port numbers:


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)

67 – Bootp

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)

138 - NetBIOS 


139 – SMB-Samba(smbd)

143 – IMAP

161 – SNMP(For network monitoring)

162-SNMP Trap

 389 – LDAP(For centralized administration)

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

514 – Syslogd(udp port)

636 – ldaps(both tcp and udp)

873 – rsync



1 comments:

Post a Comment

Blogger Tips and TricksLatest Tips And TricksBlogger Tricks