41223108 cp2023

  • Home
    • SMap
    • reveal
    • blog
  • About
  • 倉儲維護
    • s.cycu.org維護
    • windows維護
  • weekly progress
    • w1~4
    • w5
    • w6
    • w7
    • w9
    • w12
      • helloworld
      • GD繪圖程式1
    • W13
    • w15
  • ANSIC
    • 1.
    • 2.
    • 3.
    • 4.
    • 5.
    • 6.
    • 7.
    • 8.
    • 9.
    • 10.
  • NOTE
    • ssh
    • puttygen
  • 國旗練習
    • Thai
    • Laos
    • Bangladesh
    • vietnam
    • Italian
    • Russia
    • Belgium
    • Ukraine
    • Korea
  • 課程評分
  • Brython
  • setup
  • C_lib
  • replit
  • MSD
  • Final
Brython << Previous Next >> C_lib

setup

利用隨身碟中的批次檔案, 設定所需的網路環境.

cadlab_network_setup.7z

納入個別學員所分配到的 IPv6 固定網址設定: 2023_fall_cadlab_network_setup.7z

1_network_setup.bat (需要管理者身分執行, 才能關閉 IPv4 網路, 啟動 IPv6 網路)

1
2
3
4
5
6
echo "disable ipv4 and setup proxy for ipv6"
SET CurrentDir=%~dp0
%windir%\system32\reg.exe import %CurrentDir%1_2023_cadlab_network_setup.reg
powershell -executionpolicy bypass -File %CurrentDir%1_disable_ipv4.ps1
rem mstsc /admin /v:your_server
exit

其中包含以下兩個設定檔案:

1_2023_cadlab_network_setup.reg 用於關閉自動 Proxy 搜尋, 開啟手動設定 Proxy server.

1
2
3
4
5
6
7
8
9
10
11
Windows Registry Editor Version 5.00
 
 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
 ; disable AutoDetect
"AutoDetect"=dword:00000000
"MigrateProxy"=dword:00000001
; enable Proxy
"ProxyEnable"=dword:00000001
"ProxyHttp1.1"=dword:00000000
"ProxyServer"="http://[2001:288:6004:17::4]:3128"
"ProxyOverride"="localhost;192.168.1.0/24;<local>"

1_disable_ipv4.ps1 用於關閉 IPv4 網路協定, 開啟 IPv6 網路協定.

對 ChatGPT 提問:

powershell "Disable-NetAdapterBinding -Name "*" -ComponentID ms_tcpip
Enable-NetAdapterBinding -Name "*" -ComponentID ms_tcpip6"可以關閉 IPv4 網路, 開啟 IPv6, 如何同時設定 IPv6 所使用的兩台 DNS servers?

原先設定:

1
2
Disable-NetAdapterBinding -Name "*" -ComponentID ms_tcpip
Enable-NetAdapterBinding -Name "*" -ComponentID ms_tcpip6

修改後的 1_disable_ipv4.ps1 Powershell 設定檔案:

1
2
3
4
5
6
7
8
9
# 關閉 IPv4 網路
Disable-NetAdapterBinding -Name "*" -ComponentID ms_tcpip
 
# 啟用 IPv6 網路
Enable-NetAdapterBinding -Name "*" -ComponentID ms_tcpip6
 
# 設置 IPv6 網路中的兩個 DNS 伺服器 (hinet)
$dnsServers = "2001:b000:168::1", "2001:b000:168::2"
Set-DnsClientServerAddress -InterfaceAlias "*" -ServerAddresses $dnsServers

對 ChatGPT 提問:

the following powershell script can setup windows network connection "# 關閉 IPv4 網路
Disable-NetAdapterBinding -Name "*" -ComponentID ms_tcpip
 
# 啟用 IPv6 網路
Enable-NetAdapterBinding -Name "*" -ComponentID ms_tcpip6
 
# 設置 IPv6 網路中的兩個 DNS 伺服器 (hinet)
$dnsServers = "2001:b000:168::1", "2001:b000:168::2"
Set-DnsClientServerAddress -InterfaceAlias "*" -ServerAddresses $dnsServers" what if the ipv6 address need set to 2001:288:6004:17:1234::1234 and subnet prefix as 64 and ipv6 gateway as 2001:288:6004:17::254

可以得到下列回應答案:

加上個別學員所分配到的 IPv6 固定網址設定後的 1_disable_ipv4.ps1 Powershell 設定檔案 (必須自行更改固定 Ipv6 位址):

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
# 關閉 IPv4 網路
Disable-NetAdapterBinding -Name "*" -ComponentID ms_tcpip
   
# 啟用 IPv6 網路
Enable-NetAdapterBinding -Name "*" -ComponentID ms_tcpip6
   
# 設置 IPv6 網路中的兩個 DNS 伺服器 (hinet)
$dnsServers = "2001:b000:168::1", "2001:b000:168::2"
Set-DnsClientServerAddress -InterfaceAlias "*" -ServerAddresses $dnsServers
 
 
# 設定 IPv6 固定位址 (fixed address), 子網路首碼長度 (subnet prefix) 與網路預設閘道 (gateway) 等三個變數
$ipv6Address = "2001:288:6004:17:請使用個人所分配到的 IPv6 位址"
$subnetPrefixLength = 64
$gateway = "2001:288:6004:17::254"
  
# 參考 https://serverfault.com/questions/427234/getting-network-interface-device-name-in-powershell
$query = "SELECT * FROM Win32_NetworkAdapter WHERE Manufacturer != 'Microsoft' AND NOT PNPDeviceID LIKE 'ROOT\\%'"
$interfaces = Get-WmiObject -Query $query | Sort index
$interfaces | ForEach{
    $friendlyname = $_ | ForEach-Object { $_.NetConnectionID }
    New-NetIPAddress -AddressFamily "IPv6" -InterfaceAlias $friendlyname -IPAddress $ipv6Address -PrefixLength $subnetPrefixLength -DefaultGateway $gateway
}
 
  
# 列出所使用的 IPv6 網路通訊協定內容
Write-Host "IPv6 Address: $ipv6Address/$subnetPrefixLength"
Write-Host "IPv6 Gateway: $gateway"

下載 2023_fall_w7_cadlab_network_setup.7z (需要下載密碼), 必須先放入個人所分配到的 IPv6 位址後, 以管理者身分執行批次檔案, 就能直接完成電腦輔助設計室中電腦的網路連線設定.

各學員所分配的固定 IPv6 位址如下:

1a 學員展示用 IPv6 位址: 2001:288:6004:17:2023:cba::班級名單序號

2b 學員展示用 IPv6 位址: 2001:288:6004:17:2023:cbb::班級名單序號


Brython << Previous Next >> C_lib

Copyright © All rights reserved | This template is made with by Colorlib