Use configured gateway in all platforms. Closes #3668.

Also use python 2.6 compatible str.format.