IT/Linux

nc 커맨드 / 특정 IP로 listen

nofence 2022. 3. 29. 23:56

[root@localhost ~]# ip -4 -br a
lo               UNKNOWN        127.0.0.1/8
ens160           UP             192.168.0.118/24 192.168.0.119/32

 

[root@localhost ~]# nc -l 192.168.0.118 3000 &
[1] 1926
[root@localhost ~]# nc -l 192.168.0.119 3000 &
[2] 1927

[root@localhost ~]# nc -l localhost 3000 &
[3] 1972

[root@localhost ~]# nc -4 -l localhost 3000 &
[4] 2035 

 

[root@localhost ~]# jobs
[1]   Running                 nc -l 192.168.0.118 3000 &
[2]   Running                 nc -l 192.168.0.119 3000 &
[3]-  Running                 nc -l localhost 3000 &
[4]+  Running                 nc -4 -l localhost 3000 &

 

[root@localhost ~]# ss -anltp | grep -i 3000
LISTEN    0         10               127.0.0.1:3000             0.0.0.0:*        users:(("nc",pid=2035,fd=3))                                             
LISTEN    0         10           192.168.0.119:3000             0.0.0.0:*        users:(("nc",pid=1927,fd=3))                                             
LISTEN    0         10           192.168.0.118:3000             0.0.0.0:*        users:(("nc",pid=1926,fd=3))                                             
LISTEN    0         10                   [::1]:3000                [::]:*        users:(("nc",pid=1972,fd=3))      

 

 

Reference :

https://serverfault.com/questions/512333/how-can-i-configure-netcat-or-some-other-stock-linux-utility-to-listen-on-a-sp

 

How can I configure netcat (or some other stock linux utility) to listen on a specific port on a secondary IP address?

CentOS 5.9 For testing purposes, I want my CentOS server to listen on a secondary virtual IP (eth0:0). I'm familiar with nc -l -p <port> but it only listens on the primary. Is there a way I...

serverfault.com