文章

内网穿透

内网穿透

ZeroTier

用户手册 操作面板

server安装

  • Windows MSI Installer (x86/x64)
  • MacOS MacOS PKG Installer
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    
      # Get your ZeroTier address and check the service status
      sudo zerotier-cli status
    
      # Join, leave, and list networks
      sudo zerotier-cli join ################
      sudo zerotier-cli leave ################
      sudo zerotier-cli listnetworks
        
      # Stop and start the service with launchctl
      sudo launchctl unload /Library/LaunchDaemons/com.zerotier.one.plist
      sudo launchctl load /Library/LaunchDaemons/com.zerotier.one.plist
        
      # Cleanly uninstall ZeroTier One, preserving only your secret identity
      sudo "/Library/Application Support/ZeroTier/One/uninstall.sh"
    
  • Apple iOS App Store
  • Android Google Play Store
  • Linux (DEB/RPM)
    • rely on SSL to authenticate the site
      1
      
        curl -s https://install.zerotier.com | sudo bash
      
    • have GPG installed
      1
      2
      
        curl -s 'https://raw.githubusercontent.com/zerotier/ZeroTierOne/master/doc/contact%40zerotier.com.gpg' | gpg --import && \
        if z=$(curl -s 'https://install.zerotier.com/' | gpg); then echo "$z" | sudo bash; fi
      
    • Other Linux distributions building and installing from source
  • FreeBSD FreeBSD Package

加入网络

type zerotier-cli join ################ with ############### being the 16-digit network ID of the network 启动和开机自启动(systemctl的说明)

1
2
3
4
# sudo systemctl start zerotier-one.service # 启动某个服务
# sudo systemctl enable zerotier-one.service # 将某个服务设为开机自启动
sudo systemctl --now enable zerotier-one.service # 启动并开机自启动
sudo zerotier-cli listnetworks # 查看网络列表

problems:

  • 提示zerotier-cli: missing authentication token and authtoken.secret not found (or readable) in /var/lib/zerotier-one 解决chmod 755 /var/lib/zerotier-one/authtoken.secret
  • 每次join network都会新建新的网络端口, 增加网络数 解决 在计算机\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles中删除ProfileName以”网络”开头的条目 管理员运行PowerShell
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    
      Get-ChildItem 'HKLM:\Software\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles\' |
      ForEach-Object{
          $profilename = $_.GetValue('ProfileName')
          if($profilename.StartsWith("网络 ")){
              Write-Host "Removing item: $profilename" -ForegroundColor green
              Remove-Item $_.PSPath -Whatif
          }else{
              Write-Host "Skipping item:$profilename" -Fore blue -Back white
          }
      }
    

    端口转发

    ssh

    ssh命令

Squid

参考1, 2, 3, squid server linux在/etc/squid/squid.conf, mac在/usr/local/etc/squid.confhttp_access deny all改为http_access allow all后, service squid restart 在代理中设置端口为3128即可(mac的命令是brew services restart squid)

1
2
3
4
5
6
7
8
9
10
11
# Protect the original config file
sudo cp /etc/squid/squid.conf /etc/squid/squid.conf.original
sudo chmod a-w /etc/squid/squid.conf.original
# 启动
systemctl start squid.service
# 停止
systemctl stop squid.service
# 重启
systemctl restart squid.service
#设置开机自启
systemctl enable squid.service

mac系统的brew替换镜像源

VNC

  • 服务相关
    1
    2
    3
    
      vncserver -kill :1#关掉某个窗口
      vncserver :1#开启某个窗口
      vncserver start
    
  • 显示桌面 编辑 ~/.vnc/xstartup文件(ref)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    
      [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
      [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
      xsetroot -solid grey
      vncconfig -iconic &
      x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
      x-window-manager &
      #在最后添加
      gnome-panel &
      gnome-settings-daemon &
      metacity &
      nautilus &
    
本文由作者按照 CC BY 4.0 进行授权