I have a dedicated server with Ubuntu Server 18.04. I need an additional IP-address so I leased a cheap VDS, then I've setup pptpd on VDS and pptp on dedicated server. Then I configured a VPN-connection on both machines. Then I've setup a static local IP-address for my dedicated server as a PPTP-client. Local IP-address of PPTP-server is 192.168.0.1
, local IP-address of PPTP-client is 192.168.0.10
. Also I forwarded some ports from VDS to my PPTP-client (dedicated server) via iptables:
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-destination 192.168.0.10
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j DNAT --to-destination 192.168.0.10
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 8080 -j DNAT --to-destination 192.168.0.10
Dedicated server:
root@cencored:~# pon pptp
root@cencored:~# ifconfig
enp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.1.10 netmask 255.255.255.0 broadcast 10.0.1.255
inet6 fe80::dabb:c1ff:fe9d:f29a prefixlen 64 scopeid 0x20<link>
ether d8:bb:c1:9d:f2:9a txqueuelen 1000 (Ethernet)
RX packets 5143110 bytes 3266730706 (3.2 GB)
RX errors 0 dropped 420968 overruns 0 frame 0
TX packets 5426143 bytes 3358034990 (3.3 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 24290274 bytes 4438508584 (4.4 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 24290274 bytes 4438508584 (4.4 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ppp0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1496
inet 192.168.0.10 netmask 255.255.255.255 destination 192.168.0.1
ppp txqueuelen 3 (Point-to-Point Protocol)
RX packets 11 bytes 322 (322.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 6 bytes 102 (102.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
The thing with forwarded port didn't work, so I tried to add a gateway:
ip route add default via 192.168.0.1
Now it works, but any applications like web-server, ssh, etc. is unreachable from enp1s0.
Then I deleted gateway and tried to configure netplan:
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
enp1s0:
addresses:
- 10.0.1.10/24
gateway4: 10.0.1.1
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
search: []
optional: true
ppp0:
addresses:
- 192.168.0.10/32
gateway4: 192.168.0.1
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
search: []
optional: true
and netplan apply
Now route
looks like:
root@cencored:~# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 10.0.1.1 0.0.0.0 UG 0 0 0 enp1s0
default 192.168.0.1 0.0.0.0 UG 0 0 0 ppp0
10.0.1.0 0.0.0.0 255.255.255.0 U 0 0 0 enp1s0
192.168.0.1 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
But ports 80, 8080, 443 still unreachable from internet