0

I am desperately trying to setup a gateway-server that forwards all local traffic to a ppp0 connection but is still reachable via ssh on the local network.

The point-to-point connection establishes fine, IP-forwarding is enabled and with

route add -net 0.0.0.0/0 ppp0
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

I almost achieve what I want. But once "route" is set, the gateway-server can no longer be reached via ssh.

I am pretty new to "route" and "iptables" and do not fully understand how they work yet but there has to be a super simple solution for my problem.

Please help!

A very similar question without proper solution: How can I route outgoing traffic through a PPTP VPN connection on a VPS without losing SSH access?

EDIT: A more detailed example below

LOCALHOST (192.168.0.1) --> GATEWAY (192.168.0.2) --> VPN (93.184.216.34)

GATEWAY shall be a local gateway to the internet via VPN. This is quite an easy setup as described above: Enable IP-forward, establish a PPTP connection between GATEWAY<>VPN and set a default route through ppp0 afterwards.

LOCALHOST can now use GATEWAY for internet access with VPN's IP-address but access to GATEWAY within the local network (192.168.0.X) via SSH does not work anymore once the PPTP connection is established.

EDIT2: ifconfig and route output (192.168.0.10 is the 'regular' local gateway)

eth0      Link encap:Ethernet  Hardware Adresse 12:34:56:78:90:ab  
          inet Adresse:192.168.0.1  Bcast:192.168.1.255  Maske:255.255.255.0

ppp0      Link encap:Punkt-zu-Punkt-Verbindung  
          inet Adresse:10.10.1.1  P-z-P:93.184.216.34  Maske:255.255.255.255

-

Ziel            Router          Genmask         Flags Metric Ref    Use Iface
default         *               0.0.0.0         U     0      0        0 ppp0
default         192.168.0.10    0.0.0.0         UG    0      0        0 eth0
93.184.216.34   192.168.0.10    255.255.255.255 UGH   0      0        0 eth0
93.184.216.34   *               255.255.255.255 UH    0      0        0 ppp0
localnet        *               255.255.255.0   U     0      0        0 eth0
  • Please post details about networks: ip of local host running ssh client; ip of gateway server, on the lan-side; ip of default gateway used on the lan. These are needed to define the "route add" command that you need to substitute to the one you posted to solve your problem. – Damiano Verzulli Dec 28 '14 at 1:15
  • Can you show the output of ifconfig and route once everything is up ? – Marki Dec 29 '14 at 12:09
0

/etc/ppp/peers/CONFIG:

...
defaultroute
replacedefaultroute

/etc/ppp/ip-up.d/CONFIG:

#!/bin/bash
route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.0.10 dev eth0
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.