I could reproduce the crash, but it's caused by YOUR empty gwmetric.
You must always assign a value to gwmetric. The only exception is if you set gateway to none (in this case you must leave gwmetric empty).
I've tested your script with gwmetric=1 and everything seems to work fine!
Quote:
A default gateway with this IP Address already configured on this interface.
|
This isn't an error. You'll get this message if you run the script multiple times.