﻿<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title><![CDATA[unix 软硬件 技术宅 ]]></title> 
<description><![CDATA[linux(openwrt lede meilin tomato ddwrt) bsd windows 开源软件 云端server容器  嵌入式 操作系统 文艺青年]]></description>
<link>https://blog.sxx1314.com/</link>
<language>zh-cn</language>
<generator>www.emlog.net</generator>
<item>
	<title>LXC容器的openwrt 的简单升级</title>
	<link>https://blog.sxx1314.com/openwrt/620.html</link>
	<description><![CDATA[<h2>1.查询根文件系统目录</h2>

<p>首先去web管理下查询根文件系统存放的目录。</p>

<p>具体目录为资源-根磁盘。一般为/var/lib/lxc/&lt;container_id&gt;/rootfs 或者 在&nbsp;local-lvm:里面</p>

<p>如果为local-lvm: 则先cd到&nbsp;/dev/mapper# ls -lha 发现具体所在磁盘位置</p>

<p>比如我的为&nbsp;</p>

<pre class="brush:bash;">
lrwxrwxrwx 1 root root 7 Mar 11 09:42 pve-vm--102--disk--1 -&gt; ../dm-7</pre>

<h2>2.挂载根文件磁盘</h2>

<pre class="brush:bash;">
# 创建一个临时挂载点
mkdir /mnt/openwrt_container

# 挂载设备到临时挂载点
mount /dev/dm-7 /mnt/openwrt_container</pre>

<h2>3.解压新的根文件系统到指定目录下&nbsp;</h2>

<pre class="brush:bash;">
mkdir /mnt/tmpfs
tar -xzvf /root/openwrt - rootfs.tar.gz -C /mnt/tmpfs</pre>

<h2>4.替换文件系统为最新同时配置文件会保留旧配置</h2>

<p>（可以先使用openwrt内置的备份功能先备份）</p>

<pre class="brush:bash;">
rsync -av /mnt/tmpfs/ /mnt/openwrt_container/</pre>

<h2>5.卸载挂载点</h2>

<pre class="brush:bash;">
umount /mnt/openwrt_container</pre>

<h2>6.启动容器</h2>

<pre class="brush:bash;">
pct start 100</pre>

<h2>7.测试最新的openwrt根文件系统</h2>

<p>如果是小版本更新可以直接使用原config，如果有问题就用备份的config复原。如果是大版本更新推荐先把根文件系统清空再复制</p>]]></description>
	<pubDate>Wed, 12 Mar 2025 10:44:22 +0000</pubDate>
	<author>沁雨寒</author>
	<guid>https://blog.sxx1314.com/openwrt/620.html</guid>

</item>
<item>
	<title>小爱/猫精/小度 通用刷机破解教程</title>
	<link>https://blog.sxx1314.com/hwother/619.html</link>
	<description><![CDATA[<h2>前言</h2>

<p><strong>通用教程，实测都能刷。主要支持mtk几个型号，所以只要设备是MT6781, MT6789, MT6855, MT6886, MT6895, MT6983, MT8985等型号就能刷。目前mtkclient项目为python项目所以支持linux等系统下刷机。具体要怎么刷还是看你自己的环境。</strong></p>

<h2><strong>准备</strong></h2>

<p>安装两个驱动（要注意这里面缺一不可，好多同学主要是缺失驱动导致无法识别）</p>

<p><a href="https://github.com/daynix/UsbDk/releases/download/v1.00-22/UsbDk_1.0.22_x64.msi" target="_blank">UsbDk</a></p>

<p><a href="https://gsmclassic.com/download/driver/mtk/MediaTek_SP_Driver_v5.2307.zip" target="_blank">MediaTek_SP_Driver</a></p>

<h2><strong>找到Micro-USB插口</strong></h2>

<p>这个就看这个型号的拆机视频，一般都住在电源接口旁边。</p>

<h2><strong>将设备链接到电脑上</strong></h2>

<p><a href="https://wwxy.lanzouf.com/iGUFF0pnh67e" rel="nofollow noopener" target="_blank" title="MTKClientV2.0">windows可直接运行但是版本老</a>&nbsp;</p>

<p><a href="https://github.com/bkerler/mtkclient" target="_blank">python项目支持win/linux运行版本新</a><br />
运行<strong>MTKClient</strong></p>

<p><strong>先将设备用USB连接电脑，然后插入电源时立刻按住所有按键（如果是小爱其实只需要音量+或者音量+和电源，天猫精灵的话还额外需要按静音），直到界面出现芯片的具体参数和加载信息之后（会多次链接，模式会切换过去），松开所有按键即可(第一遍提示音是进入brom模式，第二次提示音是进入preloader模式)最近在玩x08e的时候发现，带电池版有点奇葩需要在最后切换模式的时候快速插拔一下usb才能进入，要注意一下。</strong></p>

<h2><br />
<strong>解锁BootLoader</strong></h2>

<p>点击GUI中的<strong>Flash工具</strong>，选择解锁<strong>BootLoader</strong>，防止刷入修改后的分区无限重启。（如果只是修补boot获取root权限其实可以不解锁，但是为了防止出现问题还是解锁。解锁之后启动时会提示设备不被信任）。</p>

<h2><strong>备份system和boot分区</strong></h2>

<p>点击GUI中的读分区，然后勾选system，再点击右上的读分区，保存到电脑做好备份，遇到无限重启需要还原，boot分区的备份同样操作。推荐全盘备份.因为小爱的固件可以直接从服务器下载，因为有穷举工具，但是其他的目前没有办法下载。所以为了防止以后玩坏了全盘备份。</p>

<p>&nbsp;</p>

<p>将备份好的system.bin和boot.bin拷贝到没有中文路径的目录里(有中文路径下一步打包会不成功)，然后把扩展名改成.img继续下一步。</p>

<h2><strong>解包system分区</strong></h2>

<p><a href="https://wwxy.lanzouf.com/ijZKd0pnjhpa" rel="nofollow noopener" title="crb_v221b">下载地址</a><br />
解压后打开<strong>CRBuilder.exe</strong>，点击解包，这时候软件会重新加载一下(闪一下)，再次点击解包，在弹出的界面中点击Create，执行完毕点击Select File，选择上一步改好扩展名的system.img文件，点击Extract，等待执行完毕，点击右下角的Output Folder</p>

<p>这个工具比较老了。你可以去xda下载最新的程序（最新程序是解包打包是运行在linux环境下所以需要开启win下的各功能）或者更换成其他的解包程序。习惯命令行的推荐用TIK,官方地址在github，效果一样。</p>

<h2><strong>打包system分区</strong></h2>

<p><a href="https://wwxy.lanzouf.com/irLVY0pnkk1a" rel="nofollow noopener" title="app">下载地址</a><br />
解压后得到5个.apk安装包，将其拷贝到刚才打开的输出目录中system-app文件夹里，5个文件分别是当贝桌面，悬浮球，ES文件管理器，面具，权限狗。（面具安装在另一个priv-app目录可以防止其他app遮挡导致无法授权。另外面具需要在获得了安装软件的权限之后通过mt管理器等删除在app目录下的程序安装到用户目录）<br />
拷贝完成后点击主界面的打包-自定义打包Image，点击构建，完成后点击输出目录。这里可以一并从apkpure/apkmirror下载最新的webview（lineageos项目包名和google不一样），然后替换system/app/webview下的webview.apk。为了homeassistant等对webview的版本号有要求的项目。如果你不玩可以不用更新，不更新的话&ldquo;稳定&rdquo;一点。还有就是删除自动更新的程序，一样去app目录下看，有update字样的删除。小爱因为可以下载到全量的更新包所以不屏蔽也行，主要我也没找到对应的程序，希望知道的可以告知一下。</p>

<h2><strong>修补boot分区</strong></h2>

<p><a href="https://wwxy.lanzouf.com/ik3iC0pnlbja" rel="nofollow noopener" title="Magiskpatcher">下载地址</a><br />
解压后打开<strong>Magiskpatcher.exe</strong>(360可能会报毒不用管，不放心的自己搜，甚至可以使用同架构的其他android设备去修补)，选择文件处选择上面改好名称的boot.img文件，配置中架构这里选择的arm(第2个)，其他设备只要是mt8167等soc都差不多除非内存为4G或者以上，反正在这种设备上清一色的1G内存就算是支持arm64（armv8）也一样系统使用armv7（为了省内存），不对的话自己查查CPU的架构或者自己挨个试试，勾选保持验证，保持强制加密，修补vbmeta标志，点击确认配置会自动跳到修补界面。</p>

<h2><strong>写入system和boot分区</strong></h2>

<p>打开MTKClient点击写分区，找到system一排的选择，点击选择改好的system.bin文件，点击右上角的写分区，等待完成。boot分区同理。可以一起刷写。</p>

<h2><strong>特殊步骤，小爱救砖</strong></h2>

<p>小爱有工具可以穷举获取所有的版本的版本号所以可以不用全盘备份，但是要怎么刷写官方的bin呢？因为那个bin是自带分区表的集合镜像，所以需要github的工具解包。</p>

<p>先用<a href="https://github.com/elmagnificogi/MyTools/raw/master/Redmixiaoaisound8/%E5%B0%8F%E7%88%B1%E9%9F%B3%E7%AE%B1%E5%9B%BA%E4%BB%B6%E8%8E%B7%E5%8F%96%E5%B7%A5%E5%85%B7.exe" target="_blank">小爱固件获取工具</a>获取你需要的镜像。然后用<a href="https://github.com/vm03/payload_dumper.git" target="_blank">解包工具</a>&nbsp;解包。这也是一个python工具安装依赖之后运行python payload_dumper.py payload_xx.xxx.xxx.bin</p>

<p>解压出来的各个镜像都要刷写进去。</p>

<p>稳定版开启adb可以修改prop文件，</p>

<pre class="brush:as3;">
persist.service.adb.enable=1

persist.service.debuggable=1

persist.sys.usb.config=mtp,adb</pre>

<p>此操作适合小爱，猫精阉割了设置虽然可以开启但是没有同意pc调试的选项，如果要猫精等支持adb的话得额外修复系统组件这个以后再说。</p>

<h2><strong>获取软件安装权限</strong></h2>

<p>利用权限狗给文件管理器以及其他需要的app或者软件安装权限。第一次启动magisk是没有root权限的请再次启动之后然后使用权限狗。</p>

<p>至此完整的折腾流程就ok了。</p>]]></description>
	<pubDate>Wed, 04 Sep 2024 07:08:38 +0000</pubDate>
	<author>沁雨寒</author>
	<guid>https://blog.sxx1314.com/hwother/619.html</guid>

</item>
<item>
	<title>kernel 5.15 编译支持 NAT1/FULLCONE-NAT   pve/debian kernel 编译 （添加nat1/fullcone-nat ppp拨号 i225等支持）</title>
	<link>https://blog.sxx1314.com/linux/618.html</link>
	<description><![CDATA[<p>&nbsp;</p>

<h2>项目地址</h2>

<p>https://github.com/Chion82/netfilter-full-cone-nat</p>

<p>https://github.com/proxmox/pve-kernel</p>

<p>https://github.com/sxx1314/pve-kernel</p>

<p>&nbsp;</p>

<p>预编译deb下载：https://github.com/sxx1314/pve-kernel</p>

<h2>一.&nbsp; 推荐使用debian11编译。可以使用docker来编译。</h2>

<p>&nbsp;</p>

<pre class="brush:as3;">
docker pull debian:bullseye
docker run&nbsp;debian:bullseye</pre>

<p>&nbsp;</p>

<h2>二.&nbsp; 前置操作</h2>

<p>&nbsp;</p>

<h3>1. 添加pve的源</h3>

<p>&nbsp;</p>

<pre class="brush:as3;">
echo &ldquo;deb http://download.proxmox.wiki/debian/pve bullseye pve-no-subscription&rdquo; &gt;&gt; /etc/apt/sources.list</pre>

<h3><br />
2. 添加 Proxmox VE 存储库密钥：</h3>

<p>wget&nbsp;<a href="http://download.proxmox.com/debian/proxmox-ve-release-6.x.gpg">http://download.proxmox.com/debian/proxmox-release-bullseye.gpg</a>-O /etc/apt/trusted.gpg.d/<a href="http://download.proxmox.com/debian/proxmox-ve-release-6.x.gpg">proxmox-release-bullseye.gpg</a><br />
&nbsp;</p>

<h3>3. 更新源</h3>

<p>&nbsp;</p>

<pre class="brush:as3;">
apt update</pre>

<h3><br />
4. 安装编译环境</h3>

<p>&nbsp;</p>

<pre class="brush:as3;">
apt install devscripts asciidoc-base automake bc bison cpio dh-python flex git kmod libdw-dev libelf-dev libiberty-dev libnuma-dev libpve-common-perl libslang2-dev libssl-dev libtool lintian lz4 perl-modules python2-minimal rsync sed sphinx-common tar xmlto zlib1g-dev dwarves zfsd</pre>

<h3><br />
<br />
5.新建普通用户</h3>

<pre class="brush:as3;">
groupadd pve #新建组
useradd -m pve&nbsp;-g pve&nbsp;-s /bin/bash -d /home/pve
passwd pve
su pve&nbsp;#切换到用户</pre>

<p>&nbsp;</p>

<p>如果需要回到root用户直接exit退出即可，另外没有授予pve su权限 以及没有安装sudo，所以pve用户无法安装软件。可以自己授权不做赘述。</p>

<h2><br />
三.&nbsp; 源码配置</h2>

<p>&nbsp;</p>

<h3>1. git clone</h3>

<pre class="brush:as3;">
cd ~
git clone git://git.proxmox.com/git/pve-kernel.git

cd pve-kernel
git submodule update &mdash;init submodules/ubuntu-jammy</pre>

<p>&nbsp;</p>

<h3>2 修改配置文件</h3>

<p><br />
<strong>修改Makefile文件</strong></p>

<p><br />
vim Makefile<br />
<br />
找到</p>

<pre class="brush:as3;">
cat ${BUILD_DIR}/${KERNEL_SRC}/debian.master/config/config.common.ubuntu ${BUILD_DIR}/${KERNEL_SRC}/debian.master/config/${ARCH}/config.common.${ARCH} ${BUILD_DIR}/${KERNEL_SRC}/debian.master/config/${ARCH}/config.flavour.generic &gt; ${KERNEL_CFG_ORG}</pre>

<p><br />
和</p>

<pre class="brush:as3;">
cp ${KERNEL_CFG_ORG} ${BUILD_DIR}/${KERNEL_SRC}/.config</pre>

<p><br />
<br />
前面加 # 号 注掉自动生成config<br />
保存</p>

<p>手动生成.config(以下脚本就是基于上面注掉的脚本改来的)</p>

<pre class="brush:as3;">
cat debian.master/config/config.common.ubuntu debian.master/config/amd64/config.common.amd64 debian.master/config/amd64/config.flavour.generic &gt; .config
</pre>

<p><br />
执行后，已经进到了~/pve-kernel/submodules/submodules/ubuntu-jammy/目录</p>

<p>&nbsp;</p>

<p>这里还需要修改几个小玩意：</p>

<p>&nbsp;&nbsp;CONFIG_SYSTEM_TRUSTED_KEYS=&quot;&quot;&nbsp; 这里有两个证书需要清空路径。</p>

<p>当然如果你想保持安全性，可以</p>

<pre class="brush:as3;">
openssl req -x509 -newkey rsa:4096 -keyout certs/mycert.pem -out certs/mycert.pem -nodes -days 3650</pre>

<p>把上述目录修改为生成证书路径。</p>

<p>生成x509的证书给kernel使用，增加安全性。</p>

<p>意义在于，以后所有外部加载的kernel二进制文件都需要用此key签名才能加载。</p>

<p>&nbsp;</p>

<h3>3. 现在添加xt_FULLCONENAT</h3>

<p><br />
3.1 复制 xt_FULLCONENAT.c 到 ubuntu-jammy/net/netfilter/xt_FULLCONENAT.c</p>

<pre class="brush:as3;">
cd ~/pve-kernel/submodules/ubuntu-jammy/net/netfilter
wget&nbsp;https://raw.githubusercontent.com/sxx1314/pve-kernel/main/netfilter-full-cone-nat/xt_FULLCONENAT.c</pre>

<p><br />
&nbsp;</p>

<p><span style="color:#e74c3c"><strong>这个文件是修复之后可以适用于5.15kernel的，原项目的不行。</strong></span></p>

<p>3.2 将以下行添加到ubuntu-jammy/net/netfilter/Makefile</p>

<pre class="brush:as3;">
obj-$(CONFIG_NETFILTER_XT_TARGET_FULLCONENAT) += xt_FULLCONENAT.o</pre>

<p><br />
&nbsp;</p>

<p>3.3 打开ubuntu-jammy/net/ipv4/netfilter/Kconfig，将以下代码插入到config IP_NF_TARGET_NETMAP部分之后：</p>

<pre class="brush:as3;">
config IP_NF_TARGET_FULLCONENAT
tristate &ldquo;FULLCONENAT target support&rdquo;
depends on NETFILTER_ADVANCED
select NETFILTER_XT_TARGET_FULLCONENAT
help
This is a backwards-compat option for the user&rsquo;s convenience
(e.g. when running oldconfig). It selects
CONFIG_NETFILTER_XT_TARGET_FULLCONENAT.</pre>

<p><br />
&nbsp;</p>

<p>3.4 打开ubuntu-jammy/net/netfilter/Kconfig，将以下代码插入到config NETFILTER_XT_TARGET_NETMAP部分之后：</p>

<pre class="brush:as3;">
config NETFILTER_XT_TARGET_FULLCONENAT
tristate &lsquo;&ldquo;FULLCONENAT&rdquo; target support&rsquo;
depends on NF_NAT
help
Full Cone NAT


To compile it as a module, choose M here. If unsure, say N.</pre>

<ol>
</ol>

<p>&nbsp;</p>

<p>确保现在在目录`~/pve-kernel/submodules下</p>

<p>3.5 运行 make menuconfig and 选择: Networking support -&gt; Network options -&gt; Network packet filtering framework (Netfilter) -&gt; IP: Netfilter Configuration -&gt; &lt;M&gt; FULLCONENAT target support</p>

<p>3.6 以下添加拔号内核模块</p>

<p>运行 make menuconfig and 选择: Device Drivers &gt; Network device support &gt; PPP(point-to-point protocol) support 由*改为M<br />
保存</p>

<h2>四.编译</h2>

<pre class="brush:as3;">
cd ~/pve-kernel
make</pre>

<p>&nbsp;</p>

<p>make :直接多线程编译，可以跑满所有线程。</p>

<p>make V=s :单项目编译输出log，用户排错。&nbsp;&nbsp;</p>

<p>这里操作和openwrt一致。</p>

<p>&nbsp;</p>]]></description>
	<pubDate>Thu, 17 Mar 2022 12:22:23 +0000</pubDate>
	<author>沁雨寒</author>
	<guid>https://blog.sxx1314.com/linux/618.html</guid>

</item>
<item>
	<title>关于录制视频格式的选择</title>
	<link>https://blog.sxx1314.com/opsource/617.html</link>
	<description><![CDATA[<blockquote>
<p>先说一下我的历程吧。</p>
</blockquote>

<ul>
	<li>
	<h3><strong>首先先不管授权问题</strong></h3>
	</li>
	<li>
	<h3>部分格式以前的话因为需要授权费所以有些平台/软件不支持。但是现在都2022年了，这个是最不是问题的问题，所以可以忽略。</h3>
	</li>
	<li>
	<h3><strong>mp4格式</strong></h3>
	</li>
	<li>最主要还是以前就用比较顺手并且在win等平台不用借助第三方app就能直接播放。但是mp4在录制的时候会有一个非常大的问题，就是因为异常中断时，由于mp4会把视频信息写入到最末尾，所以异常中断会导致信息丢失而无法播放。并且修复非常麻烦。所以后续就不再使用这个格式。</li>
	<li>
	<h3><strong>flv</strong></h3>
	</li>
	<li>这个格式对于录制其实是最佳格式，因为就算异常也不会丢失任何数据，所有视频内容都会保留。但是也会有一个问题，就是网络不稳定会导致画面黑屏（mp4的话稍微好一点点）卡顿。并且由于flv默认是没有信息帧的，所以进度条拖动是不支持的（也不是不支持就是得完整加载之后才能播放 等待时间非常非常非常长）</li>
	<li>
	<h3><strong>mkv</strong>。</h3>
	</li>
	<li>mkv虽然异常中断也会丢失最后录制的一丢丢视频，但是整体并不影响，并且mkv是由信息帧的所以可以轻松拖动。并且mkv的字母文件可以直接集成进去。但是mkv部分平台自带软件无法播放。</li>
</ul>]]></description>
	<pubDate>Thu, 03 Feb 2022 09:59:43 +0000</pubDate>
	<author>沁雨寒</author>
	<guid>https://blog.sxx1314.com/opsource/617.html</guid>

</item>
<item>
	<title>简单的linux 硬盘读写性能测试命令</title>
	<link>https://blog.sxx1314.com/linux/616.html</link>
	<description><![CDATA[<pre>

&nbsp;</pre>

<pre class="brush:as3;">
dd if=/dev/zero of=/tmp/tempfile bs=1M count=1024 status=progress</pre>

<p>&nbsp;</p>

<p>使用dd测试，status=progress 选项 显示进度。</p>

<p>&nbsp;</p>

<p>&nbsp;</p>]]></description>
	<pubDate>Mon, 24 Jan 2022 13:34:14 +0000</pubDate>
	<author>沁雨寒</author>
	<guid>https://blog.sxx1314.com/linux/616.html</guid>

</item>
<item>
	<title>Chrome OS  在 TF卡/U盘/移动硬盘里安装 其他linux发行版</title>
	<link>https://blog.sxx1314.com/linux/615.html</link>
	<description><![CDATA[<blockquote>
<p>这里只谈 chroot，直接在原内核上挂载新系统的文件系统。不修改bios来做单系统的启动。好处是可以随时切换系统</p>
</blockquote>

<p>&nbsp;</p>

<p>依赖项目 ：<a href="https://blog.sxx1314.com/go.php?url=github.com/dnschneid/crouton" target="_blank">github.com/dnschneid/crouton</a></p>

<p>&nbsp;</p>

<p>怎么装 见 readme，不做赘述。</p>

<p>这里讲讲安装完毕之后的事情。</p>

<p>&nbsp;</p>

<ul>
	<li>当然首先确保安装介质是ext4。</li>
	<li>然后先去chrome的文件管理里卸载介质</li>
	<li>shell里手动挂载介质</li>
	<li>执行上述项目已安装的目录下的enter-chroot脚本</li>
</ul>]]></description>
	<pubDate>Thu, 20 Jan 2022 19:05:44 +0000</pubDate>
	<author>沁雨寒</author>
	<guid>https://blog.sxx1314.com/linux/615.html</guid>

</item>
<item>
	<title>linux / win 下使用测试MTU</title>
	<link>https://blog.sxx1314.com/linux/614.html</link>
	<description><![CDATA[<p>主要记录一下命令</p>

<p>设置TCP最大报文长度，一般情况下自己可以算出来。</p>

<p>但是很多情况下并不一定，还是需要自己测试。</p>

<h4>LINUX<br />
&nbsp;</h4>

<pre class="brush:as3;">
当包是1472字节并且不拆包，能够传送正确；
[root@sxx1314 ~]# ping -c 3 -s 1472 -M do www.baidu.com
PING www.a.shifen.com (10.10.0.230) 1472(1500) bytes of data.
1480 bytes from 10.10.0.230: icmp_seq=1 ttl=64 time=0.345 ms
1480 bytes from 10.10.0.230: icmp_seq=2 ttl=64 time=0.303 ms
1480 bytes from 10.10.0.230: icmp_seq=3 ttl=64 time=0.314 ms
--- 10.1.0.230 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.303/0.320/0.345/0.027 ms
当包是1473字节并且不拆包，加上28字节的包头，大于设定值1500，发生错误。
[root@sxx1314 ~]# ping -c 3 -s 1473 -M www.baidu.com
PING www.a.shifen.com (10.10.0.230) 1473(1501) bytes of data.
From 10.10.34.1 icmp_seq=1 Frag needed and DF set (mtu = 1500)
From 10.10.34.1 icmp_seq=1 Frag needed and DF set (mtu = 1500)
From 10.10.34.1 icmp_seq=1 Frag needed and DF set (mtu = 1500)
--- 10.1.0.230 ping statistics ---
0 packets transmitted, 0 received, +3 errors</pre>

<p>&nbsp;</p>

<p>&nbsp;</p>

<h4>WIN</h4>

<p>测试方法</p>

<pre class="brush:as3;">
ping &ndash;l 1472 &ndash;f  www.baidu.com</pre>

<p>&nbsp;</p>

<p>&nbsp;</p>]]></description>
	<pubDate>Thu, 20 Jan 2022 19:05:44 +0000</pubDate>
	<author>沁雨寒</author>
	<guid>https://blog.sxx1314.com/linux/614.html</guid>

</item>
<item>
	<title>Linux Kernel 5.4 5.10 5.14 等PLUS BBR 魔改内核安装和开启 BBR</title>
	<link>https://blog.sxx1314.com/linux/613.html</link>
	<description><![CDATA[<blockquote>
<p dir="auto"><strong>项目来源：<a href="https://github.com/UJX6N" target="_blank">https://github.com/UJX6N</a></strong></p>

<p dir="auto">&nbsp;</p>
</blockquote>

<h2 dir="auto"><strong>安装办法</strong></h2>

<ol dir="ltr">
	<li>先自行安装wget curl 等软件。apt install/yun install/pacman -S ...</li>
	<li>
	<pre>
bash &lt;(curl -Lso- https://git.io/kernel.sh)</pre>

	<p>&nbsp;</p>
	</li>
</ol>

<p dir="auto"><a href="https://github.com/jinwyp/one_click_script/blob/master/docs/readme3.png?raw=true" rel="noopener noreferrer" target="_blank"><img alt="功能列表3" src="https://github.com/jinwyp/one_click_script/raw/master/docs/readme3.png?raw=true" /></a></p>

<p dir="auto">&nbsp;</p>

<h2 dir="auto"><strong>注意事项：</strong></h2>

<ol dir="ltr">
	<li><strong>UJX6N 的新内核安装时不要卸载旧内核。卸载旧内核可能会一并删除依赖导致系统无法启动。</strong></li>
	<li><strong>dog250 原版内核如果本地安装了高版本内核需要卸载旧内核或者修改grub把bbr内核改成第一引导。此内核卸载不影响启动</strong></li>
</ol>]]></description>
	<pubDate>Sun, 02 Jan 2022 03:35:37 +0000</pubDate>
	<author>沁雨寒</author>
	<guid>https://blog.sxx1314.com/linux/613.html</guid>

</item>
<item>
	<title>Docker macvlan 容器和宿主互访</title>
	<link>https://blog.sxx1314.com/dockers/612.html</link>
	<description><![CDATA[<p>创建一个新的 macvlan 接口。随意命名，这里我写为创建一个新的 macvlan 接口。</p>

<pre class="brush:as3;">
ip link add mynet-shim link eno1 type macvlan  mode bridge</pre>

<p>现在使用我们保留的ip地址配置接口并启动它</p>

<pre class="brush:as3;">
ip addr add 10.10.10.250/32 dev mynet-shim  
ip link set mynet-shim up</pre>

<p>我们需要做的最后一件事是告诉我们的主机在与容器通信时使用该接口。我们将容器限制在本地网络的特定 CIDR 子集中；我们只需添加一条到该范围的route，如下所示</p>

<pre class="brush:as3;">
ip route add 10.10.10..200/27 dev mynet-shim #也可以一个一个ip添加</pre>

<p>&nbsp;</p>]]></description>
	<pubDate>Thu, 30 Dec 2021 07:57:12 +0000</pubDate>
	<author>沁雨寒</author>
	<guid>https://blog.sxx1314.com/dockers/612.html</guid>

</item>
<item>
	<title>网关设备中 Docker 的网络优化</title>
	<link>https://blog.sxx1314.com/dockers/611.html</link>
	<description><![CDATA[<h1>Bridge 网络</h1>

<p dir="auto">Docker 使用&nbsp;<code>Bridge</code>&nbsp;网络时，会创建docker0 网桥，用于连接容器，然后&nbsp;<code>docker0</code>&nbsp;通过&nbsp;<code>NAT</code>&nbsp;转发访问外部网络，具体细节在这里就不赘述了。<br />
当容器进行映射时，Docker 会自动添加&nbsp;<code>DNAT</code>&nbsp;进行转发，实现访问宿主机端口的时候，将流量转发到容器内部。</p>

<p dir="auto">在普通宿主机中使用&nbsp;<code>Docker Bridge</code>&nbsp;网络没有任何问题，但是，如果宿主机是网关，或者&nbsp;<code>Openwrt</code>&nbsp;的时候，<code>WAN</code>&nbsp;口也能轻松访问容器暴露出来的端口，带来很大的安全问题。</p>

<h4 dir="auto">WAN 口访问的控制</h4>

<p dir="auto">所以核心问题是阻止&nbsp;<code>WAN</code>&nbsp;口访问，此前也有大佬 LEAN 采用阻止&nbsp;<code>Docker</code>&nbsp;操作 iptables的方案，这个方法简单粗暴，Docker 就不会添加&nbsp;<code>DNA</code>T 转发，当然不存在端口暴露问题，但是带来的问题也有不少，有几率存在没有给&nbsp;<code>docker0</code>&nbsp;做&nbsp;<code>SNAT</code>&nbsp;导致整个&nbsp;<code>bridge</code>&nbsp;网络下的容器都无法联网，实现下来还有其他一些奇奇怪怪的问题。</p>

<p dir="auto">对于这种问题，Docker 官方的这篇<a href="https://docs.docker.com/network/iptables/" rel="nofollow">文档</a>给出了解决方案<br />
下面就针对&nbsp;<code>Openwrt</code>&nbsp;来实现访问控制：</p>

<pre class="brush:as3;">
# 新建 DOCKER-MAN 自定义链

# 挟持 DOCKER-USER 转到 DOCKER-MAN 自定义链
iptables -I DOCKER-USER -j DOCKER-MAN

# 若流量来自 br-lan 放行，目的是 `LAN` 口可以访问容暴露的端口
iptables -A DOCKER-MAN -i br-lan -o docker0 -j RETURN
# 阻止所有新建以及无效的连接。
iptables -A DOCKER-MAN -m conntrack --ctstate NEW,INVALID -o docker0 -j DROP
# 接受容器主动访问的流量，目的是容器能够联网。
iptables -A DOCKER-MAN -m conntrack --ctstate ESTABLISHED,RELATED -o docker0 -j RETURN
iptables -A DOCKER-MAN -j RETURN
</pre>

<p dir="auto">这样一来，LAN 口是可以访问容器暴露的端口，对与其他<code>接口</code>，容器主动访问不受限制，而外面是无法直接访问容器的，做到了单项访问。</p>

<p dir="auto">到这里，又有问题来了，如果我有一个容器比如&nbsp;<code>qBittorrent</code>，暴露的端口就是希望从外部(公司)等管理的，这样一来就无法访问了，当然也有解决方案：</p>

<pre class="brush:as3;">
# 在 DOCKER-MAN 自定义链接加入对 172.17.0.9 (需要放行的容器ip) 的放行
iptables -I DOCKER-MAN -d 172.17.0.9 -o docker0 -j RETURN
</pre>

<p dir="auto">这样一来，这个容器就可以被正常访问了</p>

<p dir="auto">最后一个问题，<code>Bridge</code>&nbsp;网络下面的&nbsp;<code>ip</code>&nbsp;地址不是固定的，每次重启&nbsp;<code>Docker daemon</code>&nbsp;都有可能改变容器的 ip<br />
这样手动操作起来就相对比较麻烦了，所以在&nbsp;<a href="https://github.com/lisaac/luci-app-dockerman">luci-app-dockerman</a>中加入了<code>访问控制</code>选项，可以轻松实现对容器的访问控制</p>

<h2 dir="auto">Macvlan 网络</h2>

<p dir="auto">Macvlan 网络的真的是好处多多，有兴趣的同学自己翻阅资料查看，使用&nbsp;<code>macvlan</code>&nbsp;网络就基本和虚拟机的桥接模式类似，而且不存在&nbsp;<code>Bridge</code>&nbsp;网络的端口暴露的风险，在&nbsp;<code>Openwrt</code>&nbsp;下使用&nbsp;<code>macvlan</code>&nbsp;网络最大的问题就是无法上网的问题。</p>

<p dir="auto">这里讲一个简单的方案，首先通过&nbsp;<code>Docker</code>&nbsp;新建&nbsp;<code>macvlan</code>&nbsp;网络</p>

<pre class="brush:as3;">
docker network create -d macvlan \
    --subnet=192.168.3.0/24 --gateway=92.168.3.1 \
    -o parent=br-lan \
    -o macvlan_mode=bridge \
    macnet
</pre>

<p dir="auto">请注意这里的<code>subnet</code>不要和其他接口冲突（若要使用同网段后面会讲），<code>parent</code>使用<code>br-lan</code>，然后在&nbsp;<code>Openwrt</code>&nbsp;上创建&nbsp;<code>macvlan</code>&nbsp;设备</p>

<pre class="brush:as3;">
ip link add link br-lan docker_mac0 type macvlan mode bridge
ip link set docker_mac0 up
</pre>

<p dir="auto">接下来&nbsp;<code>Openwrt</code>&nbsp;中添加接口，你也可以在&nbsp;<code>luci</code>&nbsp;中添加</p>

<pre class="brush:as3;">
uci set network.docker_mac0=interface
uci set network.docker_mac0.ifname=docker_mac0
uci set network.docker_mac0.proto=static
uci set network.docker_mac0.ipaddr=192.168.3.1
uci set network.docker_mac0.netmask=255.255.255.0
uci commit network
</pre>

<p dir="auto">将这个接口加入到防火墙中的 LAN zone</p>

<pre class="brush:as3;">
uci set firewall.@zone[0].network=&quot;br-lan docker_mac0&quot;
uci commit firewall
</pre>

<p dir="auto">至此，<code>Docker macvlan</code>&nbsp;网络就可以正常使用了，这个步骤相对比较简单，但是网络重启或者&nbsp;<code>Openwrt</code>&nbsp;重启的时候就会失效，解决这个问题，已经在&nbsp;<a href="https://github.com/lisaac/luci-app-dockerman">luci-app-dockerman</a>&nbsp;实现，当创建&nbsp;<code>macvlan</code>&nbsp;网络时，dockerman 会自动做好这些工作，网络重启也会自动添加，删除网络，则会自动删除创建的&nbsp;<code>macvlan</code>&nbsp;网络。</p>

<h4 dir="auto">Macvlan 进阶</h4>

<p dir="auto">有些老哥觉得用这个方案&nbsp;<code>macvlan</code>&nbsp;网络，使用的是与&nbsp;<code>LAN</code>&nbsp;不同的网段，访问容器会存在转发。<br />
解决这个其实很简单，禁用 br-lan 的 DHCP, 同时开启&nbsp;<code>docker_mac0</code>&nbsp;的&nbsp;<code>DHCP</code>&nbsp;就可以，这样路由器下的所有主机和容器内的所有主机都在同一个网段之下了。<br />
所以，如果你开始就想用这个进阶方案的话，从创建&nbsp;<code>macvlan</code>&nbsp;网络的时候就应该规划好自己偏好的网段。</p>

<p dir="auto">&nbsp;</p>]]></description>
	<pubDate>Thu, 30 Dec 2021 07:57:12 +0000</pubDate>
	<author>沁雨寒</author>
	<guid>https://blog.sxx1314.com/dockers/611.html</guid>

</item></channel>
</rss>