1

I need to access my home http service from internets, but I only have LTE ISP which gives me dynamic internal IP that is different from dynamic public IP. So, straight forward port forwarding is not working.

I do have VPS on DigitalOcean running Ubuntu. At home I have Mikrotik SXT LTE modem and RB2011 router. I set up PPTP on Ubuntu and can PPTP on my router - it works fine. Service is running on local device at 192.168.1.46.

How can I port forward Ubuntu to it's PPTP client which is my router and then to network device?

1 Answer 1

0

You can port forward but you will need to NAT the other direction of traffic, because otherwise it wouldn't work.

On ubuntu:

  • eth0 is uplink
  • ppp0 is pptp connection
  • xx is TCP port of service

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport xx -j DNAT --to 192.168.1.46

iptables -t nat -A POSTROUTING -o ppp0 -d 192.168.1.46 -p tcp --dport xx -j MASQUERADE

You must also have ipv4 forwarding enabled on ubuntu

3
  • For some reason my VPS is not communicating with home network. I only can talk to my router. I've modified rules you provided to route port 333 to 192.168.1.1 and on my home router I dst-nat to my network device. Commented Mar 6, 2016 at 19:35
  • you must set up routes properly on mikrotik and on ubuntu too. after ping works then you can try forwarding ports Commented Mar 6, 2016 at 20:35
  • Thank you a lot for showing direction. I've added route add -net 192.168.1.0 netmask 255.255.255.0 dev ppp0 on Ubuntu and I could ping everything at home. Before it was 192.168.1.1 so I could only ping router. Now next challenge is to have more devices (cameras) accessible from internet. I'm trying to use ports like :81-82 and through iptables pointing them to certain IP's but so far no success. Commented Mar 9, 2016 at 16:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .