九溪

溪水润知林,滴露启慧心

用户工具

站点工具


pages:home

ColinOL Home

V2Ray的安装配置与资源

v2ray 的安装与使用

v2ray 环境搭建(服务端+客户端)

v2ray配置文件路径:/etc/v2ray/config.json

注意事项:reboot后,v2ray的配置文件的信息会被丢失,需要重新添加inbound,然后重启v2ray服务即可。

拯救被墙的IP:V2Ray+CDN 解决方案

关键词:v2ray+ws+tls+CDN

文档

各类V2Ray客户端

客户端下载

  1. V2RayN(Windows): Github 下载 v2rayN-Core.zip
  2. BifrostV(Android): Play商店 | ApkPure
  3. V2RayNG(Android): Play商店 | Github

参考:

V2ray资源

2019/10/08 17:54 · colin

Linux 支持 ipv6 网络

如果默认的网络环境不支持ipv6(只支持ipv4),

概要:通过 https://www.tunnelbroker.net 建立tunnel隧道,使得linux能够支持ipv6网络

创建隧道

  1. 创建通道“Create Regular Tunnel”
    • 填写VPS的公网 IP 地址。填写IP时出现“IP is a potential tunnel endpoint.”说明可以添加ipv6隧道。
    • 选择隧道节点,点击Create Tunnel创建。
    • 关于隧道节点的选择,大家可以在自己的云服务器上分别ping一下提供的IP,选时延低的。
  2. 创建IPv6隧道及路由:
    • 到下一页面切换到Example configurations选项卡,
    • 下拉菜单选择Debian/Ubuntu,
    • 复制出现的内容。类似下面的代码
auto he-ipv6
iface he-ipv6 inet6 v4tunnel
        address xxxx:xxx:xxxx:xxx::x
        netmask 64
        endpoint xxx.xxx.xxx.xx
        local xxx.xxx.xxx.xxx
        ttl 255
        gateway xxxx:xxx:xxxx:xxx::x

在主机中添加ipv6隧道

修改

编辑文件,将刚才复制的内容粘贴进去。

vim /etc/network/interfaces
auto he-ipv6
iface he-ipv6 inet6 v4tunnel
        address xxxx:xxx:xxxx:xxx::x
        netmask 64
        endpoint xxx.xxx.xxx.xx
        local xxx.xxx.xxx.xxx
        ttl 255
        gateway xxxx:xxx:xxxx:xxx::x

添加DNS

vim /etc/resolvconf/resolv.conf.d/base

加入以下内容

nameserver 2001:4860:4860::8844
nameserver 2001:470:20::2

保存后,执行以下命令

resolvconf -u

重启网络

service networking restart

或者重启主机

reboot

然后,执行

ifconfig

应该可以看到 he-ipv6 网卡

没有的话,执行

ifup he-ipv6

检测

接着连通测试

ping6 -c 5 2001:4860:4860::8888
ping6 -c 5 ipv6.google.com

Ping通了,说明网络已连通,能正常解析域名,说明DNS也正常。

其他IPv6 测试工具:

如何确定目前连接的方式为 IPv4 还是 IPv6?打开 https://www.google.com/search?hl=en&q=what+is+my+ip ,如果显示的您的 IP 地址为 IPv6 格式说明您是以 IPv6 的形式接入的,否则为 IPv4 形式。

Hosts

如果需要指定域名通过IPv6 访问,修改Hosts文件即可。

vi /etc/hosts

如强制使用IPV6访问谷歌,也非常简单,在/etc/hosts里添加

# Google
2607:f8b0:4005:811::200e google.com
2607:f8b0:4005:80c::2004 www.google.com
# Google Scholar
2607:f8b0:4005:80a::200e scholar.google.cn      
2607:f8b0:4005:80a::200e scholar.google.com     
2607:f8b0:4005:80a::200e scholar.google.com.hk  
2607:f8b0:4005:80a::200e scholar.google.com.sg  
2607:f8b0:4005:80a::200e scholar.google.com.tw  
2607:f8b0:4005:80a::200e scholar.google.com.uk  
2607:f8b0:4005:80a::200e scholar.l.google.com

