Windows Network Interface changing on detach/attach

Whenever i detach a port from a server and later attach the same port again, Windows is recognize it as a new network interface. This will cause a loss of all IP configuration on OS level. is there any solution to detach and attach a port without losing the configuration. If not, is there any workaround like cloudbase-init