[완료] iptables 에서 --to-ports 옵션에 대한 질문입니다.

cococo의 이미지

..... 자유 게시판에 질문을 올려놓는 우(愚)를 범해, 옮겨옵니다. 날이 더우니 실수를 하나 봐요. 기가 허해진건가... @_@;;

------------------------------------
안녕하십니까. 비 와서 좀 시원해 졌네요.

회사 안에서 Load Balancing 을 구현하기 위해서 ipvsadm 이랑 iptables 에 대해 조사해 본 다음,
테스트를 해 보려고 네트워크 망 구성을 부탁했습니다.

근데, man iptables 해 보면 ( http://linux.die.net/man/8/iptables )
--to-ports 라는 옵션이 있는데요,
실제로 써 보면 안먹습니다.
(

iptables v1.4.1.1: Unknown arg `--to-ports'
Try `iptables -h' or 'iptables --help' for more information.

라고 나와요. -_-;;
)

iptables command는

iptables -t nat -p tcp -A POSTROUTING -o eth1 -j SNAT -s 10.1.1.10/11 --sport 9999 --to 10.1.1.12:9999
iptables -t nat -p tcp -A PREROUTING -i eth1 -j DNAT -d 10.1.1.12 --dport 9999 --to 10.1.1.10-10.1.1.11:9999

로 했구요( --to-ports, --to-port 가 먹히지 않아서 결국 [:9999] 의 형태로 했습니다. )

결과는

iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination
DNAT       tcp  --  anywhere             10.1.1.12           tcp dpt:9999 to:10.1.1.10-10.1.1.11:9999
 
Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination
SNAT       tcp  --  10.0.0.0/11          anywhere            tcp spt:9999 to:10.1.1.12:9999
 
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

이렇게 나옵니다.

원래 --to-ports 혹은( --to-port) 옵션이 없는 건가요?

그리고, --to-ports 대신에 XXX.XXX.XXX.XXX:9999 로 해도 될까요?

혹시 아시는 분, 혹은 비슷한 경우를 겪으셨던 분은 조언 부탁드립니다.

그럼, 좋은 저녁 되시기 바랍니다.

( PS: kldp 뒤져보니까 [ --to-ports ] 가 없네요. -_-;; 진짜 없긴 없는 듯 한데요. )

bushi의 이미지

링크하신 문서엔 MASQUERADE, REDIRECT 타겟에 대해서만 --to-ports 옵션을 설명하고 있습니다.

[bushi@rose mojo]$ iptables -j MASQUERADE --help
...
MASQUERADE target options:
 --to-ports <port>[-<port>]
				Port (range) to map to.
 --random
				Randomize source port.
[bushi@rose mojo]$
 
[bushi@rose mojo]$ iptables -j REDIRECT --help
...
REDIRECT target options:
 --to-ports <port>[-<port>]
				Port (range) to map to.
[bushi@rose mojo]$

OTL

cococo의 이미지

bushi 님 답변 감사드립니다. 좋은 하루 되시기 바랍니다.

-----------------------------------------
행복은 희생없이는 얻을 수 없는 것인가?
시대는 불행없이는 넘을 수 없는 것인가?