0

I installed OpenVPN client on the OpenWRT and want to direct all my traffic through the VPN, including the game traffic.

But the server side didn't push the route to the client side. How can I achieve this by setting up in the OpenWRT using ip route and ip rule command?

--update-- Accutually, openwrt is just a virtual machine, I deployed it on the VirtualBox. All traffic from the host machine will flow through the virtual machine. I read some articles about how to using ip route to static route the traffic but still don't know what ip address I need to use to replace the address part of the ip route add and ip rule add rule.

3
  • 2
    Why did you include someone else's ifconfig output? (Why do you think ifconfig output is relevant to your question?) What have you tried so far? What is the (specific) problem you have with using ip route?
    – sebasth
    Commented Oct 24, 2017 at 9:03
  • @sebasth Accutually, the 'openwrt' is just a virtual machine, I deployed it on the virtualbox. All traffic from the host machine will flow through the virtual machine. I didn't configure my own client yet so I copy and pasted the output of another person. You need to type some address of the interface when using ip route, so I think i should put the ifconfig output here. I read some articles about how to using ip route to static route the traffic but still don't know how to use it onto the openvpn. Commented Oct 24, 2017 at 9:40
  • @sebasth I don't know what ip address i need to use to replace the address part of the 'ip route add' and 'ip rule add' rule. Commented Oct 24, 2017 at 9:49

3 Answers 3

1

If you want to route all traffic from your router via your VPN, just configure the default route via OpenVPN. Remember to configure a route (if it isn't automatically configured) to the external IP of the OpenVPN server via your internet gateway.

ip route add <openvpn server external ip> via <default internet gateway>
ip route change default via <openvpn gateway (internal) ip>

If you want to apply different routing depending on where the traffic originates (or some other criteria), you need to use a separate routing table and create rules when to use it.

For example, with the new table identified by 10:

ip route add default via <openvpn gateway (internal) ip> table 10
ip rule add from <your network (address+netmask)> table 10
ip route flush cache

You do not need to alter routes in main routing table when you use a separate routing table.

Your OpenVPN server does not automatically know the routes to hosts in your network. You either need to configure such routes or use NAT on your OpenVPN client.

1

I assume we're talking IPv4 here? If this is your main router then it shouldn't be needed to supply any routes to the clients, under normal circumstances clients would already have the router set as their default route, so then the router (OpenWRT in this case) can easily sort out the rest of the traffic.

But to still answer the question: normally you can provide routing information to your clients through use of a DHCP server. It supplies the clients with an IP address, DNS (lookup) information and routing. Although most commonly this only applies to the previously mentioned default route, not an entire routing table.

1

you need to add to OpenVPN Server configuration:

push "redirect-gateway def1"

This will set 128.0.0.0 route via VPN server gateway and all traffic will start flow over it

The rest configuration with custom routes most likely not needed, as MASQUERADE for upstream and proper routes already set in OpenWRT

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .