Update ip-renew/README.md
This commit is contained in:
@@ -1,54 +1,27 @@
|
|||||||
## WSL2에서 Windwos IP 변경하기
|
# Windows에서 IP 변경하기
|
||||||
|
|
||||||
- 아래의 방법으로 원하는 LAN카드의 MAC주소를 변경할 수 있다.
|
- 아래의 방법으로 원하는 LAN카드의 MAC주소를 변경할 수 있다.
|
||||||
- MAC주소가 변경되면 ISP 모뎀에서 새로운 기기로 인식하고 새로운 IP를 할당한다.
|
- MAC주소가 변경되면 ISP 모뎀에서 새로운 기기로 인식하고 새로운 IP를 할당한다.
|
||||||
|
- Powershell (관리자로 실행):
|
||||||
- Powershell:
|
|
||||||
```powershell
|
```powershell
|
||||||
# 현재 네트워크 어댑터 목록 확인
|
# 현재 네트워크 어댑터 목록 확인
|
||||||
Get-NetAdapter
|
Get-NetAdapter
|
||||||
|
|
||||||
# MAC 주소 변경 (어댑터 이름과 원하는 MAC 주소 지정)
|
Name InterfaceDescription ifIndex Status MacAddress LinkSpeed
|
||||||
|
---- -------------------- ------- ------ ---------- ---------
|
||||||
|
vEthernet (WSL) Hyper-V Virtual Ethernet Adapter 26 Up 00-15-5D-20-8B-D9 10 Gbps
|
||||||
|
VMware Network Adapte...1 VMware Virtual Ethernet Adapter for ... 14 Up 00-50-56-C0-00-01 100 Mbps
|
||||||
|
vEthernet (Default Swi... Hyper-V Virtual Ethernet Adapter #2 30 Up 00-15-5D-73-E2-0C 10 Gbps
|
||||||
|
VMware Network Adapte...8 VMware Virtual Ethernet Adapter for ... 11 Up 00-50-56-C0-00-08 100 Mbps
|
||||||
|
Bluetooth 네트워크 연결 Bluetooth Device (Personal Area Netw... 10 Not Present E4-60-17-4B-6D-64 0 bps
|
||||||
|
이더넷 Intel(R) Ethernet Controller (3) I225-V 8 Not Present D8-43-AE-3D-0F-64 0 bps
|
||||||
|
Wi-Fi Intel(R) Wi-Fi 6E AX211 160MHz 3 Up E4-60-17-4B-6D-60 721 Mbps
|
||||||
|
|
||||||
|
|
||||||
|
# 원하는 MAC 주소로 변경
|
||||||
Set-NetAdapter -Name "이더넷" -MacAddress "00-11-22-33-44-55"
|
Set-NetAdapter -Name "이더넷" -MacAddress "00-11-22-33-44-55"
|
||||||
|
|
||||||
# 랜덤 MAC 주소 생성 및 설정
|
# 랜덤 MAC 주소 생성 및 설정
|
||||||
$randomMac = (0..5 | ForEach-Object { "{0:X2}" -f (Get-Random -Minimum 0 -Maximum 255) }) -join '-'
|
$randomMac = (0..5 | ForEach-Object { "{0:X2}" -f (Get-Random -Minimum 0 -Maximum 255) }) -join '-'
|
||||||
Set-NetAdapter -Name "이더넷" -MacAddress $randomMac
|
Set-NetAdapter -Name "이더넷" -MacAddress $randomMac
|
||||||
```
|
```
|
||||||
|
|
||||||
## ~~WSL2에서 Windows SSH 접속하기~~
|
|
||||||
|
|
||||||
WSL2의 명령어로 IP를 변경하기 위해 WSL2 -> Windows SSH 연결을 수립한다.
|
|
||||||
|
|
||||||
- Powershell (관리자로 실행):
|
|
||||||
```powershell
|
|
||||||
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
|
|
||||||
Start-Service sshd
|
|
||||||
Set-Service -Name sshd -StartupType 'Automatic'
|
|
||||||
if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) {
|
|
||||||
Write-Output "Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it..."
|
|
||||||
New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
|
|
||||||
} else {
|
|
||||||
Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists."
|
|
||||||
}
|
|
||||||
|
|
||||||
(Get-Content -Path "C:\ProgramData\ssh\sshd_config") |
|
|
||||||
ForEach-Object {$_ -replace "^#PubkeyAuthentication yes", "PubkeyAuthentication yes"} |
|
|
||||||
Set-Content -Path "C:\ProgramData\ssh\sshd_config"
|
|
||||||
```
|
|
||||||
Restart-Service sshd
|
|
||||||
|
|
||||||
Debian에서 바라보는 Windows의 IP는 다음과 같이 얻을 수 있다.
|
|
||||||
- Debian bash:
|
|
||||||
```sh
|
|
||||||
ip route | grep default | awk '{print $3}'
|
|
||||||
# 172.17.112.1
|
|
||||||
```
|
|
||||||
|
|
||||||
ssh 계정에 접속받기 위해서는 그 윈도우 계정에 암호가 설정되어 있어야 한다.
|
|
||||||
|
|
||||||
- Debian bash:
|
|
||||||
```sh
|
|
||||||
cat ~/.ssh/id_rsa.pub >> /mnt/c/Users/<YourUsername>/.ssh/authorized_keys
|
|
||||||
ssh w@$(ip route | grep default | awk '{print $3}')
|
|
||||||
```
|
|
||||||
Reference in New Issue
Block a user