- No you can't prevent Comcast from changing your IP address unless you've purchased a Static IP address from them.
- When you change your router/MAC they will likely issue a new IP address.
- In my experience Comcast changes IP addresses every 1 to 3 years
One way to keep your "dynamic IP" in sync with your DNS is by using a service like Dyn or NoIP which provide their proprietary Domain names/Domain names to purchase.
However if you have your own custom domain name that you'd like to use, you can use the DNS services from NameSilo (http://www.namesilo.com) as your DNS provider and the powershell windows script below along with a scheduled task to replicate the Dyn/NoIP service.
Assuming you're running windows, here's a simple script that you can "schedule" using Task Scheduler to run on StartUp/Logon and then rerun every 6 hours (that way the maximum downtime due to an IP address change is 6 hours).
Save the script below in a file called NameSiloDDNS.ps1
# NameSilo API Dynamic DNS
#Variables
param([string]$APIkey=$(throw "APIKey is required"), [string]$domain=$(throw "Domain is required"), [string]$record)
###Code - Do not edit below this line
# Gather data about the DNS entries in the domain
$listdomains = Invoke-RestMethod -Uri "https://www.namesilo.com/apibatch/dnsListRecords?version=1&type=xml&key=$APIkey&domain=$domain"
$CurrentIP = $listdomains.namesilo.request.ip
if ($record) {
$RecordIP = ($listdomains.namesilo.reply.resource_record|where {$_.host -eq "$record.$domain" -and $_.type -eq "A"}).value
$RecordID = ($listdomains.namesilo.reply.resource_record|where {$_.host -eq "$record.$domain" -and $_.type -eq "A"}).record_id
} else {
$RecordIP = ($listdomains.namesilo.reply.resource_record|where {$_.host -eq "$domain" -and $_.type -eq "A"}).value
$RecordID = ($listdomains.namesilo.reply.resource_record|where {$_.host -eq "$domain" -and $_.type -eq "A"}).record_id
}
$listdomains.namesilo.reply
#Write-Host "CurrentIP $CurrentIP, RecordIP $RecordIP, RecordID $RecordID"
# If the current IP address is not the same as the one in the record it updates it
Write-Host "https://www.namesilo.com/apibatch/dnsUpdateRecord?version=1&type=xml&key=$APIkey&domain=$domain&rrid=$RecordID&rrhost=$record&rrvalue=$CurrentIP&rrttl=3600"
if ($CurrentIP -ne $RecordIP){
if ($record) {
Write-Host "Updating $record.$domain with IP $CurrentIP"
} else {
Write-Host "Updating $domain with IP $CurrentIP"
}
$update = Invoke-RestMethod -Uri "https://www.namesilo.com/apibatch/dnsUpdateRecord?version=1&type=xml&key=$APIkey&domain=$domain&rrid=$RecordID&rrhost=$record&rrvalue=$CurrentIP&rrttl=3600"
$update.namesilo.reply
} else {
Write-Host "No need to update $record.$domain, IP $CurrentIP upto date"
}
Next save the script below in a file called UpdateDDNSIPv4.bat
.
PowerShell -ExecutionPolicy Bypass .\NameSiloDDNS.ps1 <NameSilo_API_Key> somedomain.com
PowerShell -ExecutionPolicy Bypass .\NameSiloDDNS.ps1 <NameSilo_API_Key> somedomain.com subdomain
Keep both the files in the same directory. UpdateDDNSIPv4.bat
is the batchfile which should be called by Task Scheduler in your recurring task.
Couple of things to note, you will need to Login to your NameSilo account and under API Manager -> Generate an API Key which you need to enter in the batch script above to replace <NameSilo_API_Key>
.
This script can be used to update your A
DNS records for the main domain (e.g. somedomain.com
) and also for your subdomains (e.g. subdomain
). You can create one line for each domain/subdomain you want to update.
This script will automatically find your "Public IP Address" and then update your NameSilo DNS A records.
You can find a BASH equivalent of this script here: https://github.com/pztop/namesilo_ddns
A Python equivalent of a script can also be found at:
https://github.com/rbenji/DynamicDNS-for-NameSilo
This script was taken and customized from http://www.forkrobotics.com/2014/10/dynamic-dns-with-namesilo-and-powershell/
Hope this helps
I have comcast as my isp. my external ip has not changed in over 10 years. No, it's not a paid static IP. – Blekthor – 2017-01-08T20:12:19.393
Mine hasn't changed since writing this post 4 years ago. – user1032531 – 2017-06-10T20:37:52.363
3The honest answer to this question is pretty much "As often as Comcast wants it to change." but at least once a week. Your purchase of the new router likely has nothing to do with your ip changing to be honest. There are limited number of IPv4 addresses Comcaster is the owner an will assign it to any number of their customers. You can purchase a static ip address if you want of course. – Ramhound – 2013-10-21T16:41:15.437
@Ramhound. Thanks. I've had the same dynamic IP for over a year. I've read that Comcast and others will keep them if the mac address is the same, so the router change might have had an effect. – user1032531 – 2013-10-21T16:48:21.837
@user1032531, you're right that MAC address changes will probably get you a new IP, but you can expect occasional changes even if the MAC doesn't change. I have a similar setup, but my DNS provider (namecheap) includes the ability to dynamically update the IP. – heavyd – 2013-10-21T17:11:31.023