跳转到内容

博客

从源代码安装 Qt

0.简介通过本地编译从 opensouce 安装 Qt。

Section titled “0.简介通过本地编译从 opensouce 安装 Qt。”

以Qt-5.15.2为例。

wget http://mirrors.ustc.edu.cn/qtproject/official_releases/qt/5.15/5.15.2/single/qt-everywhere-src-5.15.2.tar.xz

## 2.安装依赖并解压```
sudo apt install libX11-dev libXext-dev libXtst-dev -y
tar -xvf qt-everywhere-src-5.15.2.tar.xz

cd qt-everywhere-src-5.15.2 ./configure -prefix /usr/local/qt-5.15.2 -opensource -developer-build
-confirm-license -nomake tests -nomake examples

## 4.制作并安装```
make -j8
sudo make install

由于上面的配置,Qt 将安装到/usr/local/qt-5.15.2。

[2]. http://mirrors.ustc.edu.cn/help/qtproject.html

Mikrotik 上的容器

0. 简介从 Mikrotik ROS 7.4 Beta 4 开始,Mikrotik 添加了 Container 的新功能。

Section titled “0. 简介从 Mikrotik ROS 7.4 Beta 4 开始,Mikrotik 添加了 Container 的新功能。”

配置基于 Mikrotik RouterOS 7.13.1 。

使用以下命令登录 RouterOS 中的终端:``` /system/device-mode/update container=yes

> 如果在 X86 上使用容器,您将需要按下重置按钮或冷重启来确认设备模式。
## 2. 创建网络### 桥接模式#### (1).为容器添加bridge veth接口:```
/interface/veth/add name=veth1 address=172.17.0.2/24 gateway=172.17.0.1

(2)。为容器创建一个桥并向其中添加 veth:

Section titled “(2)。为容器创建一个桥并向其中添加 veth:”
/interface/bridge/add name=containers
/ip/address/add address=172.17.0.1/24 interface=containers
/interface/bridge/port add bridge=containers interface=veth1
/ip/firewall/nat/add chain=srcnat action=masquerade src-address=172.17.0.0/24

主机模式(Linux 设备上的 macvlan)

Section titled “主机模式(Linux 设备上的 macvlan)”
/interface/veth/add name=veth1 address=LAN_ADDRESS gateway=GATE_WAY_OF_LAN

(2)。将 veth 添加到 LAN 桥接器

Section titled “(2)。将 veth 添加到 LAN 桥接器”
/interface/bridge/port add bridge=LAN_BRIDGE interface=veth1
/container/mounts/add name=smartdns src=/smartdns.conf dst=/etc/smartdns/smartdns.conf
/container/config/set registry-url=https://registry-1.docker.io
/container/add remote-image=dashdreams/smartdns:latest interface=veth1 \
root-dir=/smartdns hostname=smartdns mounts=smartdns workdir=/root
/container/add file=smartdns.tar interface=veth1 root-dir=/smartdns \
hostname=smartdns mounts=smartdns workdir=/root
/container/start 0

6. 将端口转发到内部容器(可选)可以使用 dst-nat 转发端口(其中 192.168.88.1 路由器 IP 地址):

Section titled “6. 将端口转发到内部容器(可选)可以使用 dst-nat 转发端口(其中 192.168.88.1 路由器 IP 地址):”
/ip firewall nat
add action=dst-nat chain=dstnat dst-address=192.168.88.1 dst-port=5353 protocol=tcp to-addresses=172.17.0.2 to-ports=53
docker pull dashdreams/smartdns:latest@sha256:XXXXXXXXXXXXXXXXXXXXXXX
docker save dashdreams/smartdns > smartdns.tar

[2]. http://www.irouteros.com/?p=2712

[3]. 使用 Podman 构建容器映像

在 Mikrotik RouterOS v7.x 上配置 IPv6## 0. 简介Mikrotik RouterOS 上的 IPv6 配置比 ASUS 上的 Merlin 复杂得多。我们将在本文中配置 IPv6。

配置基于 Mikrotik RouterOS 7.6。

1. 配置 DHCPv6 客户端使用以下命令登录 RouterOS 中的终端:```

Section titled “1. 配置 DHCPv6 客户端使用以下命令登录 RouterOS 中的终端:```”

Accept ISP RA, Get IPv6 Address with SLAAC

Section titled “Accept ISP RA, Get IPv6 Address with SLAAC”

/ipv6 settings set accept-router-advertisements=yes

- IPv6 address pool: IPv6 (You can change to whatever you want)

Section titled “- IPv6 address pool: IPv6 (You can change to whatever you want)”

- Prefix length for DHCPv6 server’s offering cascading routers: 60

Section titled “- Prefix length for DHCPv6 server’s offering cascading routers: 60”

/ipv6 dhcp-client add add-default-route=no interface=pppoe-ether1 \ pool-name=IPv6 pool-prefix-length=60
request=prefix

江苏南京移动提供/60前缀,如果前缀长度小于/63,则无法使用DHCPv6。
## 2.添加必要的IPv6防火墙规则```
# Accept DHCPv6 client prefix delegation
/ipv6 firewall filter add action=accept chain=input \
comment="Accept DHCPv6 client prefix delegation" \
dst-port=546 protocol=udp src-address=fe80::/10

如果您使用默认脚本配置了路由器,则此规则是默认的。

/ipv6 address add address=::1 from-pool=IPv6 interface=bridge

## 4.配置DHCPv6-PD服务器```
# Delegate IPv6 addresses from pool `delegation`
# Lease is valid for 1 day
/ipv6 dhcp-server add address-pool=IPv6 \
interface=bridge lease-time=7d name=Home-IPv6

基于RouterOS和Openwrt的IP地址列表分发

0. 简介通过 CNIP 分配 IP 地址列表。

Section titled “0. 简介通过 CNIP 分配 IP 地址列表。”

配置基于 Mikrotik RouterOS 7.6。

1. 要求需要 Openwrt 的旁路路由器。

Section titled “1. 要求需要 Openwrt 的旁路路由器。”

2. 获取CN IP地址列表CN IP地址列表可以从以下位置找到

Section titled “2. 获取CN IP地址列表CN IP地址列表可以从以下位置找到”

[叮当网] [IPIP] [RealIP数据库] 在Linux上运行以下脚本可以获取CN IP列表:``` curl ’http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest'|\ grep ipv6 | grep CN | awk -F|
‘{ printf(“%s/%d\n”, $4, 32-log($5)/log(2)) }’ |
sed -e ‘s/^/add address=/g’ -e ‘s/$/ list=CNIP/g’|
sed -e $‘1i\\n/ipv6 firewall address-list’ \
-e $‘1i\\nremove [/ipv6 firewall address-list find list=CNIP]’|\
sed ‘$a /file remove CNIPv6.rsc’>CNIPv6.rsc

curl ’http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest'|\ grep ipv4 | grep CN | awk -F|
‘{ printf(“%s/%d\n”, $4, 32-log($5)/log(2)) }’ |\ sed -e ‘s/^/add address=/g’ -e ‘s/$/ list=CNIP/g’ \
-e ‘s/$/ comment=“CNIP”/g’ |\
sed -e $‘1i\\n/ip firewall address-list’ \
-e $‘1i\\nremove [/ip firewall address-list find list=CNIP]’ |\
sed ‘$a /’ |sed ‘$a /file remove CNIPv4.rsc’>CNIPv4.rsc

> 包含 IPv6 和 IPv4 地址。
地址列表可能如下所示:```
/ip firewall address-list
add list=CNIP address=x.x.x.x/xx
add list=CNIP address=x.x.x.x/xx
...
...
...
add list=CNIP address=x.x.x.x/xx

3. 分发配置### (1).导入 CN IP 列表打开 WinBox,并将 CNIPv4.rsc 上传到 RouterOS,然后打开Terminal,然后运行 ​​import CNIPv4.rsc。

Section titled “3. 分发配置### (1).导入 CN IP 列表打开 WinBox,并将 CNIPv4.rsc 上传到 RouterOS,然后打开Terminal,然后运行 ​​import CNIPv4.rsc。”

(2)。添加路由表在Terminal中运行命令:/routing/tables/add name=OP fib

Section titled “(2)。添加路由表在Terminal中运行命令:/routing/tables/add name=OP fib”

(3)。添加代理设备列表在Firewall中添加代理列表:```

Section titled “(3)。添加代理设备列表在Firewall中添加代理列表:```”

/ip/firewall/address-list/add name=proxy address=192.168.1.1-192.168.1.200

> 我们将 IP 地址范围 192.168.1.1--192.168.1.200 添加到代理列表中。
### (4)。 Mangle 非 CN IP 连接标记非CN IP目的地址```
add action=mark-routing chain=prerouting comment="ProxyRoute" \
src-address=proxy dst-address=!CNIP dst-address-type=!local \
new-routing-mark=OP passthrough=yes

添加另一条规则以接受openwrt的流量``` add action=accept chain=prerouting comment=“BypassOP”
src-address=192.168.1.254

> 假设openwrt的本地ip是`192.168.1.254`
### (5)。配置路由表配置到openwrt的路由表:```
/ip/route/add dst-address=0.0.0.0 gateway=192.168.1.254 \
check-getway=ping routing-table=OP distance=1 \
scope=30 target-scope=10

(6)。更改PPPOE距离将PPPOE的距离更改为2:```

Section titled “(6)。更改PPPOE距离将PPPOE的距离更改为2:```”

/interface/pppoe-client/set pppoe-CMCC default-route-distance=2

## 4. 如果绕过路由器关闭,则更改分配### (1).目的- openwrt down时的关闭分配- openwrt启动时开启分配
### (2)。配置网络监视```
/tool/netwatch/add host=192.168.1.254 type=simple interval=60 \
up-script=OPUP.rsc down-script=OPDOWN.rsc

(3)。编辑向上和向下脚本向上脚本:```

Section titled “(3)。编辑向上和向下脚本向上脚本:```”

