{"id":571,"date":"2018-04-04T08:17:19","date_gmt":"2018-04-04T16:17:19","guid":{"rendered":"http:\/\/andrewwippler.com\/?p=571"},"modified":"2018-04-02T08:23:32","modified_gmt":"2018-04-02T16:23:32","slug":"dhcp-ip-updater","status":"publish","type":"post","link":"https:\/\/andrewwippler.com\/2018\/04\/04\/dhcp-ip-updater\/","title":{"rendered":"DHCP IP updater"},"content":{"rendered":"

This is the script I use to change the DNS record of my home IP when it changes. I have it running once a week and have not noticed a lapse in coverage. If your ISP has DHCP configured correctly, you will receive the same IP address when you are due for a renew. Otherwise you need a script like the one below.<\/p>\n

#!\/usr\/bin\/ruby\n\nrequire 'aws-sdk'\nrequire 'socket'\n\ndef my_first_public_ipv4\n  Socket.ip_address_list.detect{|intf| intf.ipv4? and !intf.ipv4_loopback? and !intf.ipv4_multicast? and !intf.ipv4_private?}\nend\n\nip = my_first_public_ipv4.ip_address\n\nunless ip.nil?\n\nchange = {\n  :action => 'UPSERT',\n  :resource_record_set => {\n    :name => \"home.andrewwippler.com\",\n    :type => \"A\",\n    :ttl => 600,\n    :resource_records => [{:value => ip}]\n}}\n\nroute53 = Aws::Route53::Client.new(\n    region: 'us-east-1'\n)\nroute53.change_resource_record_sets({\n  hosted_zone_id: '\/hostedzone\/XXXXXXXXXXXXXXX', # required\n  change_batch: { # required\n    changes: [change],\n  },\n})\n\nend\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"

This is the script I use to change the DNS record of my home IP when it changes. I have it running once a week and have not noticed a lapse in coverage. If your ISP has DHCP configured correctly, you will receive the same IP address when you are due for a renew. Otherwise […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[14],"tags":[17,51],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/posts\/571"}],"collection":[{"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/comments?post=571"}],"version-history":[{"count":1,"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/posts\/571\/revisions"}],"predecessor-version":[{"id":572,"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/posts\/571\/revisions\/572"}],"wp:attachment":[{"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/media?parent=571"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/categories?post=571"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/tags?post=571"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}