New Option: --server-nat

This is where we can discuss what we would like to see added or changed in OpenVPN.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
User avatar
Traffic
OpenVPN Protagonist
Posts: 4066
Joined: Sat Aug 09, 2014 11:24 am

New Option: --server-nat

Post by Traffic » Mon Jan 19, 2015 9:15 pm

How about:
  • --server-nat IP netmask interface
    • Helper directive to work as --server and add NAT rule:
      • For example, --server-nat 10.8.0.0 255.255.255.0 eth0 expands as follows:

        Code: Select all

         mode server
         tls-server
         push "topology [topology]"
        
         if dev tun AND (topology == net30 OR topology == p2p):
           ifconfig 10.8.0.1 10.8.0.2
           if !nopool:
             ifconfig-pool 10.8.0.4 10.8.0.251
           route 10.8.0.0 255.255.255.0
           if client-to-client:
             push "route 10.8.0.0 255.255.255.0"
           else if topology == net30:
             push "route 10.8.0.1"
        
         if dev tap OR (dev tun AND topology == subnet):
           ifconfig 10.8.0.1 255.255.255.0
           if !nopool:
             ifconfig-pool 10.8.0.2 10.8.0.254 255.255.255.0
           push "route-gateway 10.8.0.1"
           if route-gateway unset:
             route-gateway 10.8.0.2
        
         iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
        maybe i'll try doing it myself ....

Post Reply