This is related to a stackoverflow post I posted.Basically I have a Python script that I'm running on an embedded system (Buildroot-based). The python script runs on startup, but I cannot guarantee that the internet connection will be up by then (based on pppd), because the unit might not be in an area with mobile phone signal.What I've found is that if the python code starts before an internet connection has been established on the machine, even after the connection is established, the python code is still unable to resolve names. I get a [Errno -3] Temporary failure in name resolution error when the socket tries to connect. The only way I can get it to work is to establish the internet connection at least once before I start the python code.What changes are being made to the system after the internet connection is established at least once that the Python code could be looking for? Is there something I can set up on boot up so that this does not happen?
Program cannot resolve host name if it's started before first successful internet connection
python;internet;pppd
Most programs read the system DNS configuration (in /etc/resolv.conf) only once when they start up or when they make their first network access. They don't re-read the configuration if it changes.It appears that on your system, the DNS configuration changes when the network goes up (probably changes from unconfigured to having DNS servers configured). This is very common, and unavoidable if the system isn't always connected to the same network.A way to ensure that programs won't be affected is to run a local DNS caching server. This way, the DNS configuration for applications can be static (always nameserver 127.0.0.1 in /etc/resolv.conf), and only the DNS caching server needs to be told about the servers provided by the network connection. Dnsmasq is a common choice, especially on embedded systems (if you have a Linux router, it probably runs dnsmasq). If you're building your own image with Buildroot, include the dnsmasq package. If you have a pre-built image without dnsmasq, installing dnsmasq via Builtroot may still be the best bet but I'm not familiar with Buildroot so I can't explain how to do it.