Windows: How to remove and re-add IPs with skipassource true flag


) Download three optional hot fixes from Microsoft:
Windows 2008 R2:
KB2386184: This is a patch adding a feature to exclude IP addresses from the list of IP addresses allowed as the outgoing IP address (e. source). This is the key patch allowing us to “select” the primary IP address.
KB2554859: KB2386184 was buggy and seems to be a quickfix. This hotfix fixes a bug where the GUI used to manage IP addresses on the server clears the configurations made using the new feature added by KB2386184 .
KB2551090: Apparently KB2386184 created another bug where you couldn’t select IP addresses excluded as outgoing IP address. This fixed that.


Windows 2008:

) Get list of existing IPs

netsh interface ip show config name="Local Area Connection" |findstr "IP Address" > ips.txt

Where “Local Area Connection” is the name of your network adapter

) Edit list to make it list just the IPs and also remove the main ‘primary’ IP

) Remove IPs

FOR /F %G IN (ips.txt) DO netsh int ipv4 delete address "Local Area Connection" addr=%G

) Re-add IPs with skipassource=true

FOR /F %G IN (ips.txt) DO netsh int ipv4 add address "Local Area Connection" %G skipassource=true