Linux – How to open a port on linux (Debian jessie)

iptableslinuxnmapport

I have a process that I'm running on my local machine which is listening on TCP port 9000. I would like to consume on another computer of my network. Here is my configuration:

I would like to see it when I run nmap 10.18.12.12 but I don't know how.

nmap localhost

Starting Nmap 6.47 ( http://nmap.org ) at 2015-08-20 13:49 ART
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00037s latency).
Other addresses for localhost (not scanned): 127.0.0.1
Not shown: 987 closed ports
PORT     STATE SERVICE
21/tcp   open  ftp
22/tcp   open  ssh
25/tcp   open  smtp
80/tcp   open  http
111/tcp  open  rpcbind
443/tcp  open  https
631/tcp  open  ipp
3306/tcp open  mysql
5432/tcp open  postgresql
8000/tcp open  http-alt
**9000/tcp open  cslistener**
9001/tcp open  tor-orport
9999/tcp open  abyss

Starting Nmap 6.47 ( http://nmap.org ) at 2015-08-20 13:45 ART
Nmap scan report for 10.18.12.12
Host is up (0.00073s latency).
Not shown: 994 closed ports
PORT     STATE SERVICE
21/tcp   open  ftp
22/tcp   open  ssh
80/tcp   open  http
111/tcp  open  rpcbind
443/tcp  open  https
3306/tcp open  mysql

Best Answer

The service is bound to 127.0.0.1. You can see this without using Nmap; use netstat instead: netstat -tln will show all listening TCP ports. You should see something like this:

$ netstat -tln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN

In this example, the service on port 21 (FTP) is listening on the special address 0.0.0.0 which means "any available address," but the service on port 9000 is bound to 127.0.0.1, which is a special address ("localhost" or "loopback") not accessible from the network.

Most services will have a way to specify which addresses or interfaces to listen on. Read the manual for the service you are interested in to determine how to change this.