Local DNS for Jenkins

Local DNS for Jenkins

In this tutorial we can learn about how to create a Local DNS for your local Jenkins server.

Before that we should know about what is DNS. DNS (Domain Name System or Service) is a hierarchical decentralized naming system/service that translates domain names into IP addresses on the Internet or a private network and a server that provides such a service is called a DNS server.

In Linux, the host file (/etc/hosts) is an operating system file that translate host names or domain names to IP addresses.

For example, you may want to test a website locally with a custom domain name before going live publicly by modifying the /etc/hosts file on your local system to point the domain name to the IP address of the local DNS server you configured.

Note

This method will only work if the Jenkins hosts have a static IP address. Therefore ensure that you have set static IP addresses for your Jenkins hosts or nodes.

The host file (/etc/hosts) is a simple text file that contains IP addresses to host names mappings. Each line consists of an IP address, followed by one or more host names.

> cat /etc/hosts
127.0.0.1       localhost
127.0.1.1       ashok.mariyala

For example your Jenkins server IP address is 192.168.1.5 and your want set host name as jenkins.local, then your host file looks like as follows

> cat /etc/hosts
127.0.0.1       localhost
127.0.1.1       ashok.mariyala
192.168.1.5     jenkins.local

The line 192.168.1.5 jenkins.local will map the IP address of 192.168.1.5 to the jenkins.local host name . We can now use the jenkins.local host name to communicate with the remote machine.

> ping jenkins.local
PING jenkins.local (192.168.1.5) 56(84) bytes of data.
64 bytes from jenkins.local (192.168.1.5): icmp_seq=1 ttl=64 time=0.042 ms
64 bytes from jenkins.local (192.168.1.5): icmp_seq=2 ttl=64 time=0.075 ms
64 bytes from jenkins.local (192.168.1.5): icmp_seq=3 ttl=64 time=0.070 ms
64 bytes from jenkins.local (192.168.1.5): icmp_seq=4 ttl=64 time=0.023 ms
^C
--- jenkins.local ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3069ms
rtt min/avg/max/mdev = 0.023/0.052/0.075/0.022 ms

Now you can access your Jenkins server using host name instead of IP address.

Local DNS for Jenkins

Local DNS for Jenkins

Scroll to top