1. Use ifup/ifdown scripts to enable/disable the the checking depending on the network connection.
2. Use rob1n's method, except use sed to put a '#' infront of everyline.