add dont-require-permissions=yes name=OPUP.rsc owner=admin policy=
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=“/
ip firewall mangle enable number=???\r
\n/ip firewall mangle enable number=???\r
\n/ip route enable number=0\r
\n/ip/dns/cache/flush”

向下脚本:```
add dont-require-permissions=yes name=OPDOWN.rsc owner=admin policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="/\
ip firewall mangle disable number=???\r\
\n/ip firewall mangle disable number=???\r\
\n/ip route disable number=0\r\
\n/ip/dns/cache/flush"

???是[MangleRules]中设置的mangle规则的索引号

[2]. https://idndx.com/high-availability-when-split-routing-using-routeros-and-raspberrypi/

[3]. 使用 SmartDNS 进行 DNS 分配 [4]. IPv6-在 Mikrotik-RouterOS-v7.x 上配置 [Clang.CN]:https://ispip.clang.cn/all_cn_cidr.txt[IPIP]:https://github.com/17mon/china_ip_list[RealIP数据库]:https://github.com/metowolf/iplist[MangleRules]:基于 RouterOS 和 Openwrt.md#4-mangle-non-cn-ip-connections 的 IP 地址列表分发

Mount Disk in Linux on Boot

开机自动挂载硬盘

在挂载磁盘前,需要知道每个磁盘的路径或UUID,此时主要依靠fdisk和blkid两个指令,前一个指令获取分区信息,后一个指令获取Block device块设备的属性。

$ sudo blkid
/dev/sda1: LABEL="Win10" UUID="C4A0E65EA0E65708" TYPE="ntfs" PARTUUID="6190c592-01"
/dev/sda2: UUID="AE3C137D3C133FAF" TYPE="ntfs" PARTUUID="6190c592-02"
/dev/sdb1: LABEL="Apps" UUID="0000678400004823" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="45ed07d2-c9e3-4167-8868-3e33f62784e1"
/dev/sdb2: LABEL="Data" UUID="0000678400004823" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="2a8b4bf1-8357-4d65-bed4-f73f01b96431"
/dev/sdb3: LABEL="Backup" UUID="0000678400004823" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="a7187083-2820-4eef-83ff-05d8899879a2"

从上面的输出结果就可以将磁盘对应到具体的块设备路径/dev/sdax,因为电脑含两块磁盘,所以包含sda及sdb。这里的块设备路径和UUID会将下面的配置参数中用到。

对于临时解决方案,可以使用以下指令将/dev/sda1挂载到/mnt/c目录

sudo mkdir /mnt/c
sudo mount -t ntfs /dev/sda1 /mnt/c

开机启动后自动挂载的方案就需要修改配置文件/etc/fstab,使用编辑器打开后,按以下格式添加新的挂载项

$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sdb5 during installation
UUID=4d2e5a83-d9fe-47bb-aa02-fee9ac8535e3 / ext4 errors=remount-ro 0 1
# /boot was on /dev/sdb6 during installation
UUID=9b521dc2-ad85-4ca6-bb8b-f285b312aa49 /boot ext4 defaults 0 2
# /home was on /dev/sdb7 during installation
UUID=f6b796dd-9e59-4f79-b70a-c2c8e5977163 /home ext4 defaults 0 2
# swap was on /dev/sdb4 during installation
UUID=9430ea0e-7ff9-4167-9bf7-1f3e08d26d34 none swap sw 0 0
# /mnt/Data was on /dev/sdb2 during installation
/dev/sdb2 /mnt/Data ntfs defaults 0 2
# /mnt/Backup was on /dev/sdb3 during installation
/dev/sdb3 /mnt/Backup ntfs defaults 0 2

后面两项就是用来挂载磁盘的,当然每行前面的/dev/sdbx也可以换成UUID=xxxxx,但是由于这两个磁盘的UUID一致,所以可能会有问题,也许可以使用blkid输出的PARTUUID。

sudo mkdir /mnt/{Data,Backup}
sudo mount -a

利用systemd 开机自动挂载smb

# This is a sample service script to mount CIFS/SAMBA shares.
# Please read carefully the comments in this file. For production usage
# you can remove all comments (lines beginning with "#") from this file.
[Unit]
# The description should be used to explain what this servicefile is for
Description=nas cifs mount home
# if we do network mounts like here we *require* 'network-online.service'
# which checks if the network is online
Requires=network-online.target
# our scripts must start *after* 'network-online.service', on timeout and if
# 'network-online.service' fails we can not mount and this scripts fails too
After=network-online.target
# usually we mount networks shares because we want they avaible *before* XBMC starts.
# so XBMC has access to this mounts from beginning. Note: this slows down the boot!
#Before=kodi.service
[Mount]
# The share we want mount
What=//IP_ADDRESS/Data
# Where we want mount this share
Where=/PATH_TO_MOUNT
# Any options you usually use with the "-o" parameter in the mount command
Options=username=haoran.qi,password=password,rw,vers=3.0,dir_mode=0775,file_mode=0664
# filesystem type
Type=cifs
[Install]
WantedBy=multi-user.target

[1]. https://www.litreily.top/2019/02/17/mount/