Code Monkey home page Code Monkey logo

pynamic_dns's Introduction

pynamic_dns

Updating DNS records when ISP changes my dedicated IP

pynamic_dns's People

Contributors

kentaasvang avatar

Watchers

 avatar

pynamic_dns's Issues

Error when trying to parse response from cloudflare

Aug 23 16:59:43 asvang-it python[825]: Traceback (most recent call last):
Aug 23 16:59:43 asvang-it python[825]:   File "/home/admin/pynamic_dns/main.py", line 79, in <module>
Aug 23 16:59:43 asvang-it python[825]:     main()
Aug 23 16:59:43 asvang-it python[825]:   File "/home/admin/pynamic_dns/main.py", line 32, in main
Aug 23 16:59:43 asvang-it python[825]:     cloudflare_client.update_ip_address(current_public_ip.ip_addr)
Aug 23 16:59:43 asvang-it python[825]:   File "/home/admin/pynamic_dns/cf_client.py", line 70, in update_ip_address
Aug 23 16:59:43 asvang-it python[825]:     response = requests.put(
Aug 23 16:59:43 asvang-it python[825]:   File "/home/admin/pynamic_dns/venv/lib/python3.9/site-packages/requests/api.py", line 130, in put
Aug 23 16:59:43 asvang-it python[825]:     return request("put", url, data=data, **kwargs)
Aug 23 16:59:43 asvang-it python[825]:   File "/home/admin/pynamic_dns/venv/lib/python3.9/site-packages/requests/api.py", line 59, in request
Aug 23 16:59:43 asvang-it python[825]:     return session.request(method=method, url=url, **kwargs)
Aug 23 16:59:43 asvang-it python[825]:   File "/home/admin/pynamic_dns/venv/lib/python3.9/site-packages/requests/sessions.py", line 589, in request
Aug 23 16:59:43 asvang-it python[825]:     resp = self.send(prep, **send_kwargs)
Aug 23 16:59:43 asvang-it python[825]:   File "/home/admin/pynamic_dns/venv/lib/python3.9/site-packages/requests/sessions.py", line 703, in send
Aug 23 16:59:43 asvang-it python[825]:     r = adapter.send(request, **kwargs)
Aug 23 16:59:43 asvang-it python[825]:   File "/home/admin/pynamic_dns/venv/lib/python3.9/site-packages/requests/adapters.py", line 519, in send
Aug 23 16:59:43 asvang-it python[825]:     raise ConnectionError(e, request=request)
Aug 23 16:59:43 asvang-it python[825]: requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.cloudflare.com', port=443): Max retries exceeded with url: /client/v4/zones/018dde8b571634e98935b75069c35547/dns_records/3a0bec6d94588d4d46e13e9b36844aef (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7fa647d5b0>: Failed to resolve 'api.cloudflare.com' ([Errno -3] Temporary failure in name resolution)"))
Aug 23 16:59:43 asvang-it systemd[1]: pynamic_dns.service: Main process exited, code=exited, status=1/FAILURE
Aug 23 16:59:43 asvang-it systemd[1]: pynamic_dns.service: Failed with result 'exit-code'.
Aug 23 16:59:44 asvang-it systemd[1]: pynamic_dns.service: Scheduled restart job, restart counter is at 1.
Aug 23 16:59:44 asvang-it systemd[1]: Stopped pynamic_dns.
Aug 23 16:59:44 asvang-it systemd[1]: Started pynamic_dns.
Aug 23 16:59:44 asvang-it python[833]:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Aug 23 16:59:44 asvang-it python[833]:                                  Dload  Upload   Total   Spent    Left  Speed
Aug 23 16:59:44 asvang-it python[833]: [124B blob data]
Aug 23 16:59:44 asvang-it python[831]: DEBUG:logger:
Aug 23 16:59:44 asvang-it python[831]: ERROR:logger:Error in retrieving public ip, message: 1 validation error for IfConfigResult
Aug 23 16:59:44 asvang-it python[831]:   Invalid JSON: EOF while parsing a value at line 1 column 0 [type=json_invalid, input_value='', input_type=str]
Aug 23 16:59:44 asvang-it python[831]:     For further information visit https://errors.pydantic.dev/2.7/v/json_invalid
Aug 23 16:59:44 asvang-it python[831]: DEBUG:logger:public ip is 'ip_addr='''
Aug 23 16:59:44 asvang-it python[831]: DEBUG:logger:stored ip is ''``

Set up umbrella domain

As of now, we specify all domains that should change in cloudflare. This can be complicated and won't work across different cloudflare accounts without increasing complexity.

A better way would be to have a domain, say "myserver.example.com", be the only domain I update with the new IP. All domains that should point to my server should have CNAME records to "myserver.example.com".

Power Outage Mechanism

Everything in this app lives in memory, so in case of power outage the service looses all its data. If ISP distributes a new IP to my router at this point, which it often does, then service won't know it has changed.

Simple solution is to store current IP as a file. This way we can save the state of the service and know if the IP has changed during power outage.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.