-1

This question is an exact duplicate of:

I tried iptables -I INPUT -p tcp -m tcp --dport 4444 -j ACCEPT to open a port but still closed:

$ nmap hostname -p 4444
Starting Nmap 7.70 ( https://nmap.org ) at 2018-05-23 04:47 +0430
Nmap scan report for linux (127.0.1.1)
Host is up (0.000040s latency).
rDNS record for 127.0.1.1: Linux.domain.linux

PORT     STATE  SERVICE
4444/tcp closed krb524

Nmap done: 1 IP address (1 host up) scanned in 0.10 seconds

What might the reason be? What should I do instead?

marked as duplicate by Jeff Schaller, Sparhawk, Rui F Ribeiro, GAD3R, vonbrand May 23 '18 at 19:10

This question was marked as an exact duplicate of an existing question.

2

There has to be something listening on the port, opening the firewall alone doesn't open it.

Here httpd is listening on 80, so it shows open

$ nmap localhost -p 80

Starting Nmap 6.40 ( http://nmap.org ) at 2018-05-22 19:22 MDT
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00019s latency).
Other addresses for localhost (not scanned): 127.0.0.1
PORT   STATE SERVICE
80/tcp open  http

Nmap done: 1 IP address (1 host up) scanned in 0.18 seconds

Here netstat shows I'm listening on 80, because httpd is listening on it.

$ netstat --listening --numeric-ports | grep 80
tcp6       0      0 [::]:80                 [::]:*                  LISTEN

$ systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2018-05-22 18:18:01 MDT; 1h 5min ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 1279 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
    Tasks: 7
   CGroup: /system.slice/httpd.service
           ├─1279 /usr/sbin/httpd -DFOREGROUND
           ├─1928 /usr/sbin/httpd -DFOREGROUND
           ├─1929 /usr/sbin/httpd -DFOREGROUND
           ├─1930 /usr/sbin/httpd -DFOREGROUND
           ├─1931 /usr/sbin/httpd -DFOREGROUND
           ├─1932 /usr/sbin/httpd -DFOREGROUND
           └─1933 /usr/sbin/httpd -DFOREGROUND

May 22 18:17:55 trogdor.mydomain.com systemd[1]: Starting The Apache HTT...
May 22 18:18:01 trogdor.mydomain.com systemd[1]: Started The Apache HTTP...
Hint: Some lines were ellipsized, use -l to show in full.

If I shut down httpd:

# systemctl stop httpd 
$ nmap localhost -p 80

Starting Nmap 6.40 ( http://nmap.org ) at 2018-05-22 19:23 MDT
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00017s latency).
Other addresses for localhost (not scanned): 127.0.0.1
PORT   STATE  SERVICE
80/tcp closed http

Nmap done: 1 IP address (1 host up) scanned in 0.13 seconds

Netstat shows I'm not listening on 80, even though it's open

$ netstat --listening --numeric-ports | grep 80
$ 

The point is, the IPTables part is an XyProblem. If I start a reverse-connect listener on 4444, (this is taken from the rapid7 Q&A), then port 4444 shows as open and listening and I never have to touch IP tables.

msf > use exploit/multi/handler
msf exploit(handler) > set PAYLOAD windows/meterpreter/reverse_tcp
msf exploit(handler) > set LHOST 127.0.0.1
msf exploit(handler) > set LPORT 4444
msf exploit(handler) > set ExitOnSession false
msf exploit(handler) > exploit -j

# netstat --numeric-ports --listening | grep 4444
tcp        0      0 localhost:4444          0.0.0.0:* 
  • netstat --listening --numeric-ports | grep 4444 no result – Raakh May 23 '18 at 7:41
  • What do you expect to have running on port 4444 – flerb May 23 '18 at 16:45
  • metasploit but is that matters what I want to run on 4444?? – Raakh May 24 '18 at 8:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.