Jump to content

Powershell C# script to handle rotating IP and my Godaddy domain


chef

Recommended Posts

chef

Wow, so powershell is an extremely powerful utility in windows that I just started to learn.

 

The reason was because my ISP is rotating my IP address which causes issues for my Godaddy domain and Emby.

 

Here is what I did.

 

Using this powershell script on Github and the Godaddy API:

 

https://github.com/markafox/GoDaddy_Powershell_DDNS

 

I run this script to check for any change in my IP address then post the new one to Godaddy servers.

 

Sooooo sweeet!

 

You need  Powershell version 3.0 or higher to use it!

 

I then created a little console app which checks the time and then runs the Powershell script.

 

Here si the C# code:

        public static void UpdateDomain()
        {
            var startInfo = new ProcessStartInfo
            {
                FileName = @"powershell.exe",
                Arguments =
                    "-ExecutionPolicy Unrestricted -NoProfile -Command \"" + Application.StartupPath +
                    "\\godaddy_ddns.ps1\"",
                RedirectStandardOutput = true,
                RedirectStandardError = true,
                UseShellExecute = false,
                CreateNoWindow = true
            };
            var process = new Process {StartInfo = startInfo};
            process.Start();

            
        }
          if (DateTime.Now.Minute == 30 || DateTime.Now.Minute == 00)
            {
                try
                {
                    UpdateDomain();
                }
                catch
                {
                }
            }

You'll have to put the script in a folder with the exe. also you'll have to do the whole "Console.Readline" stuff to keep the EXE running.

 

It works like a charm! you need to get a Secret Key and API Key from a developer account at godaddy, if you're going to use the script... super easy.

 

definitely worth the post here I think.

 

I no longer have to monitor the DNS settings, and Emby is always available at my domain.

 

Really kick-ass.

Edited by chef
Link to comment
Share on other sites

Swynol

nice work. does your router support ddns? 

 

i use a ddns from namecheap. my router sends my new IP to name cheap so that all my domain stuff works.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...