9月 102021
 

获取时间戳

[root@s6 ~]# date +%s%N
1634089185225960225
[root@s6 ~]#

获取系统的唯一性ID

[root@s6 ~]# cat /etc/machine-id 
52e2104a451e6cc4c0cd3f75608ba59f
[root@s6 ~]#

通过hostnamectl查看

[root@s6 ~]# hostnamectl 
Static hostname: s6.linuxcache.com
Icon name: computer-vm
Chassis: vm
Machine ID: 52e2104a451e6cc4c0cd3f75608ba59f
Boot ID: 7b76dcb309d94c908ec297b10998cd38
Virtualization: kvm
Operating System: Fedora 34 (Server Edition)
CPE OS Name: cpe:/o:fedoraproject:fedora:34
Kernel: Linux 5.11.12-300.fc34.x86_64
Architecture: x86-64
Hardware Vendor: Vultr
Hardware Model: HFC
[root@s6 ~]#

拼接timestamp和machine-id并使用sha1算法计算校验值

printf <timestamp><machine-id> | sha1sum
printf 163408918522596022552e2104a451e6cc4c0cd3f75608ba59f | sha1sum

计算校验值

[root@s6 ~]# printf 163408918522596022552e2104a451e6cc4c0cd3f75608ba59f | sha1sum
e4819b79f35d65e8231cb7e23bf61fc76aab5571 -
[root@s6 ~]#

截取后5位16进制值

printf e4819b79f35d65e8231cb7e23bf61fc76aab5571 | cut -c 31-

截取成功

[root@s6 ~]# printf e4819b79f35d65e8231cb7e23bf61fc76aab5571 | cut -c 31-
c76aab5571
[root@s6 ~]#

拼接前缀

fd c7 6a ab 55 71
fdc7:6aab:5571::/64
使用ipcalc命令计算子网信息

[root@s6 ~]# ipcalc -6 fdc7:6aab:5571::/64
Full Network: fdc7:6aab:5571:0000:0000:0000:0000:0000/64
Network: fdc7:6aab:5571::/64
Netmask: ffff:ffff:ffff:ffff:: = 64

Address space: Unique Local Unicast
HostMin: fdc7:6aab:5571::
HostMax: fdc7:6aab:5571:0:ffff:ffff:ffff:ffff
Hosts/Net: 2^(64) = 18446744073709551616
[root@s6 ~]#

 

 

 

9月 092021
 

原文

3.2.2. Sample Code for Pseudo-Random Global ID Algorithm

The algorithm described below is intended to be used for locally
assigned Global IDs. In each case the resulting global ID will be
used in the appropriate prefix as defined in Section 3.2.

1) Obtain the current time of day in 64-bit NTP format [NTP].

2) Obtain an EUI-64 identifier from the system running this
algorithm. If an EUI-64 does not exist, one can be created from
a 48-bit MAC address as specified in [ADDARCH]. If an EUI-64
cannot be obtained or created, a suitably unique identifier,
local to the node, should be used (e.g., system serial number).

3) Concatenate the time of day with the system-specific identifier
in order to create a key.

4) Compute an SHA-1 digest on the key as specified in [FIPS, SHA1];
the resulting value is 160 bits.

5) Use the least significant 40 bits as the Global ID.

6) Concatenate FC00::/7, the L bit set to 1, and the 40-bit Global
ID to create a Local IPv6 address prefix.

This algorithm will result in a Global ID that is reasonably unique
and can be used to create a locally assigned Local IPv6 address
prefix.

内容引用:

Unique Local IPv6 Unicast Addresses

9月 062021
 

客户端标准配置文件

[Interface]
PrivateKey = 
Address = 172.16.0.1/24
DNS = 8.8.8.8, 8.8.4.4

[Peer]
PublicKey = 
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = hostname.com:51820
PersistentKeepalive = 25

生成二维码

方式1

$ qrencode -t ansiutf8 -r client.conf

方式2

$ qrencode -t ansiutf8 < client.conf

方式3

$ qrencode -t png -o client.png -r client.conf
8月 252021
 

AnyConnect Deployment Overview
Deploying AnyConnect refers to installing, configuring, and upgrading the AnyConnect client and its related files.

The Cisco AnyConnect Secure Mobility Client can be deployed to remote users by the following methods:

Predeploy—New installations and upgrades are done either by the end user, or by using an enterprise software management system (SMS).

Web Deploy—The AnyConnect package is loaded on the headend, which is either an ASA or FTD firewall, or an ISE server. When the user connects to a firewall or to ISE, AnyConnect is deployed to the client.

For new installations, the user connects to a headend to download the AnyConnect client. The client is either installed manually or automatically (web-launch).

Updates are done by AnyConnect running on a system where AnyConnect is already installed, or by directing the user to the ASA clientless portal.

When you deploy AnyConnect, you can include optional modules that enable extra features, and client profiles that configure the VPN and optional features.

Refer to the AnyConnect release notes for system, management, and endpoint requirements for ASA, IOS, Microsoft Windows, Linux, and macOS.

内容引用:

Cisco AnyConnect Secure Mobility Client Administrator Guide, Release 4.0 – Deploy AnyConnect [Cisco AnyConnect Secure Mobility Client] – Cisco

8月 052021
 

通过查看dmesg信息获取当前文本终端的默认显示分辨率

[ 4.426948] [drm] DMA map mode: Caching DMA mappings.
[ 4.427281] [drm] Capabilities:
[ 4.427282] [drm] Rect copy.
[ 4.427282] [drm] Cursor.
[ 4.427283] [drm] Cursor bypass.
[ 4.427283] [drm] Cursor bypass 2.
[ 4.427283] [drm] 8bit emulation.
[ 4.427284] [drm] Alpha cursor.
[ 4.427284] [drm] 3D.
[ 4.427284] [drm] Extended Fifo.
[ 4.427284] [drm] Multimon.
[ 4.427285] [drm] Pitchlock.
[ 4.427285] [drm] Irq mask.
[ 4.427285] [drm] Display Topology.
[ 4.427286] [drm] GMR.
[ 4.427286] [drm] Traces.
[ 4.427286] [drm] GMR2.
[ 4.427286] [drm] Screen Object 2.
[ 4.427287] [drm] Command Buffers.
[ 4.427287] [drm] Command Buffers 2.
[ 4.427287] [drm] Guest Backed Resources.
[ 4.427288] [drm] DX Features.
[ 4.427288] [drm] HP Command Queue.
[ 4.427288] [drm] Capabilities2:
[ 4.427289] [drm] Grow oTable.
[ 4.427289] [drm] IntraSurface copy.
[ 4.427289] [drm] DX3.
[ 4.427290] [drm] Max GMR ids is 64
[ 4.427291] [drm] Max number of GMR pages is 65536
[ 4.427292] [drm] Max dedicated hypervisor surface memory is 0 kiB
[ 4.427292] [drm] Maximum display memory size is 262144 kiB
[ 4.427293] [drm] VRAM at 0xe8000000 size is 131072 kiB
[ 4.427294] [drm] MMIO at 0xfe000000 size is 256 kiB
[ 4.437927] [TTM] Zone kernel: Available graphics memory: 996108 KiB
[ 4.464121] [drm] Screen Target Display device initialized
[ 4.464193] [drm] width 1280
[ 4.464211] [drm] height 768
[ 4.464229] [drm] bpp 32
[ 4.493584] [drm] Fifo max 0x00040000 min 0x00001000 cap 0x0000077f
[ 4.591064] [drm] Using command buffers with DMA pool.
[ 4.594738] [drm] Atomic: yes.
[ 4.594741] [drm] SM5 support available.

通过hwinfo命令查看当前可用的分辨率模式

[root@fedora ~]# hwinfo --framebuffer
02: None 00.0: 11001 VESA Framebuffer 
[Created at bios.459]
Unique ID: rdCR.O3PgoQaqFo1
Hardware Class: framebuffer
Model: "VMware virtual machine"
Vendor: "VMware, Inc"
Device: "VMware virtual machine"
SubVendor: "V M ware, Inc. VBE support 2.0"
SubDevice: 
Revision: "2.0"
Memory Size: 0 MB
Memory Range: 0xe8000000-??? (rw)
Mode 0x0300: 640x400 (+640), 8 bits
Mode 0x0301: 640x480 (+640), 8 bits
Mode 0x0303: 800x600 (+800), 8 bits
Mode 0x0305: 1024x768 (+1024), 8 bits
Mode 0x0307: 1280x1024 (+1280), 8 bits
Mode 0x030e: 320x200 (+640), 16 bits
Mode 0x0311: 640x480 (+1280), 16 bits
Mode 0x0314: 800x600 (+1600), 16 bits
Mode 0x0317: 1024x768 (+2048), 16 bits
Mode 0x031a: 1280x1024 (+2560), 16 bits
Mode 0x0320: 320x200 (+320), 8 bits
Mode 0x0321: 320x400 (+320), 8 bits
Mode 0x0322: 640x400 (+640), 8 bits
Mode 0x0323: 640x480 (+640), 8 bits
Mode 0x0324: 800x600 (+800), 8 bits
Mode 0x0325: 1024x768 (+1024), 8 bits
Mode 0x0326: 1152x864 (+1152), 8 bits
Mode 0x0327: 1280x960 (+1280), 8 bits
Mode 0x0328: 1280x1024 (+1280), 8 bits
Mode 0x0329: 1400x1050 (+1408), 8 bits
Mode 0x032a: 1600x1200 (+1600), 8 bits
Mode 0x032b: 1792x1344 (+1792), 8 bits
Mode 0x032c: 1856x1392 (+1856), 8 bits
Mode 0x032d: 1920x1440 (+1920), 8 bits
Mode 0x032e: 320x200 (+640), 16 bits
Mode 0x032f: 320x400 (+640), 16 bits
Mode 0x0330: 640x400 (+1280), 16 bits
Mode 0x0331: 640x480 (+1280), 16 bits
Mode 0x0332: 800x600 (+1600), 16 bits
Mode 0x0333: 1024x768 (+2048), 16 bits
Mode 0x0334: 1152x864 (+2304), 16 bits
Mode 0x0335: 1280x960 (+2560), 16 bits
Mode 0x0336: 1280x1024 (+2560), 16 bits
Mode 0x0337: 1400x1050 (+2816), 16 bits
Mode 0x0338: 1600x1200 (+3200), 16 bits
Mode 0x0339: 1792x1344 (+3584), 16 bits
Mode 0x033a: 1856x1392 (+3712), 16 bits
Mode 0x033b: 1920x1440 (+3840), 16 bits
Mode 0x033c: 320x200 (+1280), 24 bits
Mode 0x033d: 320x400 (+1280), 24 bits
Mode 0x033e: 640x400 (+2560), 24 bits
Mode 0x033f: 640x480 (+2560), 24 bits
Mode 0x0340: 800x600 (+3200), 24 bits
Mode 0x0341: 1024x768 (+4096), 24 bits
Mode 0x0342: 1152x864 (+4608), 24 bits
Mode 0x0343: 1280x960 (+5120), 24 bits
Mode 0x0344: 1280x1024 (+5120), 24 bits
Mode 0x0345: 1400x1050 (+5600), 24 bits
Mode 0x0346: 1600x1200 (+6400), 24 bits
Mode 0x0347: 1792x1344 (+7168), 24 bits
Mode 0x0348: 1856x1392 (+7424), 24 bits
Mode 0x0349: 1920x1440 (+7680), 24 bits
Mode 0x034a: 1366x768 (+1376), 8 bits
Mode 0x034b: 1366x768 (+2752), 16 bits
Mode 0x034c: 1366x768 (+5472), 24 bits
Mode 0x034d: 1680x1050 (+1696), 8 bits
Mode 0x034e: 1680x1050 (+3360), 16 bits
Mode 0x034f: 1680x1050 (+6720), 24 bits
Mode 0x0350: 1920x1200 (+1920), 8 bits
Mode 0x0351: 1920x1200 (+3840), 16 bits
Mode 0x0352: 1920x1200 (+7680), 24 bits
Mode 0x0353: 2048x1536 (+2048), 8 bits
Mode 0x0354: 2048x1536 (+4096), 16 bits
Mode 0x0355: 2048x1536 (+8192), 24 bits
Mode 0x0356: 320x240 (+320), 8 bits
Mode 0x0357: 320x240 (+640), 16 bits
Mode 0x0358: 320x240 (+1280), 24 bits
Mode 0x0359: 400x300 (+416), 8 bits
Mode 0x035a: 400x300 (+800), 16 bits
Mode 0x035b: 400x300 (+1600), 24 bits
Mode 0x035c: 512x384 (+512), 8 bits
Mode 0x035d: 512x384 (+1024), 16 bits
Mode 0x035e: 512x384 (+2048), 24 bits
Mode 0x035f: 854x480 (+864), 8 bits
Mode 0x0360: 854x480 (+1728), 16 bits
Mode 0x0361: 854x480 (+3424), 24 bits
Mode 0x0362: 1280x720 (+1280), 8 bits
Mode 0x0363: 1280x720 (+2560), 16 bits
Mode 0x0364: 1280x720 (+5120), 24 bits
Mode 0x0365: 1920x1080 (+1920), 8 bits
Mode 0x0366: 1920x1080 (+3840), 16 bits
Mode 0x0367: 1920x1080 (+7680), 24 bits
Mode 0x0368: 1280x800 (+1280), 8 bits
Mode 0x0369: 1280x800 (+2560), 16 bits
Mode 0x036a: 1280x800 (+5120), 24 bits
Mode 0x036b: 1440x900 (+1440), 8 bits
Mode 0x036c: 1440x900 (+2880), 16 bits
Mode 0x036d: 1440x900 (+5760), 24 bits
Mode 0x036e: 720x480 (+736), 8 bits
Mode 0x036f: 720x480 (+1440), 16 bits
Mode 0x0370: 720x480 (+2880), 24 bits
Mode 0x0371: 720x576 (+736), 8 bits
Mode 0x0372: 720x576 (+1440), 16 bits
Mode 0x0373: 720x576 (+2880), 24 bits
Mode 0x0374: 800x480 (+800), 8 bits
Mode 0x0375: 800x480 (+1600), 16 bits
Mode 0x0376: 800x480 (+3200), 24 bits
Mode 0x0377: 1280x768 (+1280), 8 bits
Mode 0x0378: 1280x768 (+2560), 16 bits
Mode 0x0379: 1280x768 (+5120), 24 bits
Config Status: cfg=new, avail=yes, need=no, active=unknown
[root@fedora ~]#

修改文本终端分辨率模式的三种方法

1)在Linux启动阶段输出可用分辨率模式并由用户选择

vga=ask

2)在Linux启动阶段手动添加分辨率模式参数

vga=0x0364

3)修改GRUB2引导菜单配置,永久新增分辨率模式参数

[root@fedora ~]# grubby --default-kernel
/boot/vmlinuz-5.11.12-300.fc34.x86_64
[root@fedora ~]# grubby --args="vga=0x0364" --update-kernel /boot/vmlinuz-5.11.12-300.fc34.x86_64
[root@fedora ~]#

修改GRUB2引导菜单配置并重启后查看GRUB2引导菜单的变化

查看分辨率为1280*720的虚拟机文本终端窗口

https://docs.fedoraproject.org/en-US/fedora/rawhide/system-administrators-guide/kernel-module-driver-configuration/Working_with_the_GRUB_2_Boot_Loader/#sec-Making_Persistent_Changes_to_a_GRUB_2_Menu_Using_the_grubby_Tool
7月 302021
 

视频分辨率和宽高比

YouTube 会根据所用的平台和视频格式,以不同的宽高比播放视频。YouTube 视频播放器会自动根据每个视频的尺寸调整大小。

视频显示方式
YouTube 在计算机上的标准宽高比为 16:9。如果您的视频具有不同的宽高比,则播放器将自动变为理想尺寸以匹配您的视频和观看者的设备。

