change out IP

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
yunusyb
OpenVpn Newbie
Posts: 2
Joined: Fri Feb 11, 2011 3:19 pm

change out IP

Post by yunusyb » Fri Feb 11, 2011 3:30 pm

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!

User avatar
janjust
Forum Team
Posts: 2703
Joined: Fri Aug 20, 2010 2:57 pm
Location: Amsterdam
Contact:

Re: change out IP

Post by janjust » Fri Feb 11, 2011 3:36 pm

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

yunusyb
OpenVpn Newbie
Posts: 2
Joined: Fri Feb 11, 2011 3:19 pm

Re: change out IP

Post by yunusyb » Fri Feb 11, 2011 3:38 pm

Thanks a lot, I will try this.

Post Reply