smotbd
asked on
500: basic port forwarding/mapping
Hi all,
This is an easy 500 points, especially if you've done it before..!
I have 3 PCs (call them A, B and C)
A and C both have non-routable ip addresses so they can't talk directly to each other.
So I have set up a middle PC (i.e B) to port forward between A and B.
A will talk to B on say port 'x' and C will talk to B on say port 'y' so data can be transfered between A and C.
Problem is: I have looked at a couple of simple port forwarding commands but they all specify the ip addresses to be mapped. All I want is a command running on linux PC 'B' to forward anything sent to port 'x' to port 'y' (without specifying any ip address).
Can any one write a working example of this please.
Many thanks,
This is an easy 500 points, especially if you've done it before..!
I have 3 PCs (call them A, B and C)
A and C both have non-routable ip addresses so they can't talk directly to each other.
So I have set up a middle PC (i.e B) to port forward between A and B.
A will talk to B on say port 'x' and C will talk to B on say port 'y' so data can be transfered between A and C.
Problem is: I have looked at a couple of simple port forwarding commands but they all specify the ip addresses to be mapped. All I want is a command running on linux PC 'B' to forward anything sent to port 'x' to port 'y' (without specifying any ip address).
Can any one write a working example of this please.
Many thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
so ???? you try this helps?
ASKER
I found that the following works:
/sbin/iptables -t nat -I PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
/sbin/iptables -t nat -I PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
is the same like i post in the first message... exactly the same
ASKER
Not quite "exactly" the same but close enough I guess- see below!!
-t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
-t nat -I PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
Many thanks
-t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
-t nat -I PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
Many thanks
If it is a simple protocol you could maybe slogin to computer B from computer A and from computer C. With appropriate tunnel forwarding commands you establish a one way (or two way) connection between machines A and C.
For more complex protocols you could establish a VPN connection from A to C and this would probably involve the SSH tunneling mentioned before.
So if server A is a web server (on port 80) and you want to access it from computer C you would do:
on computer A:
slogin -N -R 8081:<computer_A_IP>:80 user@<computer_B_IP>
on computer C:
slogin -N -L 8082:<computer_B_IP>:8081 user@<computer_B_IP>
This commands are for establishing the tunnels. It is posible to establish this in startup scripts without entering passwords etc.
Then on computer C run:
lynx http://localhost:8082/
And you should get the default web page from server A.