GithubHelp home page GithubHelp logo

tinyvpn's Introduction

TinyVPN

一个用来学习的简易vpn,使用tun设备实现

安装

TinyVPN使用了gflags第三方库,使用cmake编译

使用cmake外部编译即可

cd TinyVPN
mkdir build
cd build
cmake ..
make

二进制文件在build/bin目录下

使用

客户端

  1. 启动client
$ sudo ./client --srv_port <服务端端口> --srv_addr <服务端IP>
  1. 添加路由
$ sudo ip route add default dev <tun设备名>
$ sudo ip route add <服务端IP> via <网关>

tun设备名一般为tun0,服务端IP和启动client时的服务端IP是一样的。 网关查询可以使用route -n

服务端

  1. 启动server
$ sudo ./server --port <端口> --tun_addr <tun设备IP>
  1. 添加SNAT
$ iptables -t nat -A POSTROUTING -s <tun设备子网>-o eth0 -j SNAT --to-source <出口ip(例如eth0的ip)>
  1. 打开路由功能
$ echo "1" > /proc/sys/net/ipv4/ip_forward

tinyvpn's People

Contributors

dmlfor avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.