티스토리 뷰

OS/Linux

port open - server

solarwind 2008. 6. 25. 20:35
반응형

결론적으로 원하시는 상태, 즉 접속가능한 상태를 표시하고 싶다면,
먼저 /etc/service 에서 원하는 포트를 열어두신후에
프로그램으로 원하는 소켓의포트를 오픈하는서버데몬을 작성하신후에
클라이언트에서 그포트를 이용하기위해접속하면 됩니다

먼저 원하시는 상태에 대한 설명이 필요할것 같습니다

tsc14:~ # netstat -anpt
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name  
tcp        0      0 0.0.0.0:11              0.0.0.0:*               LISTEN      6023/xinetd        
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1908/portmap       
tcp        0      0 0.0.0.0:23              0.0.0.0:*               LISTEN      6023/xinetd        
tcp        0      0 0.0.0.0:631             0.0.0.0:*               LISTEN      2505/cupsd         
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      2837/master        
tcp        0      0 :::22                   :::*                    LISTEN      2250/sshd          
tcp        0      0 ::1:25                  :::*                    LISTEN      2837/master        
tcp        0    220 210.183.235.14:22       210.183.235.13:2421     ESTABLISHED 4411/38

이처럼 netstat 를 하였을때 ESTABLISHED 상태로 나오는것은
서로 연결된 상태를 이야기합니다
 

Netstat 명령어 사용법

tsc14:~ # netstat --help
usage: netstat [-veenNcCF] [<Af>] -r         netstat {-V|--version|-h|--help}
       netstat [-vnNcaeol] [<Socket> ...]
       netstat { [-veenNac] -i | [-cnNe] -M | -s }

        -r, --route              display routing table
        -i, --interfaces         display interface table
        -g, --groups             display multicast group memberships
        -s, --statistics         display networking statistics (like SNMP)
        -M, --masquerade         display masqueraded connections

        -v, --verbose            be verbose
        -n, --numeric            don't resolve names
        --numeric-hosts          don't resolve host names
        --numeric-ports          don't resolve port names
        --numeric-users          don't resolve user names
        -N, --symbolic           resolve hardware names
        -e, --extend             display other/more information
        -p, --programs           display PID/Program name for sockets
        -c, --continuous         continuous listing

        -l, --listening          display listening server sockets
        -a, --all, --listening   display all sockets (default: connected)
        -o, --timers             display timers
        -F, --fib                display Forwarding Information Base (default)
        -C, --cache              display routing cache instead of FIB

그리고 상태표시에 대한 설명입니다

State

내       용

LISTEN

서버의 데몬이 떠서 접속 요청을 기다리는 상태.

SYS-SENT

로컬의 클라이언트 어플리케이션이 원격 호스트에 연결을 요청한 상태

SYN_RECEIVED

서버가 원격 클라이언트로부터 접속 요구를 받아 클라이언트에게 응답을 하였지만 아직 클라이언트에게 확인 메시지는 받지 않은 상태.

ESTABLISHED

3 Way-Handshaking 이 완료된 후 서로 연결된 상태

FIN-WAIT1
CLOSE-WAIT
FIN-WAIT2

버에서 연결을 종료하기 위해 클라이언트에게 종결을 요청하고 회신을 받아 종료하는 과정의 상태.

CLOSING

흔하지 않지만 주로 확인 메시지가 전송도중 분실된 상태

TIME-WAIT

연결은 종료되었지만 분실되었을지 모를 느린 세그먼트를 위해 당분간 소켓을 열어놓은 상태.

CLOSED

완전히 종료.

반응형
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/03   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
글 보관함