M587 wasn't intended to be used within config.g. Please try sending it from DWC instead, or alternatively from a macro file. Make sure that you include the SSID of the access point in the quotation marks after the S parameter (your example shows the SSID as empty).
Then run M587 without parameters. It should list the known SSIDs, with the IP address you specified (or 0.0.0.0 if you didn't specify one).
If the readback looks correct, reboot the Duet and see whether the IP address has changed.