Ad
Python Dynamically Set DNS Record To IP (in Code Not By By Changing Hosts File)
Is there a way to point a DNS record to IP by code?
Example:
Lets say www.mydns.example
is pointing to IP 192.0.2.4
, which is the firewall address.
I want to run a python script from a serverless script (like Amazon's) to reach directly to my "real" server which is on IP 192.0.2.8
(bypassing the firewall)
When I run it from a server I can change the hosts file. but I want to do it by code so I won't have to edit the local hosts file (which not functional with server-less function).
something like this:
url = "www.mydns.example"
response=urllib2.urlopen(url,ip = '192.0.2.8')
Any idea?
Ad
Answer
Issue is solved by doing the following:
the URL should be with the IP address : http://192.0.2.8/index/php
and using urllib2.Request
, I configured the headers and added the domain under 'host'.
like this:
import urllib2
req = urllib2.Request('http://192.0.2.8/',headers={'host':'www.mydns.example'})
response=urllib2.urlopen(req)
Ad
source: stackoverflow.com
Related Questions
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Can't turn off Javascript using Selenium
- → WebDriver click() vs JavaScript click()
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module
Ad