You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
7.2 KiB

  1. # VPN Bypass
  2. A simple PROCD-based vpnbypass service for OpenWrt/LEDE Project. Useful if your router accesses internet thru VPN client/tunnel, but you want specific traffic (ports, IP ranges, domains or local IP ranges) to be routed outside of this tunnel.
  3. ## Features
  4. - Allows to define local ports so that traffic to them is routed outside of the VPN tunnel (by default routes Plex Media Server traffic (port 32400) outside of the VPN tunnel).
  5. - Allows to define IPs/subnets in local network so that their traffic is routed outside of the VPN tunnel (by default routes traffic from 192.168.1.81-192.168.1.87 outside of the VPN tunnel).
  6. - Allows to define remote IPs/ranges that they are accessed outside of the VPN tunnel (by default routes LogmeIn Hamachi traffic (25.0.0.0/8) outside of the VPN tunnel).
  7. - Allows to define list of domain names which are accessed outside of the VPN tunnel (useful for Netflix, Hulu, etc).
  8. - Doesn't stay in memory -- creates the iptables rules which are automatically updated on WAN up/down.
  9. - Has a companion package (luci-app-vpnbypass) so everything can be configured with Web UI.
  10. - Proudly made in Canada, using locally-sourced electrons.
  11. ## Screenshot (luci-app-vpnbypass)
  12. ![screenshot](https://raw.githubusercontent.com/stangri/screenshots/master/vpnbypass/screenshot02.png "screenshot")
  13. ## Requirements
  14. This service requires following packages to be installed on your router: ```ipset``` and ```iptables```. Additionally, if you want to use Domain Bypass feature, you need to install ```dnsmasq-full``` (```dnsmasq-full``` requires you uninstall ```dnsmasq``` first).
  15. To fully satisfy the requirements for both IP/Port VPN Bypass and Domain Bypass features connect to your router via ssh and run the following commands:
  16. ```sh
  17. opkg update; opkg remove dnsmasq; opkg install ipset iptables dnsmasq-full
  18. ```
  19. To satisfy the requirements for just IP/Port VPN Bypass connect to your router via ssh and run the following commands:
  20. ```sh
  21. opkg update; opkg install ipset iptables
  22. ```
  23. #### Unmet dependencies
  24. If you are running a development (trunk/snapshot) build of OpenWrt/LEDE Project on your router and your build is outdated (meaning that packages of the same revision/commit hash are no longer available and when you try to satisfy the [requirements](#requirements) you get errors), please flash either current LEDE release image or current development/snapshot image.
  25. ## How to install
  26. <!---
  27. #### From Web UI/Luci
  28. Navigate to System->Software page on your router and then perform the following actions:
  29. 1. Click "Update Lists"
  30. 2. Wait for the update process to finish.
  31. 3. In the "Download and install package:" field type ```vpnbypass luci-app-vpnbypass```
  32. 4. Click "OK" to install ```vpnbypass``` and ```luci-app-vpnbypass```
  33. If you get an ```Unknown package 'vpnbypass'``` error, your router is not set up with the access to repository containing these packages and you need to add custom repository to your router first.
  34. #### From console/ssh
  35. --->
  36. Please make sure that the [requirements](#requirements) are satisfied and install ```vpnbypass``` and ```luci-app-vpnbypass``` from Web UI or connect to your router via ssh and run the following commands:
  37. ```sh
  38. opkg update
  39. opkg install vpnbypass luci-app-vpnbypass
  40. ```
  41. If these packages are not found in the official feed/repo for your version of OpenWrt/LEDE Project, you will need to [add a custom repo to your router](#add-custom-repo-to-your-router) first.
  42. #### Add custom repo to your router
  43. If your router is not set up with the access to repository containing these packages you will need to add custom repository to your router by connecting to your router via ssh and running the following commands:
  44. ###### OpenWrt CC 15.05.1
  45. ```sh
  46. opkg update; opkg install wget libopenssl
  47. echo -e -n 'untrusted comment: public key 7ffc7517c4cc0c56\nRWR//HUXxMwMVnx7fESOKO7x8XoW4/dRidJPjt91hAAU2L59mYvHy0Fa\n' > /tmp/stangri-repo.pub && opkg-key add /tmp/stangri-repo.pub
  48. ! grep -q 'stangri_repo' /etc/opkg/customfeeds.conf && echo 'src/gz stangri_repo https://raw.githubusercontent.com/stangri/openwrt-repo/master' >> /etc/opkg/customfeeds.conf
  49. opkg update
  50. ```
  51. ###### LEDE Project and OpenWrt DD trunk
  52. ```sh
  53. opkg update; opkg install uclient-fetch libustream-mbedtls
  54. echo -e -n 'untrusted comment: public key 7ffc7517c4cc0c56\nRWR//HUXxMwMVnx7fESOKO7x8XoW4/dRidJPjt91hAAU2L59mYvHy0Fa\n' > /tmp/stangri-repo.pub && opkg-key add /tmp/stangri-repo.pub
  55. ! grep -q 'stangri_repo' /etc/opkg/customfeeds.conf && echo 'src/gz stangri_repo https://raw.githubusercontent.com/stangri/openwrt-repo/master' >> /etc/opkg/customfeeds.conf
  56. opkg update
  57. ```
  58. ## Default Settings
  59. Default configuration has service disabled (use Web UI to enable/start service or run ```uci set vpnbypass.config.enabled=1```) and routes Plex Media Server traffic (port 32400) outside of the VPN tunnel, routes LogmeIn Hamachi traffic (25.0.0.0/8) outside of the VPN tunnel and also routes internet traffic from local IPs 192.168.1.81-192.168.1.87 outside of the VPN tunnel. You can safely delete these example rules if they do not apply to you.
  60. ## Documentation / Discussion
  61. Please head to [LEDE Project Forum](https://forum.lede-project.org/t/vpn-bypass-split-tunneling-service-luci-ui/1106) for discussions of this service.
  62. #### Bypass Domains Format/Syntax
  63. Domain lists should be in following format/syntax: ```/domain1.com/domain2.com/vpnbypass```. Please don't forget the leading ```/``` and trailing ```/vpnbypass```. There's no validation if you enter something incorrectly -- it just won't work. Please see [Notes/Known Issues](#notesknown-issues) if you want to edit this setting manually, without Web UI.
  64. ## What's New
  65. 1.3.0
  66. - No longer depends on hardcoded WAN interface name (```wan```) works with other interface names (like ```wwan```).
  67. - Table ID, IPSET name and FW_MARK as well as FW_MASK can be defined in config file.
  68. - Uses iptables, not ip rules for handling local IPs/ranges.
  69. - More reliable creation/destruction of VPNBYPASS iptables chain.
  70. - Updated Web UI enables/start and stops service.
  71. - Beautified output.
  72. 1.2.0
  73. - More elegant handling of iptables (thanks [@hnyman](https://github.com/hnyman) and [@tohojo](https://github.com/tohojo)!).
  74. 1.1.1
  75. - More reliable way of obtaining WAN gateway on boot (thanks [@dibdot](https://github.com/dibdot) for the hint!).
  76. 1.1.0:
  77. - Detects individual IP addresses in the config and converts them to subnet automatically.
  78. - Proper implementation of reload on vpnbypass config change.
  79. 1.0.0:
  80. - Hotplug script created during install.
  81. 0.1.0:
  82. - Package built.
  83. - Support for user-defined ports implemented.
  84. - Support for user-defined routes implemented.
  85. - Support for user-defined local ranges implemented.
  86. 0.0.1:
  87. - Initial release.
  88. ## Notes/Known Issues
  89. 1. Domains to be accessed outside of VPN tunnel are handled by dnsmasq and thus are not defined in ```/etc/config/vpnpass```, but rather in ```/etc/config/dhcp```. To add/delete/edit domains you can use VPN Bypass Web UI or you can edit ```/etc/config/dhcp``` manually or run following commands:
  90. ```sh
  91. uci add_list dhcp.@dnsmasq[-1].ipset='/github.com/plex.tv/google.com/vpnbypass'
  92. uci add_list dhcp.@dnsmasq[-1].ipset='/hulu.com/netflix.com/nhl.com/vpnbypass'
  93. uci commit dhcp
  94. /etc/init.d/dnsmasq restart
  95. ```
  96. This feature requires ```dnsmasq-full``` to work. See [Requirements](#requirements) paragraph for more details.