Windows 10 20H2更新时总是报0xc1900204错误的解决

我的台式机Windows 10版本是20H2,再往后更新的时候总是失败,困扰两年了,其间在网上找了很多方法,基本上都说是windows update服务有问题了,重置一下、删除临时文件等办法,照着做了毫无作用。近日突然想起来用英文搜了一下,总算有所突破,终于解决了多年顽疾,成功更新到最新的22H2。

这一问题其实是Win10不知道哪一次更新时带来的一个bug,主要是内部标识的版本号错误,但这一问题始终没有解决。

解决方法就是在注册表编辑器中找到HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\EditionVersion这个键,修改两个值:

  • “EditionBuildNumber”=dword:00004a62 ==> 把4a62 改成 4a61.
  • “EditionBuildQfe”=dword:0000023c ==> 改成1fc
  • 改完后如下图

参考https://www.yourwindowsguide.com/2020/10/cannot-initiate-repair-install-windows-10-20h2.html#.YkmYMv9N0go

华硕路由器官版固件自动执行自定义脚本的方法

以前开放的华硕路由器官版固件开机自动执行脚本的很多方法,目前已经失效。根据网上搜索和自己实践的情况看,目前只有利用usb_mount时候的钩子自动执行脚本还可以用,前提是插一个U盘在路由器上。

开启U盘装载自动执行脚本方法如下:

nvram set script_usbmount="sh /jffs/init.sh"
nvram commit

其中/jffs/init.sh是需要自动执行的脚本,例如:

#!/bin/sh
sed -i '$a192.168.3.123 myhost' /etc/hosts

#不能通过重启服务的方式,因为会还原hosts文件,只能kill
killall -SIGHUP dnsmasq

树莓派配置V2ray客户端及透明网关

透明网关搭建

v2搭建及测试

安装v2

  1. 官方一键脚本1
    sudo bash <(curl -L -s https://install.direct/go.sh)
  2. 下载脚本安装,其实与第1种方法一样
    wget https://install.direct/go.sh
    sudo chmod +x go.sh
    sudo bash go.sh
  3. 离线安装,在网络不佳或不合适的情况下使用本地安装在第2步中下载 go.sh 同时在v2ray-core-releases下载 v2ray-linux-arm.zip ,如果树莓派中网络不佳可以在自己的PC机下载完之后迁移文件到树莓派中。
    wget -O v2ray_install.sh https://install.direct/go.sh
    chmod +x v2ray_install.sh
    sudo ./v2ray_install.sh –local v2ray-linux-arm.zip
    配置v2
  4. 后续操作默认切换到 root 权限下,填写v2的配置json。
    sudo su root
    cat > /etc/v2ray/config.json << EOF
    {
    “log”: {
    “loglevel”: “warning”
    },
    “inbounds”: [
    {
    “tag”: “proxy”,
    “port”: 1090, // 监听端口
    “listen”: “127.0.0.1”,
    “protocol”: “socks”, // 入口协议为 SOCKS 5
    “sniffing”: {
    “enabled”: true,
    “destOverride”: [
    “http”,
    “tls”
    ]
    },
    “settings”: {
    “auth”: “noauth”, //socks的认证设置,noauth 代表不认证,由于 socks 通常在客户端使用,所以这里不认证
    “udp”: true
    },
    “streamSettings”: null
    }
    ],
    “outbounds”: [
    {
    “tag”: “proxy”,
    “protocol”: “vmess”, // 出口协议
    “settings”: {
    “vnext”: [
    {
    “address”: “server.com”, // 服务器地址,请修改为你自己的服务器 IP 或域名
    “port”: 10010, // 服务器端口
    “users”: [
    {
    “id”: “b831381d-6324-4d53-ad4f-8cda48b30811”, // 用户 ID,必须与服务器端配置相同
    “alterId”: 32 // 此处的值也应当与服务器相同
    }
    ]
    }
    ]
    }
    }
    ]
    }
    EOF
    对上述配置中的protocol以及vnext 下的 address 、 port 、 id 、 alterId 进行修改,这是必须修改的内容,其含义可参照注释,其他内容可不改变,如果懂得配置的话可以自行修改其余内容。
  5. 开启v2服务下面命令中以 # 开头为注释内容。
    systemctl start v2ray
    # 或使用 service v2ray start
    ps -ef|grep v2ray
    # 或使用 service v2ray status
    正常情况下,v2已经开始运行,查看状态结果如下图。
    v2正常运行配置
    v2正常运行状态

全局代理及测试

  1. 配置全局代理编译安装 ProxyChains-NG 进行全局代理设置。
    git clone https://github.com/rofl0r/proxychains-ng.git
    cd /home/pi/proxychains-ng/
    ./configure && make && make install

    # 设置及修改配置
    cp ./src/proxychains.conf /etc/proxychains.conf
    vim /etc/proxychains.conf
    proxychains.conf配置文件的最后部分内容做以下修改:1
    2
    – socks4 127.0.0.1 9050
    + socks5 127.0.0.1 1090
  2. 测试v2通过 IP 以及 HTTP 响应码测试 v2 是否搭建成功。
    # 返回未代理前的本地公网地址
    curl ip.sb
    # 返回代理过的v2服务器地址,表示搭建成功,若长时间无响应或返回非服务端 IP 地址的内容则表示搭建失败
    proxychains4 curl ip.sb
    # 返回 200 或 301 表示搭建成功,若返回 000 或长时间无反应则表示搭建失败
    proxychains4 curl -so /dev/null -w “%{http_code}” google.com -x socks5://127.0.0.1:1090

透明网关搭建

V2配置透明代理的入站和DNS分流

将以下配置内容覆盖原先的v2配置内容,即修改 /etc/v2ray/config.json 下的内容。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
{
“inbounds”: [
{
“tag”:”transparent”,
“port”: 12345,
“protocol”: “dokodemo-door”,
“settings”: {
“network”: “tcp,udp”,
“followRedirect”: true
},
“sniffing”: {
“enabled”: true,
“destOverride”: [
“http”,
“tls”
]
},
“streamSettings”: {
“sockopt”: {
“tproxy”: “tproxy” // 透明代理使用 TPROXY 方式
}
}
},
{
“port”: 1090,
“protocol”: “socks”, // 入口协议为 SOCKS 5
“sniffing”: {
“enabled”: true,
“destOverride”: [“http”, “tls”]
},
“settings”: {
“auth”: “noauth”
}
}
],
“outbounds”: [
{
“tag”: “proxy”,
“protocol”: “vmess”, // 代理服务器
“settings”: {
“vnext”: [
{
“address”: “server.com”, // 服务器地址,请修改为你自己的服务器 IP 或域名
“port”: 10010, // 服务器端口
“users”: [
{
“id”: “b831381d-6324-4d53-ad4f-8cda48b30811”, // 用户 ID,必须与服务器端配置相同
“alterId”: 32 // 此处的值也应当与服务器相同
}
]
},
“streamSettings”: {
“sockopt”: {
“mark”: 255
}
},
“mux”: {
“enabled”: true
}
},
{
“tag”: “direct”,
“protocol”: “freedom”,
“settings”: {
“domainStrategy”: “UseIP”
},
“streamSettings”: {
“sockopt”: {
“mark”: 255
}
}
},
{
“tag”: “block”,
“protocol”: “blackhole”,
“settings”: {
“response”: {
“type”: “http”
}
}
},
{
“tag”: “dns-out”,
“protocol”: “dns”,
“streamSettings”: {
“sockopt”: {
“mark”: 255
}
}
}
],
“dns”: {
“servers”: [
“8.8.8.8”, // 非中中国大陆域名使用 Google 的 DNS
“1.1.1.1”, // 非中中国大陆域名使用 Cloudflare 的 DNS(备用)
“114.114.114.114”, // 114 的 DNS (备用)
{
“address”: “223.5.5.5”, //中国大陆域名使用阿里的 DNS
“port”: 53,
“domains”: [
“geosite:cn”,
“ntp.org”, // NTP 服务器
“$myserver.address” // 此处改为你 VPS 的域名
]
}
]
},
“routing”: {
“domainStrategy”: “IPOnDemand”,
“rules”: [
{ // 劫持 53 端口 UDP 流量,使用 V2Ray 的 DNS
“type”: “field”,
“inboundTag”: [
“transparent”
],
“port”: 53,
“network”: “udp”,
“outboundTag”: “dns-out”
},
{
// 直连 123 端口 UDP 流量(NTP 协议)
“type”: “field”,
“inboundTag”: [
“transparent”
],
“port”: 123,
“network”: “udp”,
“outboundTag”: “direct”
},
{
“type”: “field”,
“ip”: [
// 设置 DNS 配置中的国内 DNS 服务器地址直连,以达到 DNS 分流目的
“223.5.5.5”,
“114.114.114.114”
],
“outboundTag”: “direct”
},
{
“type”: “field”,
“ip”: [
// 设置 DNS 配置中的国内 DNS 服务器地址走代理,以达到 DNS 分流目的
“8.8.8.8”,
“1.1.1.1”
],
“outboundTag”: “proxy” // 改为你自己代理的出站 tag
},
{
// 广告拦截
“type”: “field”,
“domain”: [
“geosite:category-ads-all”
],
“outboundTag”: “block”
},
{
// BT 流量直连
“type”: “field”,
“protocol”:[“bittorrent”],
“outboundTag”: “direct”
},
{
// 直连中国大陆主流网站 ip 和 保留 ip
“type”: “field”,
“ip”: [
“geoip:private”,
“geoip:cn”
],
“outboundTag”: “direct”
},
{
// 直连中国大陆主流网站域名
“type”: “field”,
“domain”: [
“geosite:cn”
],
“outboundTag”: “direct”
}
]
}
}

同样的,对上述配置中的protocol以及 vnext 下的 address 、 port 、 id 、 alterId 进行修改,这是必须修改的内容,其含义可参照注释,其他内容可不改变,如果懂得配置的话可以自行修改其余内容。

配置透明代理规则

本文使用方法是tproxy,同时保证树莓派和其他客户端均能实现科学上网。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 设置策略路由
ip rule add fwmark 1 table 100
ip route add local 0.0.0.0/0 dev lo table 100

# 代理局域网设备
iptables -t mangle -N V2RAY
iptables -t mangle -A V2RAY -d 127.0.0.1/32 -j RETURN
iptables -t mangle -A V2RAY -d 224.0.0.0/4 -j RETURN
iptables -t mangle -A V2RAY -d 255.255.255.255/32 -j RETURN
# 直连局域网,避免 V2Ray 无法启动时无法连网关的 SSH,如果你配置的是其他网段(如 10.x.x.x 等),则修改成自己的网段
iptables -t mangle -A V2RAY -d 192.168.0.0/16 -p tcp -j RETURN
# 直连局域网,53 端口除外(因为要使用 V2Ray 的 DNS 解析)
iptables -t mangle -A V2RAY -d 192.168.0.0/16 -p udp ! –dport 53 -j RETURN
# 给 UDP 打标记 1,转发至 12345 端口
iptables -t mangle -A V2RAY -p udp -j TPROXY –on-port 12345 –tproxy-mark 1
# 给 TCP 打标记 1,转发至 12345 端口
iptables -t mangle -A V2RAY -p tcp -j TPROXY –on-port 12345 –tproxy-mark 1
# 应用规则
iptables -t mangle -A PREROUTING -j V2RAY

# 代理网关本机
iptables -t mangle -N V2RAY_MASK
iptables -t mangle -A V2RAY_MASK -d 224.0.0.0/4 -j RETURN
iptables -t mangle -A V2RAY_MASK -d 255.255.255.255/32 -j RETURN
# 直连局域网
iptables -t mangle -A V2RAY_MASK -d 192.168.0.0/16 -p tcp -j RETURN
# 直连局域网,53 端口除外(因为要使用 V2Ray 的 DNS)
iptables -t mangle -A V2RAY_MASK -d 192.168.0.0/16 -p udp ! –dport 53 -j RETURN
# 直连 SO_MARK 为 0xff 的流量(0xff 是 16 进制数,数值上等同与上面V2Ray 配置的 255),此规则目的是避免代理本机(网关)流量出现回环问题
iptables -t mangle -A V2RAY_MASK -j RETURN -m mark –mark 0xff
# 给 UDP 打标记,重路由
iptables -t mangle -A V2RAY_MASK -p udp -j MARK –set-mark 1
# 给 TCP 打标记,重路由
iptables -t mangle -A V2RAY_MASK -p tcp -j MARK –set-mark 1
# 应用规则
iptables -t mangle -A OUTPUT -j V2RAY_MASK

设置开机服务自启

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
mkdir -p /etc/iptables && iptables-save > /etc/iptables/rules.v4

# /etc/systemd/system/ 目录下创建一个名为 tproxyrule.service 的文件,写入以下内容
[Unit]
Description=Tproxy rule
After=network.target
Wants=network.target

[Service]

Type=oneshot

#注意分号前后要有空格
ExecStart=/sbin/ip rule add fwmark 1 table 100 ; /sbin/ip route add local 0.0.0.0/0 dev lo table 100 ; /sbin/iptables-restore /etc/iptables/rules.v4

[Install]
WantedBy=multi-user.target

# 执行以下命令完成开机自启
systemctl enable tproxyrule

注意事项

  1. 下载离线版v2时如果树莓派安装的是官方镜像系统则按照文中方法,如果自行安装了64位系统则需要下载 v2ray-linux-arm64.zip
  2. v2的客户端代理端口有点区别,就是socks下和HTTP下是相差一个数的,具体可自行体会;
  3. 配置文件中需要注意树莓派所在网段以及本地代理地址。

结束

树莓派的使用还有许多可待拓展,本文只是介绍了目前最新的将树莓派作为透明网关的配置方法。

参考网址:

https://linwhitehat.github.io/Blog/2020/03/24/%E7%8E%A9%E8%BD%AC%E6%A0%91%E8%8E%93%E6%B4%BE%EF%BC%88%E4%BA%8C%EF%BC%89.html

https://toutyrater.github.io/app/tproxy.html

设置树莓派显示器作为Fluidd的屏幕

1、启用树莓派的auto login,启用console auto login

2、安装openbox

sudo apt-get install --no-install-recommends xserver-xorg x11-xserver-utils xinit xinput x11-utils openbox -y

3、安装chrome浏览器

sudo apt-get install --no-install-recommends chromium-browser -y

4、修改/etc/xdg/openbox/autostart,添加以下内容

# Disable any form of screen saver / screen blanking / power management
xset s off
xset s noblank
xset -dpms

# Allow quitting the X server with CTRL-ATL-Backspace
setxkbmap -option terminate:ctrl_alt_bksp

# Start Chromium in kiosk mode
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' ~/.config/chromium/'Local State'
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/; s/"exit_type":"[^"]\+"/"exit_type":"Normal"/' ~/.config/chromium/Default/Preferences
chromium-browser --disable-infobars --kiosk 'http://127.0.0.1'

5、修改~/.bash_profile,增加以下内容

[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx -- -nocursor

屏蔽刷postfix的 IP脚本

#!/bin/bash

LOGFILE="/var/log/maillog"

#统计maillog中authentication failure的IP个数与IP
grep "authentication failure" $LOGFILE|awk '{print $7}'|grep -E -o "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"|sort|uniq -c > af_iplist.txt

#取出AF出现大于300次时的IP
awk '$1>300 {print $2}' af_iplist.txt > block_ip_list.txt

#大于300次AF的IP添加到iptables中
cat block_ip_list.txt|while read line
do
/sbin/iptables -nL | grep $line
if [ $? != 0 ]
then
    iptables -I INPUT -s $line -j DROP
fi
done

参考网址https://blog.csdn.net/github_38816863/article/details/72614694

给Postfix增加邮件过滤

前一阵子邮件服务器被攻击,后来连续收到大量退信通知,考虑通过postfix的邮件过滤机制把所有退信通知屏蔽吊。实际执行情况看来效果很好。具体操作为:

  • 一、在main.cf里面增加:header_checks = regexp:/etc/postfix/header_checks

二、编辑/etc/postfix/header_checks,

格式为:/正则表达式/ 动作 [说明文本]

例如增加以下内容:

/^Subject:.*Deliver*/ DISCARD Delivery fail notification
/^Subject:.*Undeliver*/ DISCARD Delivery fail notification
/^Subject:.*Returned\ mail*/ DISCARD Delivery fail notification
/^Sender:.*MAILER-DAEMON*/ DISCARD Mail system notification
/^Sender:.*postmaster*/ DISCARD Mail system notification

  • 三、执行:postmap /etc/postfix/header_checks
  • 四、执行:service postfix restart
  • 修改header_checks的内容后,只需要执行一下postmap /etc/postfix/header_checks,不用重启postfix即可生效

发送邮件提示Sender address rejected: not owned by user错误

客户端工具发送邮件提示Sender address rejected: not owned by user错误,maillog日志里面也提示这个错误。这个问题一般是客户端工具上mail和mail from邮箱地址不一样造成的。


方法一(但是这种方法不好,有风险):
修改main.cf

smtpd_sender_restrictions =
#       reject_sender_login_mismatch,
#       reject_authenticated_sender_login_mismatch,
#       reject_unauthenticated_sender_login_mismatch



方法二(这种方法复杂,有效):

smtpd_sender_restrictions =
        reject_sender_login_mismatch,
        reject_authenticated_sender_login_mismatch,
        reject_unauthenticated_sender_login_mismatch
smtpd_sender_login_maps = hash:/etc/postfix/sender_login_maps,
        mysql:/etc/postfix/mysql_virtual_sender_maps.cf,
        mysql:/etc/postfix/mysql_virtual_alias_maps.cf
        
然后创建/etc/postfix/sender_login_maps文件,把mail from和from不一致的加进去即可。
格式为:A地址 A用户

[root@localhost ~]#postmap sender_login_maps
[root@localhost ~]#postfix reload


 
方法三(建议方法):
把内网网段假如到信任IP地址。

mynetworks = 127.0.0.1, 10.10.8.0/24, 10.10.9.0/24
smtpd_sender_restrictions =
        permit_mynetworks,
        reject_sender_login_mismatch,
        reject_authenticated_sender_login_mismatch,
        reject_unauthenticated_sender_login_mismatch
smtpd_sender_login_maps =
#       hash:/etc/postfix/sender_login_maps,
        mysql:/etc/postfix/mysql_virtual_sender_maps.cf,
        mysql:/etc/postfix/mysql_virtual_alias_maps.cf

当启用了以下选项后,须通过方法二的sender_login_maps文件建立发件人和登录名称的映射

reject_sender_login_mismatch,
reject_authenticated_sender_login_mismatch,