# Networking



# My Home Network Architecture

#### 27 tháng 5 năm 2024

Đang cố gắng nâng cấp tốc độ mạng từ 1 Gig lên 10 Gig

[![son home network.png](https://wiki.kyluat.com/uploads/images/gallery/2024-05/scaled-1680-/5k8son-home-network.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-05/5k8son-home-network.png)

# Remote Shutdown on via LAN or LOCAL Network for WINDOWS 10/11

#### Enable remote Shutdown on Window 10

#### Window Information

WIN+R   
msinfo32

#### To do:

- [ ] Set Password and Account for Window to be accessible for the remote
- [ ] Enable firewall discovery
- [ ] Set policy for local shutdown

Video instruction: [https://www.youtube.com/watch?v=UCphBNYMc4U](https://www.youtube.com/watch?v=UCphBNYMc4U)

```
WIN+E
RIGHT CLICK on THIS PC
Select MANAGE
```

Go to

System Tools &gt; Local Users and Groups &gt; Users

Right Click on your Account PC Name and Set New Password. **Make sure you rembember the password so that on the next logon you could enter.**

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/lR3image.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/lR3image.png)

Next, you will need to set the policy for local:

Open Registry Editor

Find the Path and create new value as following:

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/JMcimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/JMcimage.png)

```
Value name: LocalAccountTokenFilterPolicy

Value data: 1

Base: Hexadecimal
```

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/vKeimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/vKeimage.png)

Continue to search:

manage advanced sharing settings

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/AJ2image.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/AJ2image.png)

Check **Turn on Network discovery**

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/20Rimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/20Rimage.png)

Good,

CMD and run as Adminstrator

The commands are useful for local shutdown or app usage:

```
net use \\TargetPC /user:PCUSERNAME PASSWORD
```

To remote shutdown the targetpc:

```
shutdown /m \\TARGETPC /s
```

Thats all. You have enabled the remote shutdown pc on windows 10 or 11

```
net rpc shutdown -I 192.168.1.99 -U "USERNAME%PASSWORD"
```

USERNAME is your PC USERNAME  
PASSWORD is the password you have setted on the previous step

##### Some notes if you are encountering WOL problem with BIOS and WOL Settings:

WOL Fixed! For me was the Windows settings that fixed the type of shutdown somehow  
  
BIOS...  
Make screenshots  
Update BIOS  
Set settings how they were before update  
Set Advanced\\APM Configuration\\ErP Ready = DISABLED  
Set Advanced\\APM Configuration\\Power on by PCI-E = ENABLED  
  
  
WINDOWS...  
Open Powershell/CMD with ADMIN rights  
Run: REG ADD "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power" /V HiberbootEnabled /T REG\_dWORD /D 0 /F  
Open device manager, find your NIC, open, drivers tab - Update driver. If nothing found, download directly from manufacturer website  
Once updated, reboot.  
After reboot, open NIC properties\\Power Management tab:  
Tick all boxes - Allow computer to turn off device, allow to wake up, only allow magic packet.  
Open NIC properties\\Advanced tab and (where available):  
Set Enable PME = ENABLED  
Set Energy Efficient Ethernet / Green etc = DISABLED  
Wake on Magic Packet = ENABLED  
Wake on Pattern Match = ENABLED  
Reboot, then after reboot shutdown.

# Pihole + Zerotier + ZeroNSD

Purpose: To have Zerotier act as VPN when we go outside and still able to visit home network with its dns name server resolved.

- Setup Pihole on VM
- Setup Zerotier on VM
- Setup ZeroNSD on VM

Notes:

##### Zerotier Installation and Settings:

Tutorial: [https://www.youtube.com/watch?v=1pTsgWNae88](https://www.youtube.com/watch?v=1pTsgWNae88)

Portainer Docker Compose Yaml:

```
version: "3"

volumes:
  ztncui:
  zt1:

services:
  ztncui:
    image: keynetworks/ztncui
    container_name: ztncui
    environment:
      - USER_UID=998 #adjust to your system
      - USER_GID=100 #adjust to your system
      - NODE_ENV=production
      - HTTPS_PORT=3443
      - ZTNCUI_PASSWD=[YOURPASSWORD]  #change this
      - MYDOMAIN=[YOUR.DOMAIN.NAME/SUBDOMAIN.DOMAIN.NAME] #change this to the domain you want to use for the controller
      - MYADDR=[YOUR.PUBLIC.IP.HERE] #this is optional. if you use it, this is the public IP your ISP gave you
    volumes:
      - ztncui:/opt/key-networks/ztncui/etc
      - zt1:/var/lib/zerotier-one
    ports:
      - 3443:3443 #dashboard port
      - 3180:3180
```

Easy setting up new network address: 192.168.2.0/24 subset

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/IJOimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/IJOimage.png)

##### Pihole Settings:

When install New instance of Pihole, you need to config DNS &gt; Interfaces Settings &gt; Permit all origins \[X\] checked

**Turn of dhcp.**

Next, you will need to route between pihole eth0 and zerotier interfaces:

[https://zerotier.atlassian.net/wiki/spaces/SD/pages/224395274/Route+between+ZeroTier+and+Physical+Networks](https://zerotier.atlassian.net/wiki/spaces/SD/pages/224395274/Route+between+ZeroTier+and+Physical+Networks)

```
PHY_IFACE=eth0; ZT_IFACE=zt3f2teohp

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o zt3f2teohp -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i zt3f2teohp -o eth0 -j ACCEPT



```

Go to your zerotier network :

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/Pbvimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/Pbvimage.png)

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/H1Simage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/H1Simage.png)

**192.168.2.0/24** is Zerotier Subnet

**192.168.1.0/24** is Your local subnet that point to gateway of Pihole IP which is (**192.168.2.1**). Make sure when you install zerotier client on linux , please re-assign the ip address is 192.168.2.1 which is easier to remember.

result:

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/yXzimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/yXzimage.png)

Change your DNS to pihole zerotier ip:

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/o20image.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/o20image.png)

From now on, when you access from your phone with zerotier vpn , you will be able to visit ip address on your lan network.

# Setup OpenWRT trên Proxmox: Tạo Switch Ports để xài cho các lỗ cắm Ethernet còn dư

Cách setup trên Proxmox:

Blog post: [https://community.bigbeartechworld.com/t/setting-up-openwrt-on-a-virtual-machine-with-proxmox/257](https://community.bigbeartechworld.com/t/setting-up-openwrt-on-a-virtual-machine-with-proxmox/257)

Image File: generic-ext4-rootfs.img.gz

[https://downloads.openwrt.org/releases/23.05.2/targets/x86/64/](https://downloads.openwrt.org/releases/23.05.2/targets/x86/64/)

Cài đặt theo cấu hình như tutorial này: [https://gist.github.com/dragonfire1119/f3acd42414abfff762d2dad5e50f7cc6](https://gist.github.com/dragonfire1119/f3acd42414abfff762d2dad5e50f7cc6)

Tắt máy và add thêm các cổng trên VM Proxmox, như hình dưới mình có 2 cổng, 1 cổng kết nối mạng và một cổng làm switch tới máy khác.

Bước một tạo thêm Bridge Port trên Node, vào rack2 -&gt; System -&gt; Network -&gt; chọn Create -&gt; Linux Bridge

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/i1ximage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/i1ximage.png)

Bạn có thể thấy 2 network device, eno1, eno2 tương ứng cho vmbr0, vmbr1:

Nếu không có hiện các device eno1, eno2 thì có thể là tên khác tùy theo hardware / cpu manufacturer.

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/mYUimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/mYUimage.png)

Còn không có các device gì hết thì bạn thử cắm ethernet vào switch trước cho nó nhận ( nhớ restart lại )

Kết tiếp vào VM Openwrt của bạn , phần hardware, thêm vào vmbr1 vmbr2 vmbr3 (nếu có 4 ports ethernet)

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/fkUimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/fkUimage.png)

Đăng nhập vào web browser ui của openwrt trên trình duyệt:

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/FWbimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/FWbimage.png)

vào phần network interfaces

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/YJtimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/YJtimage.png)

Tạo / Sửa interface:

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/0OJimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/0OJimage.png)

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/bODimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/bODimage.png)

Cập nhập dns ip:

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/ERsimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/ERsimage.png)

2 DNS IP là mình tạo 2 instance Pihole, một cái làm Primary local dns, 1 cái làm secondary để phụ trợ cho cái primary dns.

Primary DNS đi trước, secondary DNS ip đi sau.

Save

Vào Device Tab và chọn configure... cho Bridge Lan

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/eRWimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/eRWimage.png)

Thêm / Check vào ports cần làm switch ports

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/m7timage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/m7timage.png)

Save

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/QkCimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/QkCimage.png)

Save &amp; Apply

Ssh vào máy và đánh các command sau để cài đặt các package cần thiết cho vm:

```
opkg update
opkg install qemu-ga
```

Restart lại VM

# Synology DSM USB Ethernet 2.5 Gbps

Mình muốn synology ethernet speed từ 1 Gbps lên 2.5 Gbps

Mình đã mua con USB Type A 2.5Gbps của Ugreen tại đây: [https://go.kyluat.com/0dRtm](https://go.kyluat.com/0dRtm)

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/HZjimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/HZjimage.png)

Driver RTL8152 trên : [https://github.com/bb-qq/r8152](https://github.com/bb-qq/r8152)

Bạn có thể download bản mình đang test:

[https://github.com/bb-qq/r8152/releases/tag/2.14.0-3](https://github.com/bb-qq/r8152/releases/tag/2.14.0-3)

Vào package manager và click vào manual install sau đó paste link url của file r8152-apollolake-2.14.0-3.spk

Nếu bạn xài system os khác dsm khác phiên bản 6.2 trở lên thì research chọn đúng driver mới hơn

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/8kOimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/8kOimage.png)

Sau khi Install và Manual Run driver trên package center,

mình vào control panel -&gt; Network -&gt; Network Interface để điều chỉnh settings ip address và set service order lên đầu:

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/Bizimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/Bizimage.png)

Mình vẫn giữ nguyên dây cũ và thêm vào dây mới để tiện khi nào usb sau khi bị cúp điện nó không nhận nữa thì vẫn vào được.

Vấn đề của usb eth là khi bạn reboot lại thì synology fake của mình nó không nhận ra nữa vì thế mình cần phải re-install/re-run service của driver.

Set MTU 9000 nhé, mình không biết cái này mày hướng dẫn thì nó bảo nên set thế cho performance tăng:

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/gKfimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/gKfimage.png)

# Dahua IP Address

Sử dụng Dahua Config Tool để tìm kiếm ip của dahua devices trong network:

[https://dahuawiki.com/ConfigTool](https://dahuawiki.com/ConfigTool)

Mua các device rẻ thì tự config ip không được nên phải xài trình này kiếm.