Skip to content

Instantly share code, notes, and snippets.

@zhanghai
Last active November 24, 2019 10:34
Show Gist options
  • Save zhanghai/59c3a9a8d781639472e3ad6998b903c4 to your computer and use it in GitHub Desktop.
Save zhanghai/59c3a9a8d781639472e3ad6998b903c4 to your computer and use it in GitHub Desktop.
浙江大学 VPN 及 ZJUWLAN 网络配置
  1. 检查是否已有 ~/bin 目录(~ 即是家目录)。如果没有:   0. 创建目录:mkdir ~/bin。   1. 编辑 ~/.bashrc,加入 export PATH="$HOME/bin:$PATH"。   2. 退出终端并重新打开以使新的 ~/.bashrc 生效(或者执行 source ~/.bashrc)。

ZJUVPN

  1. 下载 https://github.com/DreaminginCodeZH/zju-net-utils/raw/master/src/zjuvpn.sh~/bin/zjuvpn(不带扩展名,用起来方便),并使用 chmod +x ~/bin/zjuvpn 添加可执行权限。
  2. 安装 xl2tpd:sudo pacman -S xl2tpd
  3. 配置 ppp:   1. 编辑 chap-secrets(内容见同 gist 文件)并编辑学号密码sudo gedit /etc/ppp/chap-secrets。   2. 创建 zjuvpn.l2tpd(内容见同 gist 文件):sudo gedit /etc/ppp/peers/zjuvpn.l2tpd
  4. 配置 xl2tpd:   1. 创建 xl2tpd.conf(内容见同 gist 文件)并编辑学号sudo gedit /etc/xl2tpd/xl2tpd.conf
  5. 执行 zjuvpn ,庆祝或者疑惑。

ZJUWLAN

  1. 下载同 gist 文件 zjuwlan-login.sh~/bin/zjuwlan-login(不带扩展名,用起来方便),并使用 chmod +x ~/bin/zjuwlan-login 添加可执行权限。
  2. 创建 zjuwlan-login.conf(内容见同 gist 文件)并编辑学号密码gedit ~/bin/zjuwlan-login.conf
  3. 连接 ZJUWLAN,执行 zjuwlan-login,庆祝或者疑惑。
# Secrets for authentication using CHAP
# client server secret IP addresses
学号 * 密码 *
[global]
access control = no
auth file = /etc/ppp/chap-secrets
debug avp = no
debug network = no
debug packet = no
debug state = no
debug tunnel = no
[lac zjuvpn]
lns = 10.5.1.7
name = 学号
ppp debug = yes
pppoptfile = /etc/ppp/peers/zjuvpn.l2tpd
redial = yes
redial timeout = 15
require authentication = yes
require chap = yes
require pap = no
max redials = 10
noauth
proxyarp
USERNAME='学号'
PASSWORD='密码'
#!/bin/bash
source "$(basename "$0").conf"
echo 'Logging in...'
response=$(curl 'http://net.zju.edu.cn/include/auth_action.php' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Referer: https://net.zju.edu.cn/srun_portal_phone.php?url=http://www.zju.edu.cn/&ac_id=3' -d "action=login&username=${USERNAME}&password=${PASSWORD}&ac_id=3&save_me=0&ajax=1" -s)
if [[ "${response}" = *'login_ok'* ]]; then
echo 'Login successful.'
else
echo "${response}"
exit 1
fi
@jahentao
Copy link

庆祝哦!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment