Linux本地测速方法

speedtest 是一款使用 python 语言编写的轻量级的 linux 命令行测速工具,在 python2 以及 python3 的环境下都可以运行,基于 speedtest.net 基础框架来测量网络的上下行数据,安装也很简单,只要下载对应的 python 文件执行即可。

测速方法
1、先下载脚本(wget 下载或者下载好上传到服务器上)

wget https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py 

2、为脚本授权

chmod a+rx speedtest.py
chown root:root speedtest.py 

3、移至本机运行目录

mv speedtest.py /usr/local/bin/speedtest 

4、执行测速

speedtest 

如果出现找不到 python 环境的错误,对应以下解决即可!


[root@ecs-test ~]# speedtest 
/usr/bin/env: ‘python’: No such file or directory
[root@ecs-test ~]# python3 --version
Python 3.6.8
[root@ecs-test ~]# 
[root@ecs-test ~]# whereis python3
python3: /usr/bin/python3.6 /usr/bin/python3 /usr/bin/python3.6m /usr/lib/python3.6 /usr/lib64/python3.6 /usr/local/lib/python3.6 /usr/include/python3.6m /usr/share/man/man1/python3.1.gz
[root@ecs-test ~]# sudo ln -s /usr/bin/python3 /usr/bin/python
[root@ecs-test ~]# speedtest 
 

5、查看测速节点列表

speedtest --list 

6、对指定节点测速,14623是节点编号

speedtest  --server 14623 

Kimsufi-ks系列怎么配置ipv6

debian10:
ipv6 地址以及网关的获取方式:

美区账号登录:https://ca.api.kimsufi.com/
请求:https://ca.api.kimsufi.com/console/#/dedicated/server/%7BserviceName%7D/specifications/network~GET
(欧洲将链接中 ca 换成 eu )
填入主机名,Execute,便可找到:

 
{
        .....
-vmac: {
supported: true
}
-routing: {
-ipv6: {
gateway: "xx"
ip: "xx/128"
network: "xxx/56"
}
-ipv4: {
network: "xx"
ip: "xx"
gateway: "xx"
}
}
-vrack: {
type: null
bandwidth: null
}
}

编辑文件/etc/network/interfaces
添加以下代码

 
iface ens3 inet6 static    ##ens3为我的网卡,请修改成自己的网卡
    address 你的ipv6地址 
    netmask 128

post-up /sbin/ip -f inet6 route add IPv6_GATEWAY dev ens3
post-up /sbin/ip -f inet6 route add default via IPv6_GATEWAY 
pre-down /sbin/ip -f inet6 route del IPv6_GATEWAY dev ens3
pre-down /sbin/ip -f inet6 route del default via IPv6_GATEWAY
 
service networking restart
 
ping6 -c 4 google.com

网络DD重装Linux-已适配Oracle甲骨文免费主机

确保安装了所需软件:
#Debian/Ubuntu:

apt-get install -y xz-utils openssl gawk file

#RedHat/CentOS:
yum install -y xz openssl gawk file
如果出现了错误,请运行:
#Debian/Ubuntu:

apt-get update

1.新增对 Oracle AMD,Oracle ARM全面支持. 可支持从 Ubuntu, Oracle Linux 等系统网络重装.
2.更新 dd 镜像的基础系统版本.
3.移除对外部 wget 的依赖.
4.新增 -port 参数, 可更改默认SSH端口.
5.更新 内置的网络参数计算 逻辑.
6.更新 grub 配置文件定位逻辑, 可支持任意引导grub的系统.
默认密码:Vicer

以下系统已通过测试(其他自测):
Debian: 9, 10, 11;
Ubuntu: 18.04, 20.04;
CentOS: 6.10;
以下平台已通过测试(其他自测):
Oracle、Do、Azure

示例安装Debian10和Debian11(512M内存推荐使用Debian10):

bash <(wget --no-check-certificate -qO- 'https://raw.githubusercontent.com/MoeClub/Note/master/InstallNET.sh') -d 11 -v 64 -p "自定义root密码" -port "自定义ssh端口"

手动测试Oracle甲骨文免费主机安装Debian11,成功通过。
默认root密码:MoeClub.org
以上脚本支持IPV6,但是实用性不是很广,buyvm和dmit无法使用,dmit安装debian10成功

