Skip to content

Instantly share code, notes, and snippets.

@imWildCat
Created May 9, 2021 01:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imWildCat/f1b2e38215d967f365d86db6db900956 to your computer and use it in GitHub Desktop.
Save imWildCat/f1b2e38215d967f365d86db6db900956 to your computer and use it in GitHub Desktop.
config openvpn 'myvpn'
option dev 'tun'
option topology 'subnet' # This is important
option comp_lzo 'adaptive'
option ca '/etc/openvpn/ca.crt'
option dh '/etc/openvpn/dh.pem'
option cert '/etc/openvpn/server.crt'
option key '/etc/openvpn/server.key'
option persist_key '1'
option persist_tun '1'
option user 'nobody'
option group 'nogroup'
option max_clients '10'
option keepalive '10 120'
option verb '3'
option status '/var/log/openvpn_status.log'
option push 'dhcp-option DNS 192.168.1.2' # Push your gateway (旁路由) IP address
option client_connect '/etc/openvpn/push_routing_rule' # Must push this rule
option script_security '2'
option log '/var/log/openvpn_multiple_client.log'
option proto 'udp4'
option port '12345' # your openvpn port. Remember to add a port forwarding rule on your main router
option ddns '[your_ddns_domain]' # If not set, you could also use your public IP
option server '10.0.2.0 255.255.255.0'
option mssfix '1420'
option client_to_client '1'
option enabled '1'
option duplicate_cn # allow multiple-clients (can be turned off)
#!/bin/sh
echo push \"route-delay 10\" > $1
echo push \"route 192.168.1.0 255.255.255.0 $ifconfig_pool_local_ip\" >> $1
echo push \"route 10.0.2.0 255.255.255.0 $ifconfig_pool_local_ip\" >> $1
echo push \"redirect-gateway def1\" >> $1
# Note:
# `192.168.1.0` is the IP range of the DHCP service on your main router
# `10.0.2.0` is the IP range of your OpenVPN service
# Please adjust the above two IP addresses
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment