版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 (作者:张华 发表于:2019-04-30)

移动宽带没有公网IP, 除了采用ssh正向代理可以经vps访问家里机器外, 也可以可用frp内网穿透实现.

# server side
wget https://github.com/fatedier/frp/releases/download/v0.27.0/frp_0.27.0_linux_amd64.tar.gz
sudo cp frps /usr/bin/ && sudo cp frps.ini /etc/frp/
sudo bash -c 'cat > /etc/frp/frps.ini ' << EOF
root@OneCloud:~# cat /etc/frp/frps.ini 
[common]
max_pool_count = 5
bind_port = 7000
kcp_bind_port = 7001
privilege_token = 'password'
tcp_mux = true
dashboard_port = 7500
dashboard_user = admin
dashboard_pwd = admin
EOF
sudo /usr/bin/frps -c /etc/frps.ini
sudo cp systemd/frps.service /lib/systemd/system/
sudo systemctl enable frps.service
sudo systemctl restart frps.service

#cliet side
wget https://github.com/fatedier/frp/releases/download/v0.27.0/frp_0.27.0_linux_amd64.tar.gz
sudo cp frpc /usr/bin/ && sudo cp frpc.ini /etc/frp/
sudo bash -c 'cat > /etc/frp/frpc.ini ' << EOF
[common]
server_addr = quqi99.publicvm.com
server_port = 7000
privilege_token = 'password'
log_file = /var/log/frpc.log
use_encryption = true
use_compression = true

[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 2223

[socks5]
type = tcp
remote_port =7071
plugin = socks5
EOF
sudo /usr/bin/frpc -c /etc/frpc.ini
sudo cp systemd/frpc.service /lib/systemd/system/
sudo systemctl enable frpc.service
sudo systemctl restart frpc.service

或是openwrt则:
root@openwrt:~# cat /etc/init.d/ss 
#!/bin/sh /etc/rc.common
#ln -s /etc/init.d/ss /etc/rc.d/S99ss
START=99

start() {
  /usr/bin/ssclient &
}

stop() {
  /usr/bin/killall ssclient
  #/bin/ps |grep ssclient |grep -v grep |awk '{print $1}' |xargs kill -9
}

ssh hua@vps -p 2222 -v
dig @vps -p 5353 google.com
#env ALL_PROXY=socks5h://quqi:password@vps:7070 curl https://www.google.com --verbose

注: 如果安装frps的机器也有向外提供服务的需求,那继续在frps所在机器运行frpc即可。

ssh root@127.0.0.1 -p2223  #on proxy machine                                    
ssh -L 80:127.0.0.1:80 root@127.0.0.1 -p2223 -g -N -C -o TCPKeepAlive=yes  #on proxy machine


# reference
# https://diannaobos.com/post/612.html
# https://www.cnblogs.com/sanduzxcvbnm/p/8508741.html
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