Conclusion
You are now able to use variables that represent the IP address of each of your system’s NICs. As you see with the Dependencies example in this article, you can quickly bind a service to an interface’s address, regardless of its IP address state as static or dynamic.
To expand upon real-world use cases of this example: when I want a containerized service to bind to VPN connections, I use ${TUN0_IPV4}
in place of the ${DEFAULT_IPV4}
parameter.
See also
External links
- Super User : How to get the machine IP address in a “systemd” service file
- CoreOS : Using environment variables in systemd units
- Server Fault : Do systemd unit files have to be reloaded when modified?
- Container Solutions : Running Docker Containers with Systemd
- systemd.unit — Unit configuration
- Stack Overflow : Bash: How to use sed to remove all characters except letters and numbers?
- Stack Overflow : sed: removing alphanumeric words from a file
- sed character classes and bracket expressions
Did this article save you time or money? I'd love a coffee!
Did you find this useful?
Please share with those who you believe would find this useful too!