리눅스
우분투 24.04에서 nc 명령어를 사용하기 위한 방법
변군이글루
2025. 10. 22. 00:16
반응형
우분투 24.04에서 nc 명령어를 사용하기 위한 방법
우분투 24.04에서 nc(netcat)를 사용하려면 nc라는 패키명은 없고 대신 netcat-openbsd 또는 netcat-traditional을 설치하면 됩니다.
netcat 패키지 설치 시 오류
sudo apt install -y netcat
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package netcat is a virtual package provided by:
netcat-traditional 1.10-48
netcat-openbsd 1.226-1ubuntu2
You should explicitly select one to install.
E: Package 'netcat' has no installation candidate
설치
sudo apt install -y netcat-openbsd
설치 확인
$ which nc
/usr/bin/nc
$ nc -h
OpenBSD netcat (Debian patchlevel 1.226-1ubuntu2)
usage: nc [-46CDdFhklNnrStUuvZz] [-I length] [-i interval] [-M ttl]
[-m minttl] [-O length] [-P proxy_username] [-p source_port]
[-q seconds] [-s sourceaddr] [-T keyword] [-V rtable] [-W recvlimit]
[-w timeout] [-X proxy_protocol] [-x proxy_address[:port]]
[destination] [port]
Command Summary:
-4 Use IPv4
-6 Use IPv6
-b Allow broadcast
-C Send CRLF as line-ending
-D Enable the debug socket option
-d Detach from stdin
-F Pass socket fd
-h This help text
-I length TCP receive buffer length
-i interval Delay interval for lines sent, ports scanned
-k Keep inbound sockets open for multiple connects
-l Listen mode, for inbound connects
-M ttl Outgoing TTL / Hop Limit
-m minttl Minimum incoming TTL / Hop Limit
-N Shutdown the network socket after EOF on stdin
-n Suppress name/port resolutions
-O length TCP send buffer length
-P proxyuser Username for proxy authentication
-p port Specify local port for remote connects
-q secs quit after EOF on stdin and delay of secs
-r Randomize remote ports
-S Enable the TCP MD5 signature option
-s sourceaddr Local source address
-T keyword TOS value
-t Answer TELNET negotiation
-U Use UNIX domain socket
-u UDP mode
-V rtable Specify alternate routing table
-v Verbose
-W recvlimit Terminate after receiving a number of packets
-w timeout Timeout for connects and final net reads
-X proto Proxy protocol: "4", "5" (SOCKS) or "connect"
-x addr[:port] Specify proxy address and port
-Z DCCP mode
-z Zero-I/O mode [used for scanning]
Port numbers can be individual or ranges: lo-hi [inclusive]
간단히 포트 열어 수신(서버 역할)
nc -l 8080
로컬에서 연결(클라이언트 역할)
nc 127.0.0.1 8080
포트 스캔(열려있는지 체크)
nc -zv example.com 22 80 443
- -z: 포트만 체크
- -v: verbose
간단한 파일 전송
- 수신(수신측)
nc -l 1234 > received.file
- 송신(송신측)
nc receiver.example.com 1234 < file_to_send
728x90
반응형