Linux刷新dns的缓存方法是:

sudo /etc/init.d/nscd restart

如果发现提示命令找不到:sudo: /etc/init.d/nscd: command not found

需要先安装nscd包:

sudo apt-get install nscd

最暴力的方法刷dns,重启网络:

sudo /etc/init.d/networking restart

查询可用的ip地址

参考:

运行 resolvconf -u 出现以下信息

/etc/resolvconf/update.d/libc: Warning: /etc/resolv.conf is not a symbolic link to /run/resolvconf/resolv.conf

解决办法:

sudo rm /etc/resolv.conf
sudo ln -s /run/resolvconf/resolv.conf /etc/resolv.conf
sudo resolvconf -u

无法使用ifconfig时,尝试运行以下命令

sudo apt install net-tools
2019/10/08 16:13 · colin

vim 编辑器

常用配置

在用户目录下,新建文件.vimrc(如果没有特殊说明,都是默认配置在~/.vimrc文件中),将以下代码copy进去,保存即可生效

注意:vim 8.0 会默认新建一个 ~/.viminfo

set nocompatible " 关闭 vi 兼容模式

syntax on " 自动语法高亮

" colorscheme molokai " 设定配色方案

set number " 显示行号

set cursorline " 突出显示当前行

set ruler " 打开状态栏标尺

set shiftwidth=4 " 设定 << 和 >> 命令移动时的宽度为 4

set softtabstop=4 " 使得按退格键时可以一次删掉 4 个空格

set tabstop=4 " 设定 tab 长度为 4

set nobackup " 覆盖文件时不备份

set autochdir " 自动切换当前目录为当前文件所在的目录

filetype plugin indent on " 开启插件

set backupcopy=yes " 设置备份时的行为为覆盖

set ignorecase smartcase " 搜索时忽略大小写,但在有一个或以上大写字母时仍保持对大小写敏感

set nowrapscan " 禁止在搜索到文件两端时重新搜索

set incsearch " 输入搜索内容时就显示搜索结果

set hlsearch " 搜索时高亮显示被找到的文本

set noerrorbells " 关闭错误信息响铃

set novisualbell " 关闭使用可视响铃代替呼叫

set t_vb= " 置空错误铃声的终端代码

" set showmatch " 插入括号时,短暂地跳转到匹配的对应括号

" set matchtime=2 " 短暂跳转到匹配括号的时间

set magic " 设置魔术

set hidden " 允许在有未保存的修改时切换缓冲区,此时的修改由 vim 负责保存

set guioptions-=T " 隐藏工具栏

set guioptions-=m " 隐藏菜单栏

set smartindent " 开启新行时使用智能自动缩进

set backspace=indent,eol,start

" 不设定在插入状态无法用退格键和 Delete 键删除回车符

set cmdheight=1 " 设定命令行的行数为 1

set laststatus=2 " 显示状态栏 (默认值为 1, 无法显示状态栏)

set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %c:%l/%L%)\ 

" 设置在状态行显示的信息

set foldenable " 开始折叠

set foldmethod=syntax " 设置语法折叠

set foldcolumn=0 " 设置折叠区域的宽度

setlocal foldlevel=1 " 设置折叠层数为

" set foldclose=all " 设置为自动关闭折叠 

" 用空格键来开关折叠

" nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>

" 配置多语言环境

" if has("multi_byte")

" UTF-8 编码

set encoding=utf-8

set termencoding=utf-8

set formatoptions+=mM

set fencs=utf-8,gbk

" 选中状态下 Ctrl+c 复制

vmap <C-c> "+y

参考

2019/10/06 21:59 · colin

软件管理:安装/卸载/进程/软件源

软件的安装与卸载

以nginx为例

安装软件

sudo apt-get install nginx

重置软件

sudo apt-get -o DPkg::options::=--force-confmiss --reinstall install nginx-common

查看已安装的相关软件

dpkg --get-selections | grep nginx

移除/卸载软件

sudo apt-get remove nginx

完全移除软件

sudo apt-get --purge autoremove nginx

