Search code examples
routesiptablesopenvpn

Redirect a range of IPs via OpenVpn


I can't redirect an ip range through the vpn, it tells me that the VPN server blocks the traffic.

This is my architecture diagram

This is my settings:

  • The Subnet is 152.20.20.0 MASK 255.255.255.0

  • Client Windows:

    route add 22.22.22.0 MASK 255.255.255.0 10.8.0.16

  • Server Windows OpenVpn (10.8.0.1):

    It's configured in client to client mode, therefore my Windows client "knows" the gateway under the VPN

  • Ubuntu gateway (10.8.0.16):

    iptables -t nat -A PREROUTING -d 22.22.22.0/24 -j NETMAP --to 152.20.20.0/24

    iptables -t nat -A POSTROUTING -j MASQUERADE

But if I try to trace an IP from the Windows Client (on 22.22.22.0 range) i get:

Result of tracert from Windows client


Solution

  • I solved the problem:

    I added the following rule to the server:

    route 22.22.22.0 255.255.255.0
    

    And on the server's ccd (ubuntu gateway) file

    iroute 22.22.22.0 255.255.255.0