Forward Source Virtual IP in Azure VM Setup

This forum is for admins who are looking to build or expand their OpenVPN setup.

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

Forum rules
Please use the [oconf] BB tag for openvpn Configurations. See viewtopic.php?f=30&t=21589 for an example.
Post Reply
nirvanah
OpenVpn Newbie
Posts: 1
Joined: Thu Feb 03, 2022 10:05 am

Forward Source Virtual IP in Azure VM Setup

Post by nirvanah » Thu Feb 03, 2022 10:17 am

Hello,

I have set up an instance of OpenVPN Community (and also tried OpenVPN Access Server) in an Azure VM. I have multiple VNets and have peered them according to needs. I use this OpenVPN Instance to securely connect to the other VMs via their Private IPs. People connect to this VM then access the VMs in MZ via their Private IPs.

The problem is that, VMs in the MZ only detect the IP address of the OpenVPN VM and not the actual Virtual IP assigned to clients via the OpenVPN. I am looking for a solution to forward the Source Virtual IP of the Clients to the VMs in MZ when routed through OpenVPN.

Here's my IP tables configuration:

Code: Select all

iptables -t nat -A POSTROUTING -s 172.17.0.0/24 ! -d 172.17.0.0/24 -j SNAT --to 10.0.30.4
iptables -I INPUT -p udp --dport 1194 -j ACCEPT
iptables -I FORWARD -s 172.17.0.0/24 -j ACCEPT
iptables -I FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
OpenVPN server.conf
server

log-append /var/log/openvpn.log
verb 11
local 10.0.30.4
port 1194
proto udp
management 127.0.0.1 5555
dev tun
ca ca.crt
cert server.crt
key server.key
tls-version-min 1.2
dh dh.pem
auth SHA512
tls-crypt tc.key
topology subnet
server 172.17.0.0 255.255.255.0
push "route 10.0.0.0 255.255.0.0 vpn_gateway"
ifconfig-pool-persist ipp.txt
keepalive 30 120
cipher AES-256-CBC
user nobody
group nogroup
persist-key
persist-tun
status openvpn-status.log
crl-verify crl.pem
explicit-exit-notify
remote-cert-tls client
verify-client-cert require
opt-verify
#ecdh-curve
tls-server


To summarize:
VPN IP: 10.0.30.4
Target VM IP: 10.0.0.1
Source Virtual IP of Client: 172.17.0.2

IP Detected by Target VM: 10.0.30.4
Desired IP to be detected by Target VM: 172.17.0.2

Post Reply