云网
    • 版块
    • 最新
    • 标签
    • 热门
    • 世界
    • 用户
    • 群组
    • 登录
    1. 主页
    2. node-ccccc
    N
    离线
    • 资料
    • 关注 0
    • 粉丝 0
    • 主题 11
    • 帖子 11
    • 群组 2

    node-ccccc

    @node-ccccc

    administrators
    0
    声望
    1
    资料浏览
    11
    帖子
    0
    粉丝
    0
    关注
    注册时间
    最后登录

    node-ccccc 取消关注 关注
    公共群组 administrators

    node-ccccc 发布的最新帖子

    • 飞牛虚拟机使用默认NAT网络

      前言
      此倒腾在一般家庭网络环境下其实用不上。因为NAS可以随时通过DHCP获取到内网IP,不存在什么IP资源缺乏的情况。

      我之所以这么倒腾纯粹是因为我在我的闲置VPS服务器上使用DD方案刷入了飞牛OS。在创建虚拟机的时候虚拟机无法联网。因为我的VPS就只有一个IP。这个IP给的飞牛OS后,虚拟机是没有IP资源的,这一点可以通过Windows虚拟机的网络问题检测得到。飞牛的qemu按道理是可以使用多种网络模式的,然而飞牛OS现在的虚拟机默认就只有桥接这一个。所以无法在虚拟机管理里修改网络模式。我们只能通过SSH去修改配置文件了。

      流程
      首先我们需要按照正常流程创建一个飞牛虚拟机。此时可以选择不用启动它。如果已经启动且正在配置系统安装也没关系,安装完成再关闭虚拟机即可。

      然后我们通过SSH登录到飞牛NAS。这里推荐使用【Xterminal】客户端。

      首先提权

      sudo -s
      ​
      我们进入到目录 /etc/libvirt/qemu。在这里可以看到虚拟机的配置文件。此时在【Xterminal】内双击编辑是无用的,因为虚拟机配置文件默认的是【600】权限。所以我们需要对虚拟机配置文件权限进行修改。

      将虚拟机配置文件权限改为 777

      sudo chmod 777 /etc/libvirt/qemu/vm_name.xml
      ​
      反正是自己用,无所谓,直接【777】即可。

      如果不知道虚拟机真实名字的可以一个个配置文件找,配置文件内的 <title>Window 11 LTSC</title> 字段是飞牛虚拟机中创建虚拟机时的名字。

      这种方法是不是很蠢,其实有简短的方法。回到飞牛虚拟机的管理页面,我们在进入虚拟机管理后,通过【F12】来打开浏览器的开发者模式。选择网络,你可以看到不停刷新的一个请求类似于【http://192.168.1.9:5666/vm/api/v1/domain/status?names=oo1pptlw,c26vc9ti】。这最后的 names字段跟着的参数就是虚拟机里的所有虚拟机真实名称。案例为【oo1pptlw,c26vc9ti】。此时找到你要修改的虚拟机,点击编辑。你将会看到一个新的请求类似于【http://192.168.1.9:5666/vm/api/v1/domain/info?name=c26vc9ti】。这时后面跟着的名字就是我们要改的虚拟机的真实名字了。

      现在回到打开虚拟机的配置文件。你会看到类似于以下的一个片段:

      <interface type='bridge'>
        <mac address='ba:c6:8a:28:bb:f4'/>
        <source bridge='enp9s0-ovs'/>
        <virtualport type='openvswitch'>
          <parameters interfaceid='dca46eda-15a9-456e-937e-ebda1078b6ba'/>
        </virtualport>
        <model type='virtio'/>
        <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
      </interface>
      

      ​
      这里就是此虚拟机的网络配置部分。我们需要将其改为如下案例:

      <interface type='network'>
      <mac address='0c:a7:f1:44:57:a2'/>
      <source network='default'/>
      <model type='e1000'/>
      <address type='pci' domain='0x0000' bus='0x06' slot='0x01' function='0x0'/>
      </interface>
      ​
      其中的mac地址等无需进行修改。这些均采用最开始创建虚拟机的时候的设置。

      虚拟机的网络配置部分需要修改的其实对比上面两个片段就可以知道。

      将 <interface type='bridge'> 更改为 <interface type='network'>。
      移除 <source bridge='enp9s0-ovs'/> 行,因为它指定了桥接的网络接口。
      移除 <virtualport> 相关的配置,因为NAT不需要这个。
      添加 <source network='default'/> 行,其中 default 是默认的NAT网络名称。
      保存配置文件即可。配置文件权限此时也可以改回去了。

      至于默认的NAT网络配置文件位置则在 /etc/libvirt/qemu/networks/default.xml 。此文件同样是【600】权限,如需编辑,也需要进行权限修改。此处用不上,不做相关介绍。

      此时我们需要定义编辑后的配置文件。这会告诉 libvirt 使用更新后的配置文件。

      virsh define /etc/libvirt/qemu/vm_name.xml
      ​
      现在仍然不能启动虚拟机,因为我们还未配置完成。

      在飞牛OS中,默认的NAT网络并没有启用。我们可以使用如下命令查看:

      root@fnOS:/home/yourname# virsh net-list --all
      Name State Autostart Persistent

      default inactive no yes
      ​
      所以我们需要如下命令去启动它,也把在系统启动时自动启动也打开。

      virsh net-start default
      virsh net-autostart default
      ​
      此时你就可以回到飞牛OS管理页面的虚拟机处重新启动它了。此时的虚拟机就可以使用默认的NAT网络共享宿主机网络联网。

      发布在 日常闲聊
      N
      node-ccccc
    • 记一次zerotier 组网cpu爆炸错误解决

      vps上的接口太多,各种私网,ipv6地址等等
      导致vps只要一启动cpu就爆了
      下面是解决办法

      sudo nano /var/lib/zerotier-one/local.conf
      

      如果提示不能保存就先创建这个文件 ,加权限写
      下面配置是直接监听你vps上的公网,亲测加上后重启zerotier cpu正常

      {
        "settings": {
          "bind": [
            "156.147.125.10",    // 您的公网 IPv4 地址
            "2405:b70:1:100::ab"     // 您的公网 IPv6 地址
          ]
        }
      }
      
      发布在 网络技术
      N
      node-ccccc
    • he-ipv6 隧道 debian设置方法

      1.首先注册账号创建隧道,填写你的vps ip
      2.申请 /48段 ipv6
      3.编辑\ /etc/network/interfaces 文件,原先的不要删,另起一行粘贴\

       nano /etc/network/interfaces
      
      # --- Hurricane Electric IPv6 Tunnel (最终配置方案) ---
      auto sit1
      iface sit1 inet6 static
          # pre-up指令:在配置接口前,先用ip命令创建出sit1这个虚拟隧道设备
          pre-up ip tunnel add sit1 mode sit remote 66.220.18.42 local YOUR_SERVER_IPV4 ttl 255
      
          # 接口IP地址
          # HE分配给你的隧道端点地址,必须保留
          address 2001:150:c:da::2
          netmask 64
      
          # post-up指令:在接口启动后,执行一系列配置命令
          # 添加你选好的、准备用来上网的 /48 段IP地址
          post-up ip -6 addr add 2001:520:1dc0::123/48 dev $IFACE
      
          # 设置安全的MTU值,防止丢包
          post-up ip link set $IFACE mtu 1280
      
          # 【核心】为HE隧道创建一个专用的路由表(表号100),而不是加入主路由表
          post-up ip -6 route add default via 2001:150:c:da::1 dev $IFACE table 100
      
          # 【核心】创建策略路由规则,告诉内核:
          # 只要数据包的源IP是HE的IP,就必须使用表100里的路由
          post-up ip -6 rule add from 2001:150:c:da::/64 table 100
          post-up ip -6 rule add from 2001:520:1dc0::/48 table 100
      
          # pre-down/post-down指令:在关闭接口时,自动清理掉所有配置,非常干净
          pre-down ip -6 rule del from 2001:150:c:da::/64 table 100
          pre-down ip -6 rule del from 2001:520:1dc0::/48 table 100
          post-down ip tunnel del sit1
      # --- HE隧道配置结束 ---
      

      下面给一个临时命令 可以临时生效 不用更改任何配置 终端输入就行了

      ifconfig sit0 up
      ifconfig sit0 inet6 tunnel ::66.220.18.42
      ifconfig sit1 up
      ifconfig sit1 inet6 add 2001:1563:a:d::2/64
      ifconfig sit1 inet6 add 2001:1663:9876::1/48
      ip link set dev sit1 mtu 1280
      ip -6 route add default via 2001:1563:a:d::1 dev sit1 table 100
      ip -6 rule add from 2001:1563:a:d::/64 table 100
      ip -6 rule add from 2001:1663:9876::/48 table 100
      
      发布在 网络技术
      N
      node-ccccc
    • 通过网页连接获取tg群id

      1.首先创建tg群
      2.拉你创建的机器人进你创建的群
      3.打开如下连接,<YourBotToken>替换成你拉近群的机器人token

      https://api.telegram.org/bot<YourBotToken>/getUpdates
      

      4.打开你创建的群,随便发送一条消息
      5.刷新下上面的连接
      6.然后就看到你群组的群id

      发布在 日常闲聊
      N
      node-ccccc
    • docker安装以及docker-compose安装

      一、安装前准备
      确保已安装 Docker
      Docker Compose 依赖 Docker 引擎运行,需先安装 Docker。若未安装,可通过以下命令一键安装:

      bash <(curl -sSL https://linuxmirrors.cn/docker.sh)
      

      二、安装 Docker Compose
      方法 1:通过官方脚本安装(推荐)
      步骤:

      下载二进制文件
      从 GitHub 下载最新版 Docker Compose 的二进制文件:

      sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
      

      国内加速下载(解决 GitHub 访问慢的问题):

      #使用 FastGit 镜像

      sudo curl -L "https://hub.fgit.cf/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
      

      #或使用 ghproxy 代理

      sudo curl -L "https://ghproxy.com/https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
      

      赋予执行权限

      sudo chmod +x /usr/local/bin/docker-compose
      

      (可选)创建符号链接
      将二进制文件链接到 /usr/bin 目录,方便全局调用:

      sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
      

      验证安装

      docker-compose --version
      

      成功安装会显示版本号,例如:Docker Compose version v2.27.0

      发布在 网络技术
      N
      node-ccccc
    • fail2ban 常用命令

      一键安装脚本

      wget https://raw.githubusercontent.com/cnnlei/Fail2ban/master/fail2ban.sh && bash fail2ban.sh 2>&1 | tee fail2ban.log
      

      安装后需要改配置文件,才能正常启动
      fail2ban 132行改成Auto改成systemd,随后重启fail2ban

      vim /etc/fail2ban/jail.conf
      
      systemctl restart fail2ban
      

      启动/停止/重启服务

      sudo systemctl start fail2ban    # 启动服务
      sudo systemctl stop fail2ban     # 停止服务
      sudo systemctl restart fail2ban  # 重启服务
      sudo systemctl enable fail2ban   # 设置开机自启
      

      查看服务状态

      sudo systemctl status fail2ban
      

      查看被封禁的 IP

      sudo fail2ban-client status sshd
      

      解封特定 IP

      sudo fail2ban-client set sshd unbanip 192.168.1.100
      

      手动封禁 IP

      sudo fail2ban-client set sshd banip 192.168.1.100
      
      发布在 网络技术
      N
      node-ccccc
    • 常用vps的一些测试网络工具

      1.测试去程路由

      curl -sL nxtrace.org/nt |bash
      

      用法如下(其中8.8.8.8换成你要测试的ip)

      nexttrace 8.8.8.8
      

      2.tcping工具

      sudo apt install tcptraceroute
      sudo wget http://www.vdberg.org/~richard/tcpping -O /usr/bin/tcping
      sudo chmod +x /usr/bin/tcping
      

      然后是用法(8.8.8.8是地址,53是端口)

      tcping 8.8.8.8 53
      
      发布在 网络技术
      N
      node-ccccc
    • 给你的VPS添加无限个ipv6地址

      ipv6地址在线随机生成
      打开上面的地址,复制你vps的ipv6地址,包括掩码一起复制,然后点击生成,转换成shell指令复制,在vps中ssh粘贴,这样就行了,如果报错就执行如下指令

      apt install sudo
      
      发布在 网络技术
      N
      node-ccccc
    • Linux/VPS屏蔽指定国家IP(ipv4)

      前言
      ipset 是 iptables 的扩展,它允许你创建匹配整个 IP 地址集合的规则。可以快速的让我们屏蔽某个 IP 段。这里分享一个屏蔽指定国家的 IP 访问的方法和一个屏蔽国外 IP 访问(仅允许国内 IP 访问)的方法,当我们遇到 CC 攻击,可以尝试选择和使用能有所缓解。

      屏蔽指定国家的IP
      首先需要得到国家 IP 段,下载地址:http://www.ipdeny.com/ipblocks/。这里以我们国家为例。

      1、安装 ipset

      #Debian/Ubuntu系统

      apt-get -y install ipset
      

      #CentOS系统

      yum -y install ipset
      

      2、创建规则(这里已国内ip为例)

      #创建一个名为cnip的规则

      ipset -N cnip hash:net
      

      #下载国家IP段

      wget -P . http://www.ipdeny.com/ipblocks/data/countries/cn.zone
      

      #将IP段添加到cnip规则中

      for i in $(cat /root/cn.zone ); do ipset -A cnip $i; done
      

      3、禁用tcp连接

      iptables -I INPUT -p tcp -m set --match-set cnip src -j DROP
      

      4、禁用udp连接

      iptables -I INPUT -p udp -m set --match-set cnip src -j DROP
      

      5、禁用单个tcp端口

      iptables -I INPUT -p tcp --dport 12345 -m set --match-set cnip src -j DROP
      

      6、禁用单个udp端口

      iptables -I INPUT -p udp --dport 12345 -m set --match-set cnip src -j DROP
      

      7、禁用多个tcp端口

      iptables -I INPUT -p tcp -m multiport --dports 35761,38707 -m set --match-set cnip src -j DROP
      
      发布在 网络技术
      N
      node-ccccc
    • Debian 12 解决 /etc/rc.local 开机启动问题

      由于某些软件并没有增加开启启动的服务,很多时候需要手工添加,一般我们都是推荐使用 systemd 写个系统服务,但是对于一些简单的脚本或者懒人来说,添加命令到 /etc/rc.local 文件更方便,但是自从 Debian 9 开始,Debian 默认不带 /etc/rc.local 文件,而 rc.local 服务却还是自带的:

      cat /lib/systemd/system/rc-local.service
      

      root@debian ~ # cat /lib/systemd/system/rc-local.service
      SPDX-License-Identifier: LGPL-2.1-or-later
      This file is part of systemd.
      systemd is free software; you can redistribute it and/or modify it
      under the terms of the GNU Lesser General Public License as published by
      the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

      This unit gets pulled automatically into multi-user.target by
      systemd-rc-local-generator if /etc/rc.local is executable.
      [Unit]
      Description=/etc/rc.local Compatibility
      Documentation=man:systemd-rc-local-generator(8)
      ConditionFileIsExecutable=/etc/rc.local
      After=network.target

      [Service]
      Type=forking
      ExecStart=/etc/rc.local start
      TimeoutSec=0
      RemainAfterExit=yes
      GuessMainPID=no
      并且默认情况下这个服务还是关闭的状态:

      systemctl status rc-local
      

      root@debian ~ # systemctl status rc-local
      ● rc-local.service - /etc/rc.local Compatibility
      Loaded: loaded (/lib/systemd/system/rc-local.service; static)
      Drop-In: /usr/lib/systemd/system/rc-local.service.d
      └─debian.conf
      Active: inactive (dead)
      Docs: man:systemd-rc-local-generator(8)
      为了解决这个问题,我们需要手工添加一个 /etc/rc.local 文件:

      cat <<EOF >/etc/rc.local
      #!/bin/sh -e
      #
      # rc.local
      #
      # This script is executed at the end of each multiuser runlevel.
      # Make sure that the script will "exit 0" on success or any other
      # value on error.
      #
      # In order to enable or disable this script just change the execution
      # bits.
      #
      # By default this script does nothing.
      
      exit 0
      EOF
      

      然后赋予权限:

      chmod +x /etc/rc.local
      

      接着启动 rc-local 服务:

      systemctl enable --now rc-local
      

      此时可能会弹出警告:

      The unit files have no installation config (WantedBy=, RequiredBy=, Also=,
      Alias= settings in the [Install] section, and DefaultInstance= for template
      units). This means they are not meant to be enabled using systemctl.

      Possible reasons for having this kind of units are:
      • A unit may be statically enabled by being symlinked from another unit's
      .wants/ or .requires/ directory.
      • A unit's purpose may be to act as a helper for some other unit which has
      a requirement dependency on it.
      • A unit may be started when needed via activation (socket, path, timer,
      D-Bus, udev, scripted systemctl call, ...).
      • In case of template units, the unit is meant to be enabled with some
      instance name specified.
      无视警告,因为这个服务没有任何依赖的系统服务,只是开机启动 /etc/rc.local 脚本而已。

      systemctl status rc-local.service
      

      再次查看状态:
      root@debian ~ # systemctl status rc-local.service
      ● rc-local.service - /etc/rc.local Compatibility
      Loaded: loaded (/lib/systemd/system/rc-local.service; enabled-runtime; vendor preset: enabled)
      Drop-In: /usr/lib/systemd/system/rc-local.service.d
      └─debian.conf
      Active: active (exited) since Thu 2022-01-27 18:52:43 UTC; 10s ago
      Docs: man:systemd-rc-local-generator(8)
      Process: 541 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)
      CPU: 3ms

      Jan 27 18:52:43 debian systemd[1]: Starting /etc/rc.local Compatibility...
      Jan 27 18:52:43 debian systemd[1]: Started /etc/rc.local Compatibility.

      然后你就可以把需要开机启动的命令添加到 /etc/rc.local 文件,丢在 exit 0 前面即可,并尝试重启以后试试是否生效了.

      发布在 网络技术
      N
      node-ccccc