Skip to content

Instantly share code, notes, and snippets.

@yan-foto
Last active January 5, 2020 22:25
Show Gist options
  • Save yan-foto/70107775cc609390de29 to your computer and use it in GitHub Desktop.
Save yan-foto/70107775cc609390de29 to your computer and use it in GitHub Desktop.
OpenWRT configurations to run OpenVPN client | Private Internet Access - https://www.privateinternetaccess.com

This gist contains all the OpenWRT configuraion files needed to connect to Private Internet Access (PIA) VPN servers. The following files are included:

  • network: contains configuration to add a virtual network device (i.e. tun1366) and custom DNS servers
  • openvpn: OpenVPN configuration file to connect to PIA VPN servers
  • firewall: firewall configuration which passes all traffic through VPN and rejects any request when OpenVPN is down

NOTE: there are a number of other files required to be available under /etc/openvpn for this approach to work:

  • pia.auth: VPN credentials in two lines, first the username and the second the password
  • pia.ca.crt: certificate authority file
  • pia.crl.pem: certificate revocation list

For PIA the last two files can be downloaded here: https://www.privateinternetaccess.com/openvpn/openvpn.zip

config defaults
option synflood_protect 1
option input ACCEPT
option output ACCEPT
option forward REJECT
config zone
option name lan
list network 'lan'
option input ACCEPT
option output ACCEPT
option forward REJECT
config zone
option name wan
list network 'wan'
list network 'wan6'
option input REJECT
option output ACCEPT
option forward REJECT
option masq 1
option mtu_fix 1
config zone
option name pia
option network 'pia'
option input REJECT
option output ACCEPT
option forward REJECT
option masq 1
option mtu_fix 1
# We need to accept udp packets on port 68,
# see https://dev.openwrt.org/ticket/4108
config rule
option name Allow-DHCP-Renew
option src wan
option proto udp
option dest_port 68
option target ACCEPT
option family ipv4
# Allow IPv4 ping
config rule
option name Allow-Ping
option src wan
option proto icmp
option icmp_type echo-request
option family ipv4
option target ACCEPT
config rule
option name Allow-IGMP
option src wan
option proto igmp
option family ipv4
option target ACCEPT
# Allow DHCPv6 replies
# see https://dev.openwrt.org/ticket/10381
config rule
option name Allow-DHCPv6
option src wan
option proto udp
option src_ip fe80::/10
option src_port 547
option dest_ip fe80::/10
option dest_port 546
option family ipv6
option target ACCEPT
config rule
option name Allow-MLD
option src wan
option proto icmp
option src_ip fe80::/10
list icmp_type '130/0'
list icmp_type '131/0'
list icmp_type '132/0'
list icmp_type '143/0'
option family ipv6
option target ACCEPT
# Allow essential incoming IPv6 ICMP traffic
config rule
option name Allow-ICMPv6-Input
option src wan
option proto icmp
list icmp_type echo-request
list icmp_type echo-reply
list icmp_type destination-unreachable
list icmp_type packet-too-big
list icmp_type time-exceeded
list icmp_type bad-header
list icmp_type unknown-header-type
list icmp_type router-solicitation
list icmp_type neighbour-solicitation
list icmp_type router-advertisement
list icmp_type neighbour-advertisement
option limit 1000/sec
option family ipv6
option target ACCEPT
# Allow essential forwarded IPv6 ICMP traffic
config rule
option name Allow-ICMPv6-Forward
option src wan
option dest *
option proto icmp
list icmp_type echo-request
list icmp_type echo-reply
list icmp_type destination-unreachable
list icmp_type packet-too-big
list icmp_type time-exceeded
list icmp_type bad-header
list icmp_type unknown-header-type
option limit 1000/sec
option family ipv6
option target ACCEPT
# include a file with users custom iptables rules
config include
option path /etc/firewall.user
# allow IPsec/ESP and ISAKMP passthrough
config rule
option src wan
option dest lan
option proto esp
option target ACCEPT
config rule
option src wan
option dest lan
option dest_port 500
option proto udp
option target ACCEPT
config forwarding
option src lan
option dest pia
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fd38:9c1e:b54f::/48'
config interface 'lan'
option ifname 'eth0.1'
option force_link '1'
option type 'bridge'
option proto 'static'
option ipaddr '192.168.2.1'
option netmask '255.255.255.0'
option ip6assign '60'
option peerdns '0'
list dns '209.222.18.218'
list dns '209.222.18.222'
config interface 'wan'
option ifname 'eth0.2'
option proto 'dhcp'
option peerdns '0'
config interface 'wan6'
option ifname 'eth0.2'
option proto 'dhcpv6'
option peerdns '0'
config switch
option name 'switch0'
option reset '1'
option enable_vlan '1'
config switch_vlan
option device 'switch0'
option vlan '1'
option ports '0t 2 3 4 5'
config switch_vlan
option device 'switch0'
option vlan '2'
option ports '0t 1'
# OpenVPN interface
config interface 'pia'
option ifname 'tun1366'
option proto 'none'
config openvpn 'PIA'
option enabled 1
# This is an OpenVPN client config
option client 1
# Interface
option dev tun1366
# Protocol: UDP
option proto udp
# Trying indefinitely to resolve server's host name
option resolve_retry infinite
# Dont't bind to a specific local port
option nobind 1
# Try to persist some data over restarts
option persist_key 1
option persist_tun 1
# SSL/TLS params
option ca /etc/openvpn/pia.ca.crt
option crl_verify /etc/openvpn/pia.crl.pem
option tls_client 1
# Enable compression
option comp_lzo yes
# Authentication file
option auth_user_pass /etc/openvpn/pia.auth
# Set lgging to verbose
option verb 3
# Remote servers
list remote "us-seattle.privateinternetaccess.com 1198"
list remote "hk.privateinternetaccess.com 1198"
list remote "uk-london.privateinternetaccess.com 1198"
list remote "ro.privateinternetaccess.com 1198"
list remote "nl.privateinternetaccess.com 1198"
list remote "us-texas.privateinternetaccess.com 1198"
list remote "in.privateinternetaccess.com 1198"
list remote "nz.privateinternetaccess.com 1198"
list remote "us-east.privateinternetaccess.com 1198"
list remote "ireland.privateinternetaccess.com 1198"
list remote "sweden.privateinternetaccess.com 1198"
list remote "japan.privateinternetaccess.com 1198"
list remote "ca.privateinternetaccess.com 1198"
list remote "denmark.privateinternetaccess.com 1198"
list remote "brazil.privateinternetaccess.com 1198"
list remote "germany.privateinternetaccess.com 1198"
list remote "aus.privateinternetaccess.com 1198"
list remote "us-california.privateinternetaccess.com 1198"
list remote "mexico.privateinternetaccess.com 1198"
list remote "us-siliconvalley.privateinternetaccess.com 1198"
list remote "us-midwest.privateinternetaccess.com 1198"
list remote "us-florida.privateinternetaccess.com 1198"
list remote "ca-toronto.privateinternetaccess.com 1198"
list remote "fi.privateinternetaccess.com 1198"
list remote "uk-southampton.privateinternetaccess.com 1198"
list remote "france.privateinternetaccess.com 1198"
list remote "israel.privateinternetaccess.com 1198"
list remote "us-newyorkcity.privateinternetaccess.com 1198"
list remote "us-west.privateinternetaccess.com 1198"
list remote "no.privateinternetaccess.com 1198"
list remote "italy.privateinternetaccess.com 1198"
list remote "turkey.privateinternetaccess.com 1198"
list remote "us-chicago.privateinternetaccess.com 1198"
list remote "sg.privateinternetaccess.com 1198"
list remote "swiss.privateinternetaccess.com 1198"
list remote "aus-melbourne.privateinternetaccess.com 1198"
@yan-foto
Copy link
Author

These files are to be copied under /etc/config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment