ntzyz's space

∠( ᐛ 」∠)_

Category

  • Algorithm
  • Figures
  • Gameplay
  • Linux
  • Network
  • Other
  • Photos
  • Web

Tags

  • Linux
  • JavaScript
  • PS4
  • A6300
  • A7M3
  • HTML5
  • OpenWrt
  • FE55
  • Network
  • 狗
  • iptables
  • systemd
  • Tunnel
  • 猫
  • 手办
  • Web
  • Arcaea
  • VPN
  • node
  • 雪
  • AudioContext
  • PowerShell
  • Sekiro
  • HTML
  • UEFI
  • HDOJ
  • iSCSI
  • Arch Linux
  • CAPCOM
  • Highcharts.js
  • Gaming
  • USB
  • MPV
  • MHW
  • WireGuard
  • PPTP
  • SVP
  • Algorithm
  • IPv6
  • SDL
  • Highlight.js
  • FE24105G
  • FromSoftware
  • CI
  • PHP
  • MediaSource
  • Surface
  • Routing
  • LeetCode
  • SQLite
  • CSharp
  • NVMe
  • UglifyJS
  • WebAssembly
  • Node
  • Minecraft
  • NAT
  • GitHub
  • MySQL

Recent replies

  • ntzyz 发表于「CoreMark WebAssembly」
  • Hatsuroku 发表于「CoreMark WebAssembly」
  • Kyle 发表于「用 Elastic Stack 拯救 Telegram 的中文搜索」
  • ShellBin 发表于「Cinebench」
  • ntzyz 发表于「电子垃圾列表」
  • 帅粥 发表于「电子垃圾列表」
  • ntzyz 发表于「Windows 10 网络连接共享重启失效的临时解决方案」
  • Hughton 发表于「Windows 10 网络连接共享重启失效的临时解决方案」
  • Gaein nidb 发表于「使用 UEFI Shell 加载 NVMe 驱动」
  • ShellBin 发表于「DSC01764」

Links

About me
WordPress 存档
Cinebench 跑分记录
Coremark WebAssembly 跑分记录
Hpoi 手办维基 个人页
ZephRay
>Lithia's Core
Project Aurora
Ferrets 家的 Wordpress
spinmry实验室
Yuno's Wonderland
notonokodds
春上冰月的博客
kasora's blog
徐靖峰 | 个人博客
蒋炜成 | 个人博客
Test2g
447f.Misaka
Project RC
Shell Bin
标签:PowerShell

Temporary workaround for Windows 10 network connection sharing failure after reboot

2018 年 9 月 9 日分类:Other#PowerShell
Hint: this post is also available in Chinese.

The house I rented in Shanghai only provides wireless network (802.11n) to access the Internet, but I personally hope that I can get a faster wireless intranet and hide my network device from the outside, so I purchased a NETGEAR A6210 wireless network card featuring 802.11AC support and USB 3.0 interface, ready to make such a network connection:

+--------------------+       +-----------------------+
| LAN(802.11AC + GbE)| CAT5E |  HP ProLiant MS Gen8  |
| (PS4, Kindle, etc) +-------+  eth0: 192.168.137.1  |
|  192.168.137.0/24  |       | wlan0: 192.168.0.x/24 |
+--------------------+       +---+-------------------+
                                 | 802.11n
                             +---+------------+
                             | TP-LINK Router |
                             +----------------+

Implenemting this kind of structure is quiet simple for Linux PCs. You only need to enable ip_forward and execute iptables -t nat -A POSTROUTING -j MASQUERADE with root privilege. But unfortunately this USB3.0 wireless NIC has no driver in the mainline kernel. The open source driver provided by MTK has very bad performance under OpenWrt. In conclusion, it seems that the only choice of operating system is Windows.

Configuring such a network for Windows is very simple too. Right-clicking on the adapter of the wireless network card. Then select the Sharing tab, check Allow other network users to connect etc. Then choose the Ethernet Network Connection option from the dropdown. However, Microsoft has buried a bug in the implementation of network sharing in Windows 10: the network sharing will be broken after restarting the computer. Shared interface still providing DHCP service, but IP Forward is completely unavailable. After reactivate the network connection shareing, the problem can be solved.

So, we only need to prepare a scheduled task running the following PowerShell script to make the OS repeat this operation every time when it is booted:

$NetShare = New-Object -ComObject HNetCfg.HNetShare
$wlan = $null
$ethernet = $null

foreach ($int in $NetShare.EnumEveryConnection) {
  $props = $NetShare.NetConnectionProps.Invoke($int)
  if ($props.Name -eq "WLAN") {
    $wlan = $int;
  }
  if ($props.Name -eq "网桥") {
    $ethernet = $int;
  }
}

$wlanConfig = $NetShare.INetSharingConfigurationForINetConnection.Invoke($wlan);
$ethernetConfig = $NetShare.INetSharingConfigurationForINetConnection.Invoke($ethernet);

$wlanConfig.DisableSharing();
$ethernetConfig.DisableSharing();

$wlanConfig.EnableSharing(0);
$ethernetConfig.EnableSharing(1);

References

  1. NetConnectionSharing (PowerShell Module)

从网易云音乐到 Walkman 媒体播放器

2018 年 7 月 9 日分类:Other#PowerShell#SQLite#CSharp

今年六月份突然脑抽想买个很“传统”的 MP3 回来玩玩,于是就从同学那收了这么一个大法的播放器:NW-A45。到手之后检查了一下机器,几乎是全新成色,带一个 64GB 的 TF 卡,非常兴奋。但当我接上了电脑准备开始快乐地复制音乐时,我突然意识到一个问题:我从哪里复制呢?

在高中的时候,我还是保持着从网上收集音乐并整理好的习惯,原因是当时手里的播放器是 Apple iPod nano 6,整理妥当的音乐在使用 iTunes 同步时会方便很多很多。不过后来被人安利了网易云音乐之后,这个收集和整理的习惯就彻底停下来了,原因同样很简单,在线的音乐服务使用起来比自己整理要便捷太多太多。也因为如此,iPod nano 正式退休,开始养(吃)老(灰)。这之后我都是一直使用着网易云音乐,为了解决手机 16GB 存不下音乐的问题还购买了一个 iPod Touch,64G 的版本拿来听歌显然时毫无问题的。就这样,网易云音乐 + iPod Touch 的组合用到了现在。

回到从前的整理音乐+使用工具同步肯定是不会去做的,这辈子都不可能。然而 Walkman 买都买了,不把这个设备用起来就很不服气。仔细思考了一下,网易云音乐上的歌曲其实是可以随意下载的(会员才能下无损,但这不是重点),不过下载了歌曲是会丢失当时整理歌单时的顺序和分类,这一点说重要也不怎么重要,但是我很不愿意半夜听歌时随机到一些奇怪的音乐(比如血源诅咒的 OST,怕不是半夜直接吓醒),所以歌单这一信息还是有必要保留下来的。

MORE
  • «
  • 1
  • »
Copyright © 2016-2019 ntzyz. All rights reserved.
Except where otherwise noted, content on this blog is licensed under CC-BY 2.0.