删除软件的方法(2)

查看已安装软件

sudo dpkg --list|grep mysql

删除软件(可使用通配符)

sudo apt-get autoremove --purge mysql*

清理残留的数据

dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P

示例:卸载docker

在Ubuntu 20.04下卸载Docker在

卸载Docker之前,最好删除所有容器、映像、卷和网络。

运行以下命令以停止所有正在运行的容器并删除所有docker对象:

docker container stop $(docker container ls -aq)
docker system prune -a --volumes

现在,可以像使用apt安装的任何其他软件包一样卸载Docker:

sudo apt purge docker-ce
sudo apt autoremove

至此,卸载Docker完成。

查询相关软件包

dpkg -l | grep docker

删除这个包

sudo apt remove --purge docker.io

进程管理

查询正在运行的进程

ps -ef

显示整颗进程树

pstree

查询进程名中含有testprocess的进程(方法1)

pgrep -l testprocess

查询进程名中含有testprocess的进程(方法2)

ps -e | grep testprocess

查看占用端口的进程

lsof -i:80

杀死指定PID的进程 (PID为Process ID)

kill PID

查看系统中使用CPU、使用内存最多的进程;

top

参考:

软件源、软件包

啥是 Linux 包管理器,为啥我的用不了?

  • Linux 的常用包管理器 apt rpm yum 安装系统时是没有的,需要自己安装,就类似 windows 里面的添加/删除程序
  • Ubuntu 默认的包管理器为 apt,而 rpm,yum 是 Redhat 的软件包管理器
  • Ubuntu 绝大多数用 apt 就够了,当然也可以用 rpm yum 包管理器

1.安装 rpm

apt install rpm

2.安装 yum

apt install yum

5.怎么查看 apt 管理的所有包,使用命令:

apt list

怎么查看 apt 所有已经安装的包,使用命令:

apt list --installed
2019/10/06 21:48 · colin

示例:Dokuwiki 网站在 Nginx & PHP7.0 环境下的配置

Nginx 配置文件: /etc/nginx/sites-available/xxx.com

功能:

  • 开启php功能
  • 开启rewrite功能
  • www.example.com 自动重定向到 example.com
server {
  server_name example.com;
  listen 80;
  autoindex off;
  client_max_body_size 15M;
  client_body_buffer_size 128k;
  index index.html index.htm index.php doku.php;
  #access_log  /var/log/nginx/example.com/access.log;
  #error_log  /var/log/nginx/example.com/error.log;
  root /var/www/example.com;

  location / {
    try_files $uri $uri/ @dokuwiki;
    if (!-f $request_filename)
    {
        rewrite ^(/)(.*)?(.*)  $1doku.php?id=$2&$3 last;
        rewrite ^(/)$ $1doku.php last;
    }
  }

  location @dokuwiki {
    rewrite ^(/)_media/(.*) $1lib/exe/fetch.php?media=$2 last;
    rewrite ^(/)_detail/(.*) $1lib/exe/detail.php?media=$2 last;
    rewrite ^(/)_export/([^/]+)/(.*) $1doku.php?do=export_$2&id=$3 last;
  }

  location ~ ^/lib.*\.(gif|png|ico|jpg)$ {
    expires 30d;
  }

  location = /robots.txt  { access_log off; log_not_found off; }
  location = /favicon.ico { access_log off; log_not_found off; }
  location ~ /\.          { access_log off; log_not_found off; deny all; }
  location ~ ~$           { access_log off; log_not_found off; deny all; }

  location ~ \.php$ {
          include snippets/fastcgi-php.conf;
          fastcgi_pass unix:/run/php/php7.0-fpm.sock;
  }

  location ~ /(data|conf|bin|inc)/ {
    deny all;
  }

  location ~ /\.ht {
    deny  all;
  }
}

server {
    listen       80;
    server_name  www.example.com;
    return       301 http://example.com$request_uri;
}
2019/10/06 18:20 · colin · 2 评论

评论

请输入您的评论. 可以使用维基语法:
 
pages/home.txt · 最后更改: 2023/01/03 15:08 由 127.0.0.1