Page 1 of 1

change out IP

Posted: Fri Feb 11, 2011 3:30 pm
by yunusyb
Hello

I Have got openvpn setup and running, no problems here.
My server have 3 IP addresses say 1.1.1.1(server default IP), 2.2.2.2, and 3.3.3.3
When I connect to vpn and browse all traffic goes out from the IP 1.1.1.1
I want to change openvpn server setting so that all my traffic go out from IP 2.2.2.2

Below is my openvpn server config
--

Code: Select all

port 1723
proto udp
dev tun
ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/srv-01.crt
key /etc/openvpn/easy-rsa/keys/srv-01.key
dh /etc/openvpn/easy-rsa/keys/dh1024.pem
crl-verify /etc/openvpn/crl.pem
server 172.16.0.0 255.255.255.0
push "dhcp-option DNS 208.67.222.222"
push "route 10.10.10.0 255.255.255.0"
push "redirect-gateway def1"
ifconfig-pool-persist ipp.txt
keepalive 10 120
comp-lzo
user nobody
group users
persist-key
persist-tun
status openvpn-status.log
verb 3
client-to-client
duplicate-cn # (this means several users can use the same key)
# tell the OpenVPN server to validate the username/password
# entered by clients using the login PAM module
plugin /usr/share/openvpn/plugin/lib/openvpn-auth-pam.so /etc/pam.d/login
--

I am running centos 5.5, openvpn 2.1.4
Is this possible? any hints?

Thanks!

Re: change out IP

Posted: Fri Feb 11, 2011 3:36 pm
by janjust
this has little to do with openvpn and more with routing...
yes this is possible: what you want is a routing policy stating that all traffic with source IP 172.16.0.0/16 going to 0.0.0.0 needs to go out the interface with address 2.2.2.2 ; read up on LARTC for details.

Something like

Code: Select all

  ip route add to default table 100 dev eth1 via 2.2.2.2
  ip rule add from 172.16.0.0 priority 50 table 100
  ip rule add to 172.16.0.0 priority 50 table 100
HTH,

JJK

Re: change out IP

Posted: Fri Feb 11, 2011 3:38 pm
by yunusyb
Thanks a lot, I will try this.