对于某些视频和设备宽高比(例如计算机浏览器中显示的 9:16 竖版视频),YouTube 可能会添加额外的内边框以实现理想的观看效果。内边框默认为白色,但在启用“深色主题背景”的情况下为深灰色。

为了实现理想效果,请避免直接在视频中添加内边框或黑边。视频自带的内边框会干扰 YouTube 根据您的视频尺寸和观看者的设备动态调整播放器的能力。

推荐的分辨率和宽高比

对于默认的 16:9 宽高比,请按以下分辨率进行编码:

2160p:3840x2160
1440p:2560x1440
1080p:1920x1080
720p:1280x720
480p:854x480
360p:640x360
240p:426x240

https://support.google.com/youtube/answer/6375112?hl=zh-Hans

7月 152021
 

INSTALLED_APPS 默认包括了以下 Django 的自带应用:

django.contrib.admin -- 管理员站点, 你很快就会使用它。
django.contrib.auth -- 认证授权系统。
django.contrib.contenttypes -- 内容类型框架。
django.contrib.sessions -- 会话框架。
django.contrib.messages -- 消息框架。
django.contrib.staticfiles -- 管理静态文件的框架。

默认开启的某些应用需要至少一个数据表,所以,在使用他们之前需要在数据库中创建一些表。migrate 命令检查 INSTALLED_APPS 设置,为其中的每个应用创建需要的数据表。

$ python manage.py migrate

迁移模型

通过运行 makemigrations 命令,Django 会检测你对模型文件的修改(在这种情况下,你已经取得了新的),并且把修改的部分储存为一次 迁移。
迁移是 Django 对于模型定义(也就是你的数据库结构)的变化的储存形式。

(venv) harveymei@MacBookAir mysite % python manage.py makemigrations polls
Migrations for 'polls':
polls/migrations/0001_initial.py
- Create model Question
- Create model Choice
(venv) harveymei@MacBookAir mysite %

查看迁移命令将会执行的SQL语句

(venv) harveymei@MacBookAir mysite % python manage.py sqlmigrate polls 0001
BEGIN;
--
-- Create model Question
--
CREATE TABLE "polls_question" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "question_text" varchar(200) NOT NULL, "pub_date" datetime NOT NULL);
--
-- Create model Choice
--
CREATE TABLE "polls_choice" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "choice_text" varchar(200) NOT NULL, "votes" integer NOT NULL, "question_id" bigint NOT NULL REFERENCES "polls_question" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE INDEX "polls_choice_question_id_c5b4b260" ON "polls_choice" ("question_id");
COMMIT;
(venv) harveymei@MacBookAir mysite %

自动执行数据库迁移并同步管理你的数据库结构的命令 – 这个命令是 migrate

$ python manage.py migrate

(venv) harveymei@MacBookAir mysite % python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, polls, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying auth.0010_alter_group_name_max_length... OK
Applying auth.0011_update_proxy_permissions... OK
Applying auth.0012_alter_user_first_name_max_length... OK
Applying polls.0001_initial... OK
Applying sessions.0001_initial... OK
(venv) harveymei@MacBookAir mysite %

migrate 命令选中所有还没有执行过的迁移(Django 通过在数据库中创建一个特殊的表 django_migrations 来跟踪执行过哪些迁移)并应用在数据库上 – 也就是将你对模型的更改同步到数据库结构上。

迁移是非常强大的功能,它能让你在开发过程中持续的改变数据库结构而不需要重新删除和创建表 – 它专注于使数据库平滑升级而不会丢失数据。

改变模型需要这三步:

编辑 models.py 文件,改变模型。
运行 python manage.py makemigrations 为模型的改变生成迁移文件。
运行 python manage.py migrate 来应用数据库迁移。