E
E
elisey4742016-09-01 20:38:15
SSH
elisey474, 2016-09-01 20:38:15

How to forward ports on ubuntu?

The situation is this. There is a computer in my home network on ubuntu 16.04 and there is a vps with external ip $externalip also on ubuntu 16.04.
I set up authorization by key between the computer and vps.
Then on the computer I execute:
[email protected]$externalip -w 0:0
Then on the vps I execute ifconfig tun0 10.0.0.1/30 pointopoint 10.0.0.2
On the computer ifconfig tun0 10.0.0.2/30 pointopoint
10.0.0.1 vps, I get access to the computer.
But now how can I make it so that with ssh $externalip -p 2222 I get access to my computer?
Is it possible to include another participant in this network consisting of 10.0.0.1 (vps) and 10.0.0.2 (computer), for example, 10.0.0.3 (another computer)?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
tmcdos, 2016-09-01
@tmcdos

In my opinion, you can make a hole in IPtables, like
Because you didn't specify an external interface name on the VPS, I wrote eth0 .
The pointtopoint protocol only has 2 participants - no more, no less.
But if you have successfully connected to your computer via SSH, then you can already contact a third party through it.

S
Sergei Nazarenko, 2016-09-01
@nazares

iptables -t nat -I PREROUTING --dst 10.0.0.2-p tcp -m tcp --dport 2222 -j DNAT --to-destination 10.10.0.x:2222
iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to-source 10.0.0.2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question