English 中文(简体)
how can I use iptables to forward (or redirect) traffic from one ip port to another specific IP port?
原标题:

The prerequisite is:

HostA: (can access public machine, can t access hostA and hostB)              CentOS 7
HostB: (private machine, I can login, and it can access hostA and hostC,  )   CentOS 7
HostC: (private machine, svn server, IP:)

I need to hostA to "svn co http://hostC_IP:port/svn_repository".

And I set a "screen -dmS svn ssh -R HostAPublicIP:11002:HostC_IP:80 user@HostA_PublicIP -p2222" on hostB that the hostA can checkout the svn by " svn co http://127.0.0.1:11002/svn_repository". It works well.

But there is another problem that the svn repository has external links and the HostA can t checkout the external repository( the external repository s address is the same HostC_IP). So I thought of a method: use the "ip forward" to solve it.

The detail is that use the original address to checkout,and the "HostC_IP:80" forward to "127.0.0.1:11002" through the ssh tunnel:

sudo sysctl -w net.ipv4.conf.all.route_localnet=1
sudo iptables -t nat -A POSTROUTING -p tcp -d HostC_IP --dport 80 -j SNAT --to-source 127.0.0.1
# /proc/sys/net/ipv4/ip_forward=1   has setted

It didn t work.

What can I do to make it run properly or is it impossible?

问题回答

暂无回答




相关问题
pcap and iptables tussle

I have setup a DNS server on a machine. I want to capture the DNS replies before the machine sends out, and change some fields in it and then send the packet. I am only able to change fields in the ...

i just want to use the iptables command in my c program

i m designing a simple c code to call the iptables command according to the need. i just want to drop the packets from a particular ipaddress using my c code. thats why i have to use the iptables ...

List of loaded iptables modules

Is there any convenient way to show loaded iptables module list? I can show installed modules by listing /lib/iptables/ (or /lib64/iptables/) directory but I need active modules list.

iptables port redirection

I have following problem: CRM system running on Linux computer is sending emails via sendmail. I would like to change destination port from 25 to 587 using iptables but without modifing sendmail (...

Python port forwarding/multiplexing server

I would like to make server that listen on UDP port 162 (SNMP trap) and then forwards this traffic to multiple clients. Also important is that the source port & address stays same (address ...

iptables ACL question

how do I drop all traffic to smtp, except originating from my IP? This example I found drops traffic for particular IP, I need to deny by default, but allow 1 IP in. Thanks # iptables -A INPUT -s 65....

热门标签