{"action":"created","issue":{"url":"https://api.github.com/repos/wangyu-/tinyFecVPN/issues/31","repository_url":"https://api.github.com/repos/wangyu-/tinyFecVPN","labels_url":"https://api.github.com/repos/wangyu-/tinyFecVPN/issues/31/labels{/name}","comments_url":"https://api.github.com/repos/wangyu-/tinyFecVPN/issues/31/comments","events_url":"https://api.github.com/repos/wangyu-/tinyFecVPN/issues/31/events","html_url":"https://github.com/wangyu-/tinyFecVPN/issues/31","id":282419242,"number":31,"title":"一个使用方法的讨论","user":{"login":"wwqgtxx","id":582584,"avatar_url":"https://avatars0.githubusercontent.com/u/582584?v=4","gravatar_id":"","url":"https://api.github.com/users/wwqgtxx","html_url":"https://github.com/wwqgtxx","followers_url":"https://api.github.com/users/wwqgtxx/followers","following_url":"https://api.github.com/users/wwqgtxx/following{/other_user}","gists_url":"https://api.github.com/users/wwqgtxx/gists{/gist_id}","starred_url":"https://api.github.com/users/wwqgtxx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wwqgtxx/subscriptions","organizations_url":"https://api.github.com/users/wwqgtxx/orgs","repos_url":"https://api.github.com/users/wwqgtxx/repos","events_url":"https://api.github.com/users/wwqgtxx/events{/privacy}","received_events_url":"https://api.github.com/users/wwqgtxx/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-12-15T12:55:45Z","updated_at":"2017-12-21T15:15:46Z","closed_at":null,"author_association":"NONE","body":"请问一下当前版本的tinyFecVPN有办法支持把client在自身所在的局域网完全模拟成server么，即向client自己的所有端口所发送的数据（tcp,udp或者说所有Ip包）都会自动发送到server，这样实现彻底的透明代理\r\n看了一下wiki文档\r\nhttps://github.com/wangyu-/tinyFecVPN/wiki/tinyFecVPN%E8%BF%90%E8%A1%8C%E5%9C%A8%E8%99%9A%E6%8B%9F%E6%9C%BA%E4%B8%AD%EF%BC%8C%E5%8A%A0%E9%80%9Fwindows%E5%92%8C%E5%B1%80%E5%9F%9F%E7%BD%91%E5%86%85%E5%85%B6%E4%BB%96%E4%B8%BB%E6%9C%BA%E7%9A%84%E7%BD%91%E7%BB%9C\r\n不过这篇文章说的是把client配置成一个网关，这样还要在别的机器进行设置，能不能增加一篇教程实现上述提到的功能呢\r\n\r\n其实就是为了在局域网中用client完全替代server的存在，访问client就相当于访问了server，这样在这个局域网中直接访问这台client就能加速所有到server的链接，也能避免更改其他机器的网关，以及自己编译无限制的tinyFecVPN server端的问题"},"comment":{"url":"https://api.github.com/repos/wangyu-/tinyFecVPN/issues/comments/353375904","html_url":"https://github.com/wangyu-/tinyFecVPN/issues/31#issuecomment-353375904","issue_url":"https://api.github.com/repos/wangyu-/tinyFecVPN/issues/31","id":353375904,"user":{"login":"wwqgtxx","id":582584,"avatar_url":"https://avatars0.githubusercontent.com/u/582584?v=4","gravatar_id":"","url":"https://api.github.com/users/wwqgtxx","html_url":"https://github.com/wwqgtxx","followers_url":"https://api.github.com/users/wwqgtxx/followers","following_url":"https://api.github.com/users/wwqgtxx/following{/other_user}","gists_url":"https://api.github.com/users/wwqgtxx/gists{/gist_id}","starred_url":"https://api.github.com/users/wwqgtxx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wwqgtxx/subscriptions","organizations_url":"https://api.github.com/users/wwqgtxx/orgs","repos_url":"https://api.github.com/users/wwqgtxx/repos","events_url":"https://api.github.com/users/wwqgtxx/events{/privacy}","received_events_url":"https://api.github.com/users/wwqgtxx/received_events","type":"User","site_admin":false},"created_at":"2017-12-21T15:15:46Z","updated_at":"2017-12-21T15:15:46Z","author_association":"NONE","body":"经过实际测试，得出下面方法可行\r\nserver_start.sh:\r\n```bash\r\n#!/bin/sh\r\nmy_ip=$(ip -f inet address show tun100| grep -oE '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3} '| grep -oE '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}')\r\nthat_ip=$(ip -f inet address show tun100| grep -oE '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}/32'| grep -oE '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}')\r\necho \"1\"> /proc/sys/net/ipv4/ip_forward\r\niptables -t nat -A PREROUTING -i ens33 -p tcp -m tcp --dport 1:21 -j DNAT --to-destination $that_ip:1-21\r\niptables -t nat -A PREROUTING -i ens33 -p tcp -m tcp --dport 23:65535 -j DNAT --to-destination $that_ip:23-65535\r\niptables -t nat -A PREROUTING -i ens33 -p udp -m udp --dport 1:4095 -j DNAT --to-destination $that_ip:1-4095\r\niptables -t nat -A PREROUTING -i ens33 -p udp -m udp --dport 4097:65535 -j DNAT --to-destination $that_ip:4097-65535\r\niptables -t nat -A POSTROUTING -o tun100 -p tcp -m tcp --dport 1:21 -d $that_ip -j SNAT --to $my_ip\r\niptables -t nat -A POSTROUTING -o tun100 -p tcp -m tcp --dport 23:65535 -d $that_ip -j SNAT --to $my_ip\r\niptables -t nat -A POSTROUTING -o tun100 -p udp -m udp --dport 1:4095 -d $that_ip -j SNAT --to $my_ip\r\niptables -t nat -A POSTROUTING -o tun100 -p udp -m udp --dport 4097:65535 -d $that_ip -j SNAT --to $my_ip\r\n```\r\nserver_stop.sh\r\n```\r\n#!/bin/sh\r\nmy_ip=$(ip -f inet address show tun100| grep -oE '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3} '| grep -oE '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}')\r\nthat_ip=$(ip -f inet address show tun100| grep -oE '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}/32'| grep -oE '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}')\r\niptables -t nat -D PREROUTING -i ens33 -p tcp -m tcp --dport 1:21 -j DNAT --to-destination $that_ip:1-21\r\niptables -t nat -D PREROUTING -i ens33 -p tcp -m tcp --dport 23:65535 -j DNAT --to-destination $that_ip:23-65535\r\niptables -t nat -D PREROUTING -i ens33 -p udp -m udp --dport 1:4095 -j DNAT --to-destination $that_ip:1-4095\r\niptables -t nat -D PREROUTING -i ens33 -p udp -m udp --dport 4097:65535 -j DNAT --to-destination $that_ip:4097-65535\r\niptables -t nat -D POSTROUTING -o tun100 -p tcp -m tcp --dport 1:21 -d $that_ip -j SNAT --to $my_ip\r\niptables -t nat -D POSTROUTING -o tun100 -p tcp -m tcp --dport 23:65535 -d $that_ip -j SNAT --to $my_ip\r\niptables -t nat -D POSTROUTING -o tun100 -p udp -m udp --dport 1:4095 -d $that_ip -j SNAT --to $my_ip\r\niptables -t nat -D POSTROUTING -o tun100 -p udp -m udp --dport 4097:65535 -d $that_ip -j SNAT --to $my_ip\r\n```\r\ntinyvpn_s.service\r\n```\r\n[Unit]\r\nDescription=tinyvpn_s\r\nAfter=network-online.target\r\nWants=network.target\r\n\r\n[Service]\r\nType=simple\r\nLimitNOFILE=32768\r\nExecStartPre=/sbin/ip tuntap del tun100 mode tun\r\nExecStartPre=/sbin/ip tuntap add tun100 mode tun\r\nExecStartPre=/sbin/ifconfig tun100 up\r\nExecStartPre=/bin/chmod +x /tunnel/server_start.sh\r\nExecStartPre=/bin/chmod +x /tunnel/server_stop.sh\r\nExecStartPre=/bin/chmod +x /tunnel/tinyvpn\r\nExecStartPost=/tunnel/server_start.sh\r\nExecStart=/tunnel/tinyvpn -s -l0.0.0.0:4096 -f20:10 -k \"passwd\" --sub-net 11.22.22.0 --tun-dev tun100 --disable-fec\r\nExecStopPost=/tunnel/server_stop.sh\r\nRestart=on-failure\r\nRestartSec=1s\r\nStartLimitBurst=0\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n\r\n```\r\nclient_start.sh\r\n```bash\r\n#!/bin/sh\r\nmy_ip=$(ip -f inet address show ens33| grep -oE '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}/24'| grep -oE '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}')\r\necho \"1\"> /proc/sys/net/ipv4/ip_forward\r\niptables -t nat -A PREROUTING -i tun100 -p tcp -m tcp --dport 1:65535 -j DNAT --to-destination 192.168.31.1:1-65535\r\niptables -t nat -A PREROUTING -i tun100 -p udp -m udp --dport 1:65535 -j DNAT --to-destination 192.168.31.1:1-65535\r\niptables -t nat -A POSTROUTING -o ens33 -p tcp -m tcp --dport 1:65535 -d 192.168.31.1 -j SNAT --to $my_ip\r\niptables -t nat -A POSTROUTING -o ens33 -p udp -m udp --dport 1:65535 -d 192.168.31.1 -j SNAT --to $my_ip\r\nping 11.22.22.1  >/dev/null 2>&1 &\r\n/tunnel/tinyvpn -c -r10.10.16.27:4096 -f20:10 -k \"passwd\" --sub-net 11.22.22.0 --tun-dev tun100 --keep-reconnect --disable-fec\r\n```\r\nclient_stop.sh\r\n```bash\r\n#!/bin/sh\r\nmy_ip=$(ip -f inet address show ens33| grep -oE '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}/24'| grep -oE '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}')\r\niptables -t nat -D PREROUTING -i tun100 -p tcp -m tcp --dport 1:65535 -j DNAT --to-destination 192.168.31.1:1-65535\r\niptables -t nat -D PREROUTING -i tun100 -p udp -m udp --dport 1:65535 -j DNAT --to-destination 192.168.31.1:1-65535\r\niptables -t nat -D POSTROUTING -o ens33 -p tcp -m tcp --dport 1:65535 -d 192.168.31.1 -j SNAT --to $my_ip\r\niptables -t nat -D POSTROUTING -o ens33 -p udp -m udp --dport 1:65535 -d 192.168.31.1 -j SNAT --to $my_ip\r\n```\r\ntinyvpn_c.service\r\n```\r\n[Unit]\r\nDescription=tinyvpn_c\r\nAfter=network-online.target\r\nWants=network.target\r\n\r\n[Service]\r\nType=simple\r\nLimitNOFILE=32768\r\nExecStartPre=/sbin/ip tuntap del tun100 mode tun\r\nExecStartPre=/sbin/ip tuntap add tun100 mode tun\r\nExecStartPre=/sbin/ifconfig tun100 up\r\nExecStartPre=/bin/chmod +x /tunnel/client_start.sh\r\nExecStartPre=/bin/chmod +x /tunnel/client_stop.sh\r\nExecStartPre=/bin/chmod +x /tunnel/tinyvpn\r\nExecStart=/tunnel/client_start.sh\r\nExecStopPost=/tunnel/client_stop.sh\r\nRestart=on-failure\r\nRestartSec=1s\r\nStartLimitBurst=0\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n\r\n```\r\n\r\n这个例子实现了把客户端的局域网内的192.168.31.1这台主机映射到服务器的所有端口上（跳过了udp4096和tcp22端口）"}}
{"actor":{"display_login":"wwqgtxx"}}