197 lines
No EOL
6.1 KiB
Markdown
197 lines
No EOL
6.1 KiB
Markdown
# Minecraft Windows Network Configuration
|
|
|
|
This guide provides PowerShell commands to configure Windows Firewall for Minecraft networking.
|
|
|
|
## Prerequisites
|
|
|
|
- Windows 10 or later
|
|
- PowerShell running as Administrator
|
|
- Java Runtime Environment (JRE)
|
|
|
|
## Check Installed Java Versions
|
|
|
|
First, let's check which Java versions are installed on your system:
|
|
|
|
```powershell
|
|
# List all Java installations
|
|
Get-Command java -ErrorAction SilentlyContinue | Select-Object Source
|
|
Get-ChildItem "C:\Program Files\Java" -ErrorAction SilentlyContinue
|
|
Get-ChildItem "C:\Program Files (x86)\Java" -ErrorAction SilentlyContinue
|
|
Get-ChildItem "$env:LOCALAPPDATA\Programs\Java" -ErrorAction SilentlyContinue
|
|
Get-ChildItem "$env:APPDATA\ATLauncher\jre" -ErrorAction SilentlyContinue
|
|
```
|
|
|
|
## Firewall Configuration
|
|
|
|
Open PowerShell as Administrator and run the following commands:
|
|
|
|
### 1. Allow Java through Windows Firewall (Dynamic Selection)
|
|
|
|
```powershell
|
|
# Function to create firewall rules for a specific Java path
|
|
function Add-MinecraftJavaFirewallRules {
|
|
param (
|
|
[string]$JavaPath
|
|
)
|
|
|
|
if (Test-Path $JavaPath) {
|
|
Write-Host "Adding firewall rules for Java at: $JavaPath"
|
|
New-NetFirewallRule -DisplayName "Minecraft Java" -Direction Inbound -Program $JavaPath -Action Allow
|
|
New-NetFirewallRule -DisplayName "Minecraft Java" -Direction Outbound -Program $JavaPath -Action Allow
|
|
} else {
|
|
Write-Host "Java path not found: $JavaPath"
|
|
}
|
|
}
|
|
|
|
# Get all possible Java paths
|
|
$javaPaths = @(
|
|
"C:\Users\rob\AppData\Roaming\ATLauncher\jre\bin\java.exe",
|
|
"C:\Program Files\Java\*\bin\java.exe",
|
|
"C:\Program Files (x86)\Java\*\bin\java.exe",
|
|
"$env:LOCALAPPDATA\Programs\Java\*\bin\java.exe"
|
|
)
|
|
|
|
# Find all existing Java installations
|
|
$foundJavaPaths = $javaPaths | ForEach-Object { Get-ChildItem $_ -ErrorAction SilentlyContinue } | Select-Object -ExpandProperty FullName
|
|
|
|
if ($foundJavaPaths.Count -gt 1) {
|
|
Write-Host "Multiple Java installations found:"
|
|
for ($i = 0; $i -lt $foundJavaPaths.Count; $i++) {
|
|
Write-Host "[$i] $($foundJavaPaths[$i])"
|
|
}
|
|
|
|
$selection = Read-Host "Enter the number of the Java installation to use (or 'all' for all installations)"
|
|
|
|
if ($selection -eq 'all') {
|
|
foreach ($path in $foundJavaPaths) {
|
|
Add-MinecraftJavaFirewallRules -JavaPath $path
|
|
}
|
|
} else {
|
|
$index = [int]$selection
|
|
if ($index -ge 0 -and $index -lt $foundJavaPaths.Count) {
|
|
Add-MinecraftJavaFirewallRules -JavaPath $foundJavaPaths[$index]
|
|
} else {
|
|
Write-Host "Invalid selection"
|
|
}
|
|
}
|
|
} else {
|
|
# If only one Java installation is found, use it automatically
|
|
if ($foundJavaPaths) {
|
|
Add-MinecraftJavaFirewallRules -JavaPath $foundJavaPaths[0]
|
|
} else {
|
|
Write-Host "No Java installations found"
|
|
}
|
|
}
|
|
```
|
|
|
|
### 2. Open Required Minecraft Ports
|
|
|
|
```powershell
|
|
# Allow Minecraft default port (25565)
|
|
New-NetFirewallRule -DisplayName "Minecraft TCP" -Direction Inbound -LocalPort 25565 -Protocol TCP -Action Allow
|
|
New-NetFirewallRule -DisplayName "Minecraft UDP" -Direction Inbound -LocalPort 25565 -Protocol UDP -Action Allow
|
|
```
|
|
|
|
### 3. Verify Rules
|
|
|
|
```powershell
|
|
# List all Minecraft-related firewall rules
|
|
Get-NetFirewallRule | Where-Object DisplayName -like "*Minecraft*" | Format-Table DisplayName, Enabled, Direction, Action
|
|
```
|
|
|
|
## LAN Connection Configuration
|
|
|
|
### 1. Network Discovery and File Sharing
|
|
|
|
```powershell
|
|
# Enable Network Discovery
|
|
Set-NetFirewallRule -DisplayGroup "Network Discovery" -Enabled True
|
|
|
|
# Enable File and Printer Sharing
|
|
Set-NetFirewallRule -DisplayGroup "File and Printer Sharing" -Enabled True
|
|
```
|
|
|
|
### 2. Check Network Profile
|
|
|
|
```powershell
|
|
# Get current network profile
|
|
Get-NetConnectionProfile | Select-Object Name, NetworkCategory
|
|
|
|
# Set network to Private (if needed)
|
|
Set-NetConnectionProfile -NetworkCategory Private
|
|
```
|
|
|
|
### 3. Verify LAN Connectivity
|
|
|
|
```powershell
|
|
# Get local IP address
|
|
Get-NetIPAddress | Where-Object {$_.AddressFamily -eq "IPv4" -and $_.PrefixOrigin -eq "Dhcp"} | Select-Object IPAddress, InterfaceAlias
|
|
|
|
# Test connection to other players
|
|
Test-NetConnection -ComputerName <other_player_ip> -Port 25565
|
|
```
|
|
|
|
## Removing Rules
|
|
|
|
If you need to remove the firewall rules, use these commands:
|
|
|
|
```powershell
|
|
# Remove Minecraft firewall rules
|
|
Remove-NetFirewallRule -DisplayName "Minecraft Java"
|
|
Remove-NetFirewallRule -DisplayName "Minecraft TCP"
|
|
Remove-NetFirewallRule -DisplayName "Minecraft UDP"
|
|
```
|
|
|
|
## Notes
|
|
|
|
- Make sure to run PowerShell as Administrator
|
|
- The script will automatically detect Java installations
|
|
- Default Minecraft port is 25565, adjust if using a different port
|
|
- These rules allow both incoming and outgoing connections for Minecraft
|
|
- For LAN games, ensure all players are on the same network
|
|
- Some antivirus software may block Minecraft connections
|
|
|
|
## Troubleshooting
|
|
|
|
If you experience connection issues:
|
|
|
|
1. Verify the rules are enabled:
|
|
```powershell
|
|
Get-NetFirewallRule -DisplayName "Minecraft*" | Select-Object DisplayName, Enabled
|
|
```
|
|
|
|
2. Check if the ports are actually open:
|
|
```powershell
|
|
Test-NetConnection -ComputerName localhost -Port 25565
|
|
```
|
|
|
|
3. Ensure Java is running with proper permissions:
|
|
```powershell
|
|
Get-Process java | Select-Object Id, ProcessName, Path
|
|
```
|
|
|
|
4. Check Java version:
|
|
```powershell
|
|
java -version
|
|
```
|
|
|
|
5. LAN Connection Issues:
|
|
```powershell
|
|
# Check if Windows Defender Firewall is blocking Minecraft
|
|
Get-NetFirewallApplicationFilter -Program "C:\Users\rob\AppData\Roaming\ATLauncher\jre\bin\java.exe"
|
|
|
|
# Verify network sharing settings
|
|
Get-NetFirewallRule -DisplayGroup "Network Discovery" | Select-Object DisplayName, Enabled
|
|
Get-NetFirewallRule -DisplayGroup "File and Printer Sharing" | Select-Object DisplayName, Enabled
|
|
|
|
# Check if port is in use
|
|
netstat -ano | findstr :25565
|
|
```
|
|
|
|
6. Common LAN Issues:
|
|
- Ensure all players are on the same network
|
|
- Check if Windows Defender Firewall is blocking the connection
|
|
- Verify that Network Discovery is enabled
|
|
- Make sure the host's computer is not in sleep mode
|
|
- Check if any antivirus software is blocking the connection
|
|
- Ensure the host's Minecraft version matches other players' versions |