| 41 | |
| 42 | == Note on another way to do it == |
| 43 | When I read the above write-up it taught me another way to achieve a goal that I already knew how to solve.[[BR]] |
| 44 | The problem is when a server that has services listening on the internet, and then runs openvpn with redirect-gateway, the server loses its ability to host its services on its physical interface. Packets get to the service, but the servers response gets routed over the VPN and lost. A clear difference between those return packets and packets generated from the server is the source address. When the IP on the physical device is contacted, it will reply with the IP from the physical device as its source. When the server is generating traffic it will have the source IP of the device that you route through, so the VPN device.[[BR]] |
| 45 | If we assume the servers physical device is 10.0.0.2 and its gateway is 10.0.0.1 then the following commands should solve the problem: |
| 46 | |
| 47 | {{{ |
| 48 | ip route add default via 10.0.0.1 table 10 |
| 49 | ip rule add from 10.0.0.2 table 10 |
| 50 | }}} |
| 51 | |
| 52 | The first command adds a second routing table (table 10) with the normal default route (the one the server uses without a vpn)[[BR]] |
| 53 | The second command tells the server to route any packets with src 10.0.0.2 out of the table that we just made (table 10 in our case) |