[关闭]
@natsumi 2016-06-14T14:25:42.000000Z 字数 4874 阅读 2852

linux下使用SoftEtherVPN 从入门到放弃

Linux


从14年开始开源,代码在这里
https://github.com/SoftEtherVPN/SoftEtherVPN

解压后扫了一眼readme,感觉和一般的软件差不多的编译安装方式我就直接上手装了。。。
先是./configure --prefix=/opt/softEtherVPN
意外的顺利~(图样图奶一捂啊!!!)
然后make就开始报错了~(看看configure的脚本根本什么都没做啊!指示让你选择了操作系统和cpu多少位)

首先是关于readline~非常容易解决~
ubuntu:sudo apt-get install libreadline-dev
centos应该是: yum install readline-devel

然后ncurses找不到
sudo apt-get install libncurses-dev

然后make完成了~

由于看过configure的脚本,什么都没做,那我们之前加的prefix选项当然也不会有效啊==

于是我们来看一看“生成”(其实src/makefiles下面有很多Makefile,项目根目录下的configure根据用户选的操作系统和cpu位数选择一个复制到项目根目录下作为实际使用的Makefile)的Makefile~

可以看到安装目录是直接写死在Makefile中的

  1. INSTALL_BINDIR=/usr/bin/
  2. INSTALL_VPNSERVER_DIR=/usr/vpnserver/
  3. INSTALL_VPNBRIDGE_DIR=/usr/vpnbridge/
  4. INSTALL_VPNCLIENT_DIR=/usr/vpnclient/
  5. INSTALL_VPNCMD_DIR=/usr/vpncmd/

另外看到Makefile的目标只有install,没有uninstall
哼!这不是耍流氓么==

所以为了卸载方便,修改安装路径

  1. INSTALL_BINDIR=/opt/softEtherVPN/bin/
  2. INSTALL_VPNSERVER_DIR=/opt/softEtherVPN/vpnserver/
  3. INSTALL_VPNBRIDGE_DIR=/opt/softEtherVPN/vpnbridge/
  4. INSTALL_VPNCLIENT_DIR=/opt/softEtherVPN/vpnclient/
  5. INSTALL_VPNCMD_DIR=/opt/softEtherVPN/vpncmd/

然后sudo make install,会出错~需要继续修改Makefile的install部分~大概是381-428行的部分

改动如下:

  • 由于变量INSTALL_BINDIR原来是一个存在的路径(/usr/bin),在makefile中没有mkdir,修改后需要加入@mkdir -p $(INSTALL_BINDIR),我加在了原makefile的394和395行之间
  • 将类似echo "#!/bin/sh" > $(INSTALL_BINDIR)vpnserver的语句中的双引号改为单引号。这是因为单引号告诉shell忽略所有特殊字符。在终端中直接运行这样的语句如echo "#!/bin/sh" > temp.txt也会报错bash: !/bin/sh: event not found