wget --no-check-certificate -O AutoReinstall.sh https://git.io/AutoReinstall.sh && bash AutoReinstall.sh

手动测试商家buyvm通过,默认密码:Pwd@Linux
这个脚本IPV4没问题对IPV6支持不太好,可能会出现模块无法加载的问题,但是实用性很广,几乎支持所有IDC

开机改密:

#!/bin/bash
echo root:Vicer |sudo chpasswd root
sudo sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config;
sudo sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config;
sudo reboot

支持centos7、8

bash <(wget --no-check-certificate -qO- 'https://raw.githubusercontent.com/MoeClub/Note/master/InstallNET.sh') -c 7 -v 64 -a
bash <(wget --no-check-certificate -qO- 'https://raw.githubusercontent.com/MoeClub/Note/master/InstallNET.sh') -c 8 -v 64 -a

 

 

Virmach 可用DD脚本 实测成功 Debian 10

wget -N --no-check-certificate https://down.vpsaff.net/linux/dd/network-reinstall-os.sh && \
chmod +x network-reinstall-os.sh && ./network-reinstall-os.sh

注意事项:
由于CentOS 7以上改变了安装机制,需要2G或更多内存才能完成网络重装;
CentOS 7和8 DD方式来自第三方,本站不作任何保证,好处就是不受VPS内存大小限制;
重装系统需要比较长的时间,请耐心等待,如果服务商有提供VNC可以查看全过程。
默认账户名为:root,密码为:IdcOffer.com
脚本来源:https://www.idcoffer.com/archives/7536

功能强大的linux系统一键DD重装脚本

一、Linux reinstall下载

网站:

    1. https://github.com/leitbogioro/Tools

脚本下载:
wget –no-check-certificate -qO InstallNET.sh ‘https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/InstallNET.sh’ && chmod a+x InstallNET.sh

默认密码是:LeitboGi0ro

相关说明:
支持各大云商,特别支持Oracle ARM机
支持 raid 0,仅限 Debian,要使用 raid 0 请添加 -raid “0”参数。单硬盘请不要添加此参数。有效性尚待测试。
DD Windows 方法和原版萌咖功能一样,该怎么用就怎么用,如果 DD 包无后缀名,默认使用 gz 解压方式,支持 xz 结尾的压缩包,如果要解压 xz 压缩包请添加参数 -filetype “xz”。
支持 RedHat 系新系统,包括 CentOS 9 Stream,RockyLinux 8+,AlmaLinux 8+,Fedora 34+,也支持从 OracleLinux/VzLinux 装到脚本支持的系统。
Debian 9+ 支持 xfs,这也是 Redhat 系默认的文件系统,抛弃老旧的默认 ext2。
如果要指定其他参数,比如镜像地址,系统后面必须带上版本,比如:-debian 11,不然会出错。
默认采用 DHCP 配置网络,如果确认是静态地址,请附带 –dhcp-static 参数,不过脚本仍然会自动检测,如果是 DHCP,还会改回来。
由于 RedHat 7 以后默认采用 firewalld 做防火墙,防火墙不放行的端口都用不了,所以通过强改 firewalld 配置文件来对 RedHat 系列的系统自定 s-s-h 端口号进行支持。此前旧版本仅支持 22 端口,不支持自定。
脚本对当前与运行系统的硬件架构作了判断和对要装的系统硬件架构名称做了自动转换,并且 -v 参数已经被废弃,用 -version 替代,如果不懂,不要再使用这个参数
国内机器不用指定安装源,脚本自动监测并切换到国内源。

