搭建LookingGlass 随时监测服务器回程线路

搭建LookingGlass 随时监测服务器回程线路

检测服务器的回程线路,是每个VPS玩家的必备技能。检测方法通常都是SSH连接上VPS后使用traceroute命令或者mtr命令,或者安装ipip的besttrace查看回程,还能查看回程IP的运营商和归属地。

但是,每次测试回程都要连接SSH服务器,而且还要提前获取自己的IP,才能进行路由追踪,很麻烦。比如,你到你朋友家,网速很慢,你想看看回程路由,还要连接SSH...那就更麻烦了。有没有一个工具能快速查看回程线路呢?

有,那就是LookingGlass。一般搞IDC的商家会提供LookingGlass,但也有很多不提供,或者官方的线路跟自己的线路有细微的差别。好在自己搭建LookingGlass并不难,注意避坑就可以了。

准备

LookingGlass(修改版)源代码:https://github.com/ILLKX/LookingGlass/

LookingGlass源代码:https://github.com/telephone/LookingGlass

建议使用修改版,修改版增加了对PHP7的支持;traceroute使用的是ipip的besttrace,相较于原版,能查看回程IP的运营商和归属地。

默认已经安装了HTTP服务端(Nginx、Apache等) PHP 安装这些也很简单,有lnmp oneinstack等,相关教程很多,在此就不赘述了。

安装过程

  1. 下载LookingGlass源代码到服务器,建议下载到网站目录中,就不用移动了wget https://github.com/ILLKX/LookingGlass/archive/master.zip
  2. 解压 unzip master.zip
  3. 修改文件夹名称 mv LookingGlass-master lg
  4. 进行安装:bash lg/LookingGlass/configure.sh
  5. 按照提示进行安装:
########################################
#
# LookingGlass is a user-friendly script
# to create a functional Looking Glass
# for your network.
#
# Created by Nick Adams (telephone)
# http://iamtelephone.com
#
########################################

Do you wish to install LookingGlass? (y/n): y

###              ###
# Starting install #
###              ###

#这一步是检查相关依赖是否安装 没有安装的话会自动安装的
Checking script requirements:
Checking for host...
Checking for mtr...
Checking for ping...
Checking for traceroute...
Checking for sqlite3...

Checking for previous config:
Creating Config.php...

Creating test files:
Test files already exist...


###                    ###
# Starting configuration #
###                    ###

Running setup:
#输入网站的名字,会显示在标题和header上
Enter your website name (Header/Logo) []: Xiaomage`s LookingGlass
#输入lookingGlass的URL(你想把LG放在哪,包含http协议头)
Enter the public URL to this LG (including http://) []: https://bbx.xmgspace.me/lg
#服务器位置 可不填
Enter the servers location []: San Jose, LA, USA
#服务器IP 为了放在IP泄露,可不填
Enter the test IPv4 address []: 
#IPv6地址 可不填
Enter the test IPv6 address (Re-enter everytime this script is run) []: 
#生成测速文件的大小 可不填
Enter the size of test files in MB (Example: 25 50 100) []: 
#限制每个IP每小时的测试次数 选n就表示不开启此功能
Do you wish to enable rate limiting of network commands? (y/n): n
#不选择其他主题,主题就一套
Would you like to choose a different theme? (y/n): n

Creating Config.php...

Creating SQLite database...
#输入服务器的用户名或用户组 root一把梭
Enter the username of your webserver (E.g. www-data): root
Enter the user group of your webserver (E.g. www-data): root
Fixing besttrace permissions...

Installation is complete

这样安装过程就完成了。访问你的网站:http://你的域名/lg就可以看到LookingGlass的主界面了。可以显示出你的IP,点击你的IP地址,就会自动输入到输入框中。

LG界面

然而,当你兴致勃勃的打算进行路由追踪,按下开始测试按钮后,按钮闪了一下,什么都没有发生。

这个地方有一个坑,有些一键安装包为了安全,会禁止PHP调用一些系统函数。但LookingGlass就是调用mtr等系统命令,再显示再页面上的,我们要解除对这些命令的限制。修改php.ini就可以解除限制。
这个大坑花了我一晚上时间,自己写了个DEMO,本地运行可以,为什么在服务器上就不行呢...最后才找到原因。

vim /usr/local/php/etc/php.ini

找到disable_functions /disable_functions

将proc_open 这个函数去掉即可。

之后保存文件,重启php-fpm service php-fpm restart

Enjoy it!

参考资料

LookingGlass https://github.com/ILLKX/LookingGlass

本文永久链接:https://blog.xmgspace.me/archives/looking-glass-setup.html
本文文章标题:搭建LookingGlass 随时监测服务器回程线路
如无特殊说明,只要您标明转载自Xiaomage's Blog,就可自由转载本文。禁止CSDN/采集站采集转载。
授权协议:署名-非商业性使用-相同方式共享 4.0(CC BY-NC-SA 4.0)

评论

  1. hunter
    Android Chrome
    4年前
    2020-7-15 17:14:22

    学习下,嘿嘿

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