修改后的install部分如下:

  1. # Install
  2. install: $(INSTALL_BINDIR)vpnserver $(INSTALL_BINDIR)vpnbridge $(INSTALL_BINDIR)vpnclient $(INSTALL_BINDIR)vpncmd
  3. @echo
  4. @echo "--------------------------------------------------------------------"
  5. @echo "Installation completed successfully."
  6. @echo
  7. @echo "Execute 'vpnserver start' to run the SoftEther VPN Server background service."
  8. @echo "Execute 'vpnbridge start' to run the SoftEther VPN Bridge background service."
  9. @echo "Execute 'vpnclient start' to run the SoftEther VPN Client background service."
  10. @echo "Execute 'vpncmd' to run SoftEther VPN Command-Line Utility to configure VPN Server, VPN Bridge or VPN Client."
  11. @echo "--------------------------------------------------------------------"
  12. @echo
  13. $(INSTALL_BINDIR)vpnserver: bin/vpnserver/hamcore.se2 bin/vpnserver/vpnserver
  14. @mkdir -p $(INSTALL_BINDIR)
  15. @mkdir -p $(INSTALL_VPNSERVER_DIR)
  16. cp bin/vpnserver/hamcore.se2 $(INSTALL_VPNSERVER_DIR)hamcore.se2
  17. cp bin/vpnserver/vpnserver $(INSTALL_VPNSERVER_DIR)vpnserver
  18. echo '#!/bin/sh' > $(INSTALL_BINDIR)vpnserver
  19. echo $(INSTALL_VPNSERVER_DIR)vpnserver '"$$@"' >> $(INSTALL_BINDIR)vpnserver
  20. echo 'exit $$?' >> $(INSTALL_BINDIR)vpnserver
  21. chmod 755 $(INSTALL_BINDIR)vpnserver
  22. $(INSTALL_BINDIR)vpnbridge: bin/vpnbridge/hamcore.se2 bin/vpnbridge/vpnbridge
  23. @mkdir -p $(INSTALL_VPNBRIDGE_DIR)
  24. cp bin/vpnbridge/hamcore.se2 $(INSTALL_VPNBRIDGE_DIR)hamcore.se2
  25. cp bin/vpnbridge/vpnbridge $(INSTALL_VPNBRIDGE_DIR)vpnbridge
  26. echo '#!/bin/sh' > $(INSTALL_BINDIR)vpnbridge
  27. echo $(INSTALL_VPNBRIDGE_DIR)vpnbridge '"$$@"' >> $(INSTALL_BINDIR)vpnbridge
  28. echo 'exit $$?' >> $(INSTALL_BINDIR)vpnbridge
  29. chmod 755 $(INSTALL_BINDIR)vpnbridge
  30. $(INSTALL_BINDIR)vpnclient: bin/vpnclient/hamcore.se2 bin/vpnclient/vpnclient
  31. @mkdir -p $(INSTALL_VPNCLIENT_DIR)
  32. cp bin/vpnclient/hamcore.se2 $(INSTALL_VPNCLIENT_DIR)hamcore.se2
  33. cp bin/vpnclient/vpnclient $(INSTALL_VPNCLIENT_DIR)vpnclient
  34. echo '#!/bin/sh' > $(INSTALL_BINDIR)vpnclient
  35. echo $(INSTALL_VPNCLIENT_DIR)vpnclient '"$$@"' >> $(INSTALL_BINDIR)vpnclient
  36. echo 'exit $$?' >> $(INSTALL_BINDIR)vpnclient
  37. chmod 755 $(INSTALL_BINDIR)vpnclient
  38. $(INSTALL_BINDIR)vpncmd: bin/vpncmd/hamcore.se2 bin/vpncmd/vpncmd
  39. @mkdir -p $(INSTALL_VPNCMD_DIR)
  40. cp bin/vpncmd/hamcore.se2 $(INSTALL_VPNCMD_DIR)hamcore.se2
  41. cp bin/vpncmd/vpncmd $(INSTALL_VPNCMD_DIR)vpncmd
  42. echo '#!/bin/sh' > $(INSTALL_BINDIR)vpncmd
  43. echo $(INSTALL_VPNCMD_DIR)vpncmd '"$$@"' >> $(INSTALL_BINDIR)vpncmd
  44. echo 'exit $$?' >> $(INSTALL_BINDIR)vpncmd
  45. chmod 755 $(INSTALL_BINDIR)vpncmd

安装完成后会出现下面的提示

由于我们修改了安装路径,要想在任意目录下能执行这些命令,先把/opt/softEtherVPN/bin/加到PATH环境变量中。这里我还是简单粗暴改直接改/etc/profile。

然后迫不及待的试了一下vpnclient start命令
但是又报错了

  1. -- Alert: SoftEther VPN Kernel --
  2. Fatal Error: The file "hamcore.se2" is missing or broken.
  3. Please check hamcore.se2.
  4. (First, reboot the computer. If this problem occurs again, please reinstall VPN software files.)

看了这个我还真的重启了一下==
然后还是出错,这个真的不是reinstall能解决的好嘛!
咱不会不能瞎支招儿啊==
看看/opt/softEtherVPN/vpnclient目录下,hamcore.se2文件是存在的~难道真的是broken了?并没有!
其实是因为运行没有用root用户,而这个文件没有读权限,就sudo chmod -R +r .,问题解决了

  1. -- Alert: SoftEther VPN Kernel --
  2. Unable to create /opt/softEtherVPN/vpnclient/.VPN-41056876FF.

opt目录下没有写权限。。还是直接切换到root运行。。总算正常了。。

怎么用呢?参考这个http://www.cnblogs.com/zungmou/p/linux-softether.html
这个软件的windows版是提供公共中继服务器地址的呀==
linux下好像没有装VGate这个组件啊
于是sudo rm -rf /opt/softEtherVPN

最后,贴一下src目录下的configure~莫名喜感~

  1. #!/bin/sh
  2. echo 'Move to the parent directory and run ./configure script as following:'
  3. echo
  4. echo '$ cd ..'
  5. echo '$ ./configure'
  6. echo
  7. echo 'Good luck!'
  8. echo
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注