0

I have 2 servers: server1 and server2. I can't use server1's 8080 port directly only throughout server2 Now I do port-forwarding in such way:

ssh -4 -L 8080:server1:8080 user@server2

and I could connect to the first server by this address:

localhost:8080

But I want to connect by this address:

server1:8080

How can I do this?

1
  • How are the two networks connected where the servers are? Commented Jan 30, 2017 at 17:47

2 Answers 2

1

Use a dynamic port forwarding and use that as you would use a socks server

ssh -D 127.0.0.1:1080 user@server2 

Then for instance:

curl --socks5 127.0.0.1:1080 server1:8080 
2

You can redirect your outgoing traffic to server1:8080 to localhost:8080 using iptables DNAT rule as follows:

$ sudo iptables -t nat -A OUTPUT -d server1 -p tcp --dport 8080 -j DNAT --to-destination 127.0.0.1 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.