delegate でポートまとめて指定できるんね

独立したネットワーク同士の真ん中においた境界サーバからあっちとこっちをこっそり繋ぐのに delegate の tcprelay がべんり。

 

# delegated -P22,80,443 SERVER=tcprelay://original-server:-/

 

tcprelay 先のポートを "-" と書くことにより、LISTEN するポートと同じポートをマッピングしてくれる。

このままだと 0.0.0.0 で LISTEN するのでどのIPで受けても返事してしまう。

 

# netstat -nltp | grep delegate
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 7614/delegated -{00
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 7614/delegated -{00
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 7614/delegated -{00

 

自身が複数のIPを持っており、その中から特定のIPで受けたときすなわち LISTEN する IP を特定のものだけにして欲しいときはポートと一緒にIPも指定すれば良い。

 

# delegated -P192.168.0.1:22,192.168.0.1:80,192.168.0.1:443 SERVER=tcprelay://original-server:-/

 

するとIP決め打ちでLISTENしてくれる。

 

# netstat -nltp | grep delegate
tcp 0 0 192.168.0.1:80 0.0.0.0:* LISTEN 7623/delegated -{00
tcp 0 0 192.168.0.1:22 0.0.0.0:* LISTEN 7623/delegated -{00
tcp 0 0 192.168.0.1:443 0.0.0.0:* LISTEN 7623/delegated -{00

 

大変便利である。