I need your help for the following problem:

I have a CentOS server with 3 nics:

eth0:   IP ADDRESS= /24
        GW =

eth1:   IP ADDRESS= /24
        GW =

on is a router for exit on Internet.

All ok with routing here. I add another nik connected to a router ( where is a VPN configured:

eth2:   IP ADDRESS= /24
        no gateway defined because I get network nonfunctional if I put one.

On that router I have a connection to the network.

I want to route and on eth1 to be accessible from my LAN (I use as gateway

How could I do that?


You have to add route on your server to to VPN router, which IP you did not mentioner. Lets call it And then you have 2 options:

  1. to put routes on your VPN router to all networks, that you want to reach, that you use in local lan. Like:
    • ->
    • ->
  2. other option to NAT and networks on, if you can not change your VPN router config. Downside of this config, that you will be able to access LAN -> VPN, but not VPN -> LAN.
| improve this answer | |
  • Thank you, I forgot to write the VPN router IP: is correct: I make a NAT for eth2 and add a route for and all work. Thank you. – adi3000 Aug 12 '14 at 12:53

To write the final solution:

iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE
iptables -A FORWARD -i eth2 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth1 -o eth2 -j ACCEPT

echo > /etc/sysconfig/network-scripts/route-eth2
nano /etc/sysconfig/network-scripts/route-eth2

and enter:


all done. final: from LAN I can access network and network. Reverse (VPN->LAN I don't need)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.