Skip to content

Commit 060dbf2

Browse files
committed
feat(network): update Windows command to restart network adapter with IP address, subnet mask, and default gateway settings
1 parent 75e877a commit 060dbf2

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

changelogs/2026-02-14_06-13-05.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Changelog
2+
3+
## [Unreleased]
4+
5+
### Added
6+
- Ability to set a static IP address, subnet mask, and default gateway for the network interface on Windows after restarting the adapter.
7+
- New input parameters:
8+
- `ip_address`: to specify the alias IP address.
9+
- `netmask`: to specify the subnet mask (with a default value of `255.255.255.0`).
10+
- `gateway`: to specify the default gateway to restore after restart (optional).
11+
12+
### Changed
13+
- The Windows command to restart the network adapter now includes setting the IP address, subnet mask, and default gateway if provided.
14+
- The Windows verification command for removing an alias IP now uses the `Get-NetIPAddress` cmdlet directly instead of through PowerShell.

repository/network/alias-ip.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,25 @@ versions:
9393
arch: ip link set {{interface}} down && sleep 1 && ip link set {{interface}} up && echo "Adapter {{interface}} restarted"
9494
alpine: ip link set {{interface}} down && sleep 1 && ip link set {{interface}} up && echo "Adapter {{interface}} restarted"
9595
darwin: ifconfig {{interface}} down && sleep 1 && ifconfig {{interface}} up && echo "Adapter {{interface}} restarted"
96-
windows: 'Disable-NetAdapter -Name "{{interface}}" -Confirm:([bool]0); Start-Sleep -Seconds 2; Enable-NetAdapter -Name "{{interface}}"; Start-Sleep -Seconds 3; Write-Host "Adapter {{interface}} restarted"'
96+
windows: 'Disable-NetAdapter -Name "{{interface}}" -Confirm:([bool]0); Start-Sleep -Seconds 2; Enable-NetAdapter -Name "{{interface}}"; Start-Sleep -Seconds 3; if ("{{gateway}}" -ne "") { netsh interface ip set address "{{interface}}" static {{ip_address}} {{netmask}} {{gateway}} }; Write-Host "Adapter {{interface}} restarted with gateway {{gateway}}"'
9797
command: ip link set {{interface}} down && sleep 1 && ip link set {{interface}} up && echo "Adapter {{interface}} restarted"
9898
skip_on_error: true
9999
args:
100100
- name: interface
101101
prompt: "Enter the network interface name (e.g., eth0, ens33, Ethernet)"
102102
default: "eth0"
103103
required: true
104+
- name: ip_address
105+
prompt: "Enter the alias IP address (e.g., 192.168.1.100)"
106+
required: true
107+
- name: netmask
108+
prompt: "Enter the subnet mask (e.g., 255.255.255.0)"
109+
default: "255.255.255.0"
110+
required: false
111+
- name: gateway
112+
prompt: "Enter the default gateway to restore after restart (e.g., 192.168.1.1)"
113+
default: ""
114+
required: false
104115
- description: Verify alias IP was added
105116
platforms:
106117
ubuntu: ip addr show {{interface}} | grep inet
@@ -200,7 +211,7 @@ versions:
200211
arch: ip addr show {{interface}} && echo "---" && echo "Verify the IP is no longer listed above"
201212
alpine: ip addr show {{interface}} && echo "---" && echo "Verify the IP is no longer listed above"
202213
darwin: ifconfig {{interface}}
203-
windows: powershell -Command "Get-NetIPAddress -InterfaceAlias '{{interface}}' | Format-Table -AutoSize; Write-Host '--- Verify the IP is no longer listed above'"
214+
windows: 'Get-NetIPAddress -InterfaceAlias "{{interface}}" | Format-Table -AutoSize; Write-Host "--- Verify the IP is no longer listed above"'
204215
command: ip addr show {{interface}} && echo "---" && echo "Verify the IP is no longer listed above"
205216
skip_on_error: false
206217
args:

0 commit comments

Comments
 (0)