注意事项:
脚本完善了对 grub2 的处理,使 Debian 和 Redhat 系可以无限互装而不受影响,萌咖的脚本只支持处理 grub1,这就导致从 Debian 系装到 Redhat 系,grub1 变成了 grub2,导致从 Redhat 系没法再装回 Debian 系。
AMD64 legacy boot 和 AMD64 UEFI boot 以及 ARM64 UEFI boot 的启动项处理参数完全不同,处理错了就是坑,能解决好才是支持主流各 CPU 架构和主板固件启动的基础。
已进行了大量测试,确认 Oracle 机器上跑没问题。
为什么 Debian IPv6 为什么没配置正确(双栈机)?检查一下你原系统是不是 /etc/default/grub 文件里是不是 GRUB_CMDLINE_LINUX=”” 里面带 net.ifnames=0 biosdevname=0 参数?如果带,系统网卡名称会统一变成 eth0 eth1 eth2 这种的,这样会干扰新系统里写入网络配置。有能力的自己在原系统里把相关配置清掉,确保网卡显示的是真实物理网卡的名称,而不是被系统重定向过的,脚本获取手段就是这个,你原系统配置不对,不要怪脚本怎么没在新系统内写入正确的。
多网卡,多ip请进新系统内手工配置,单网卡双栈机自动配置 ipv6 仅限 debian
由于 CentOS 6 的 grub1 脚本语法和其他系统 grub1 grub2 的完全不同,所以不再对装回 CentOS 6 和将 CentOS 6 重装成别的系统的支持。
Redhat 8 要求 2.5GB 内存,Redhat 9 要求 2GB 内存。

二、Linux reinstall使用
先安装依赖:

Debian series(Debian / Ubuntu):
apt update -y
apt install wget -y

Redhat series(CentOS / AlmaLinux / RockyLinux / OracleLinux / Fedora / VzLinux):
yum update –allowerasing -y
yum install wget -y
快速安装系统:

Debian 11系统

bash InstallNET.sh -debian
CentOS 9 stream系统

bash InstallNET.sh -centos
AlmaLinux 9系统

bash InstallNET.sh -almalinux
RockyLinux 9系统

bash InstallNET.sh -rockylinux
Fedora 37系统

bash InstallNET.sh -fedora
Ubuntu 20.04系统

bash InstallNET.sh –ubuntu

三、Linux reinstall参数

Linux reinstall详细的使用示例如下:
bash InstallNET.sh -debian/ubuntu/centos/almalinux/rockylinux/fedora(os type) 11(os version) -version 64(os bit) -port “your server port” -pwd “your server password” -mirror “a valid url for linux image source” -dd/–image “dd image url” -filetype “gz or xz” -timezone “like Asia/Tokyo etc” –dhcp-static/–ip-addr ‘x.x.x.x'(ip address) –ip-mask ‘x.x.x.x'(subnet mask) –ip-gate ‘x.x.x.x'(gateway) -firmware(Debian with hardware drivers)

如果你想安装指定操作系统,请修改为以下的参数:

-debian 9/10/11 : Debian 9 and later

-centos 7/8/9-stream: CentOS 7 and later

-almalinux/alma 8/9: AlmaLinux 8 and later

-rockylinux/rocky 8/9: RockyLinux 8 and later

-fedora 34/35/36/37: Fedora 34 and later

-ubuntu 16.04/18.04/20.04: Ubuntu from 16.04 to 20.04

指定操作系统源:-mirror “a valid DIST mirror url”。有如下官方可供选择:

For Debian, official recommend mirror lists are here:

https://www.debian.org/mirror/list.html
For CentOS, official recommend mirror lists are here:

https://www.centos.org/download/mirrors/
For AlmaLinux, official recommend mirror lists are here:

https://mirrors.almalinux.org/
For RockyLinux, official recommend mirror lists are here:

https://mirrors.rockylinux.org/mirrormanager/mirrors
For Fedora, official recommend mirror lists are here:

https://admin.fedoraproject.org/mirrormanager/mirrors/Fedora
For Ubuntu, official recommend mirror lists are here:

https://launchpad.net/ubuntu/+cdmirrors
指定端口:

-port “”: you can pre-specify s-s-h port of system, range is 1~65535, both Redhat series or Debian series could be supported, 默认端口是’22’.

指定密码:

-pwd “”: you can pre-specify ssh password of system, both Redhat series or Debian series could be supported, 默认密码是’LeitboGi0ro’.

DD系统模式:

-dd/–image “DD image from a valid url”: This parameter is for DD mode in KVM or XEN virtualization platform, current os must be Debian series, for example, if you want to DD windows,。

-filetype “gz/xz”: To determine DD file type, not only “.gz”(default) but also “.xz” can be supported.

指定时区:

-timezone “like Asia/Tokyo etc”.

支持 raid 0,仅限 Debian:

