리눅스에서 socket 에 대한 특정 포트가 다른 곳에서 할당되지 않게 하는법??
글쓴이: trymp / 작성시간: 목, 2011/09/15 - 10:14오전
제가 만든 'A' 라는 damon 은 로컬에서 udp 5000번 입니다. 하지만 이 데몬이 뜨기전에
다른 데몬에서 ramdon 하게 이 포트 5000번을 먼저 커널로 부터 받아서 쓴다면
A-daemon 은 port conflict 이 나서 bind 실패해서 정상동작을 못할 것입니다.
포트를 지정하지 않고 random 하게 할당받는 데몬들과 같이 쓰는 경우 문제가 발생하는데요.
kernel 에서 빈 포트를 임으로 할당해주잖아요. 1024번 이상부터...
그 때 5000 ~ 6000 까지는 커널이 할당하지 않도록 하는 방법이 있나요?
일종의 예약개념으로 5000~ 6000 까지는 다른 데몬들한테 할당하지 않고 제가 만든 데몬이
나중에 뜰 때 사용하고 싶어서 그럽니다.
이것을 가능하게 할 마땅한 방법 좀 알려주세요.
Forums:
Documentation/networking/ip-s
Documentation/networking/ip-sysctl.txt
에 보시면
IP Variables:
ip_local_port_range - 2 INTEGERS
Defines the local port range that is used by TCP and UDP to
choose the local port. The first number is the first, the
second the last local port number. Default value depends on
amount of memory available on the system:
> 128Mb 32768-61000
< 128Mb 1024-4999 or even less.
This number defines number of active connections, which this
system can issue simultaneously to systems not supporting
TCP extensions (timestamps). With tcp_tw_recycle enabled
(i.e. by default) range 1024-4999 is enough to issue up to
2000 connections per second to systems supporting timestamps.
이런 내용이 있습니다.
웬만한 메모리용량을 사용중이시면 32768보다 큰 포트를 사용할테니 5000번대 포트는 걱정하실 필요없습니다.
/proc을 통해서 다른 값을 설정하셔도 되고요.
감사합니다. 많은 도움되었습니다...^^
....
댓글 달기