-raid “0”: Only for raid 0 disk partition, if your machine has only one hard drive, don’t assign it!

以安装Debian 11示例如下(默认密码是:LeitboGi0ro):

bash InstallNET.sh -debian 11 -mirror “http://ftp.riken.jp/Linux/debian/debian/”

四、安装Windows系统
脚本并不提供任何Windows系统,你需要自己在网上找一些自己被DD好的Windows系统了。

用法示例:

如果是 KVM or XEN virtualization, Debian series only:

bash InstallNET.sh -dd “DD image download URL”
如果是 physical hardware, Intel network adapter, kimsufi etc:

Change netboot to rescue mode, receive mail, get temporary username and password, log into linux, execute:

wget -O- “DD download URL” | xzcat | dd of=/dev/sda
网上免费的 Windows DD images可以在这里找到:

Windows Server series from TeddySun(https://teddysun.com/):

Username: Administrator
Password: Teddysun.com

Windows Server 2022 Datacenter

Chinese: https://dl.lamp.sh/vhd/zh-cn_win2022.xz
English: https://dl.lamp.sh/vhd/en-us_win2022.xz
Japanese: https://dl.lamp.sh/vhd/ja-jp_win2022.xz

Windows Server 2019 Datacenter

Chinese: https://dl.lamp.sh/vhd/cn_win2019.xz
English: https://dl.lamp.sh/vhd/en_win2019.xz
Japanese: https://dl.lamp.sh/vhd/ja_win2019.xz

Windows Server 2012 R2 Datacenter

Chinese: https://dl.lamp.sh/vhd/cn_win2012r2.xz
English: https://dl.lamp.sh/vhd/en_win2012r2.xz
Japanese: https://dl.lamp.sh/vhd/ja_win2012r2.xz

Linux设置IPv4优先,IPv6靠后解析(包含关闭IPv6)

默认的安装中,IPv4 和 IPV6 并存,并且 IPv6 优先于 IPv4。

如果不需要彻底关闭 IPv6,也可以设置让 IPv4 优先于 IPv6。

配置方式如下:
第一种方法:

echo "precedence ::ffff:0:0/96 100" >>/etc/gai.conf 

第二种方法:

vim  /etc/gai.conf 

#precedence ::ffff:0:0/96 100
去掉这一行前面的#号

保存即可生效。

测试:

ping www.google.com -c 3 

测试下来平均可以减少10ms所有的访问时间。

或者
关闭IPv6:

echo -e "net.ipv6.conf.all.disable_ipv6=1\nnet.ipv6.conf.default.disable_ipv6=1\nnet.ipv6.conf.lo.disable_ipv6=1" >> /etc/sysctl.conf
sysctl -p

Ubuntu16.04和debian单网卡配置多IPv6地址

注意:在此之前必须先分配好网络地址,才能添加。

一、修改/etc/network/interfaces 文件内容

 
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface

auto eth0
iface eth0 inet dhcp
pre-up sleep 2
#以下是第一个IPv6地址
iface eth0 inet6 static
address 2605:6400:0020:1b99::2
netmask 48
gateway 2605:6400:20::1

#以下是第二个IPv6地址
auto eth0:0
iface eth0:0 inet6 static
address 2605:6400:0020:1b99::3
netmask 48
gateway 2605:6400:20::1

#以下是第三个IPv6地址
auto eth0:1
iface eth0:1 inet6 static
address 2605:6400:0020:1b99::4
netmask 48
gateway 2605:6400:20::1

#以下是第四个IPv6地址
auto eth0:2
iface eth0:2 inet6 static
address 2605:6400:0020:1b99::5
netmask 48
gateway 2605:6400:20::1

Debian11修改内容如下:

 
iface ens3 inet6 static
      address 2604:9cc0:0000:1134:0000:0000:0000:0003/64
      gateway 2604:9cc0::1

iface ens3:0 inet6 static
      address 2604:9cc0:0000:1134:0000:0000:0000:0004/64
      gateway 2604:9cc0::1

iface ens3:1 inet6 static
      address 2604:9cc0:0000:1134:0000:0000:0000:0005/64
      gateway 2604:9cc0::1

二、重启网络、查看IP信息

 
  //重启网络服务
root@ubuntu:~# sudo systemctl restart networking.service
  //查看IP信息
root@ubuntu:~# ip -6 addr show ens3

Ubuntu完全卸载 apache2

Ubuntu自带 apache2 有时候很讨厌。 有时候需要先卸载了再装别的。

完全卸载的方法:


sudo apt-get autoremove apache2 -y
sudo apt-get remove apache* -y
sudo apt-get --purge remove apache-common -y
sudo apt-get --purge remove apache -y
sudo find /etc -name "*apache*" |xargs  rm -rf 
sudo rm -rf /var/www
sudo rm -rf /etc/libapache2-mod-jk
dpkg -l |grep apache2|awk '{print $2}'|xargs dpkg -P

Chrome谷歌浏览器内置翻译无法使用的解决方法

根据最新的统计数据谷歌浏览器(Chrome)市场占比份额:66.58%,每2人中就有1人使用的是Chrome浏览器。

主要原因:translate.google.cn 的访问被国内阻断,所以导致谷歌翻译无法使用。

google translation of chrome 和 google chrome update

重点:这两个货(在windows上)是开独立进程(线程)的,相当于独立chrome之外,都是走的系统代理,并不通过 chrome 内置 proxy 设置。

点我测试谷歌翻译是否恢复正常

1、进入etc文件夹,找到host文件

mac:右键访达—前往文件夹–输入“etc/hosts”

windows: C:\Windows\System32\drivers\etc

2、将以下内容写入到该文件:


172.253.125.90 translate.googleapis.com

142.250.28.90 translate.googleapis.com

108.177.126.90 translate.googleapis.com

142.251.2.90 translate.googleapis.com

142.250.8.90 translate.googleapis.com

172.253.58.90 translate.googleapis.com

142.250.152.90 translate.googleapis.com

142.251.18.90 translate.googleapis.com

142.251.5.90 translate.googleapis.com

142.250.98.90 translate.googleapis.com

108.177.127.90 translate.googleapis.com

142.250.12.90 translate.googleapis.com

142.250.153.90 translate.googleapis.com

142.250.9.90 translate.googleapis.com

142.250.142.90 translate.googleapis.com

142.250.11.90 translate.googleapis.com

142.250.112.90 translate.googleapis.com

142.250.138.90 translate.googleapis.com

142.250.111.90 translate.googleapis.com

172.253.116.90 translate.googleapis.com

142.250.97.90 translate.googleapis.com

142.250.13.90 translate.googleapis.com

142.251.4.90 translate.googleapis.com

172.253.123.90 translate.googleapis.com

142.250.145.90 translate.googleapis.com

142.251.1.90 translate.googleapis.com

142.251.9.90 translate.googleapis.com

142.250.158.90 translate.googleapis.com

142.251.15.90 translate.googleapis.com

142.250.27.90 translate.googleapis.com

172.253.113.90 translate.googleapis.com

142.250.102.90 translate.googleapis.com

142.251.112.90 translate.googleapis.com

142.250.123.90 translate.googleapis.com

172.253.119.90 translate.googleapis.com

216.58.227.66 translate.googleapis.com

172.253.124.90 translate.googleapis.com

172.253.126.90 translate.googleapis.com

172.253.112.90 translate.googleapis.com

142.250.10.90 translate.googleapis.com

172.217.192.90 translate.googleapis.com

172.217.195.90 translate.googleapis.com

108.177.111.90 translate.googleapis.com

172.253.62.90 translate.googleapis.com

142.250.31.90 translate.googleapis.com

172.217.204.90 translate.googleapis.com

142.251.117.90 translate.googleapis.com

216.58.227.65 translate.googleapis.com

172.217.222.90 translate.googleapis.com

142.251.166.90 translate.googleapis.com

142.251.111.90 translate.googleapis.com

216.58.227.67 translate.googleapis.com

142.250.96.90 translate.googleapis.com

172.253.115.90 translate.googleapis.com

172.253.63.90 translate.googleapis.com
 

参考链接:https://hcfy.app/blog/2022/09/28/ggg
你也可以给梯子开全局模式,也就是所有域名都走国外 IP。但是,国内网站的访问速度会因此变慢,所以还是建议花点时间研究下如何添加代理规则。

设置好了之后,请阅读测试谷歌翻译是否恢复正常。