Computers do not always seem to get an IP from dnsmasq (timing or state issues?)
by Fraks from LinuxQuestions.org on (#4WFEQ)
Hey everyone,
I am currently in the process of writing some scripts that should automate the deployment of a software solution across multiple PCs running slackware. The basic premise is that I have a network of computers of which one is running dnsmasq with a static IP address and all other computers have a specific interface set to DHCP.
The problem I am facing is that I cannot guarantee in which sequence all of the computers are started/available and as far as I have seen right now, this results in some computers in the network to not get an IP address while at the moment of checking, the dhcp server is available. Restarting the network (or rebooting) "fixes" the issue. I've also managed to use dhcpcd in some cases to get an IP address, but especially if I have used that command multiple times in a row without rebooting, I end up confused about its behaviour to the point where I don't know what I'm doing anymore and I just reboot the system.
The setup I have is extremely simple: enabled dnsmasq by making it executable, and configured its pool of addresses just as instructed in the howto on slackware.com. This is the script that enables and configures dnsmasq:
Code:# Make dnsmasq service executable
chmod 755 /etc/rc.d/rc.dnsmasq
# Configure IP range in dnsmasq configuration file
sed -i s:"^#dhcp-range=192.168.0.50,192.168.0.150,255.255.255.0,12h":"dhcp-range=42.42.42.50,42.42.42.150,255.255.255.0,12h": /etc/dnsmasq.conf
# Setting eth0 to have a static IP address (42.42.42.1) to enable clients to request their IP
sed -i s:"IPADDR\[0\]=.*":"IPADDR\[0\]=\"42.42.42.1\"": /etc/rc.d/rc.inet1.conf
sed -i s:"NETMASK\[0\]=.*":"NETMASK\[0\]=\"255.255.255.0\"": /etc/rc.d/rc.inet1.conf
sed -i s:"USE_DHCP\[0\]=.*":"USE_DHCP\[0\]=\"no\"": /etc/rc.d/rc.inet1.conf
sed -i s:"DHCP_HOSTNAME\[0\]=.*":"DHCP_HOSTNAME\[0\]=\"\"": /etc/rc.d/rc.inet1.conf
#echo ">> restarting network to activate changes"
/etc/rc.d/rc.inet1 restart > /dev/null
# (Re)starting dnsmasq
/etc/rc.d/rc.dnsmasq restart > /dev/nullConsidering my level of expertise I feel like I'm probably missing something pretty obvious, but I can't google something I don't know, so I was hoping you would be able to help me out on where to start to troubleshoot the issue:
Is the way I set up dnsmasq sufficient? In other words, based on my setup (and you can assume proper rc.inet1.conf to use dhcp on the computers that do not run dnsmasq) should slackware "automagically" get an IP address once dnsmasq has come available, regardless of timing between the two? If so, can someone explain to me / point me to documentation that explains how/when Slackware checks for IP addresses for its dhcp controlled interfaces or perhaps pointers on where to look first based on my issue description?
Thanks in advance!


I am currently in the process of writing some scripts that should automate the deployment of a software solution across multiple PCs running slackware. The basic premise is that I have a network of computers of which one is running dnsmasq with a static IP address and all other computers have a specific interface set to DHCP.
The problem I am facing is that I cannot guarantee in which sequence all of the computers are started/available and as far as I have seen right now, this results in some computers in the network to not get an IP address while at the moment of checking, the dhcp server is available. Restarting the network (or rebooting) "fixes" the issue. I've also managed to use dhcpcd in some cases to get an IP address, but especially if I have used that command multiple times in a row without rebooting, I end up confused about its behaviour to the point where I don't know what I'm doing anymore and I just reboot the system.
The setup I have is extremely simple: enabled dnsmasq by making it executable, and configured its pool of addresses just as instructed in the howto on slackware.com. This is the script that enables and configures dnsmasq:
Code:# Make dnsmasq service executable
chmod 755 /etc/rc.d/rc.dnsmasq
# Configure IP range in dnsmasq configuration file
sed -i s:"^#dhcp-range=192.168.0.50,192.168.0.150,255.255.255.0,12h":"dhcp-range=42.42.42.50,42.42.42.150,255.255.255.0,12h": /etc/dnsmasq.conf
# Setting eth0 to have a static IP address (42.42.42.1) to enable clients to request their IP
sed -i s:"IPADDR\[0\]=.*":"IPADDR\[0\]=\"42.42.42.1\"": /etc/rc.d/rc.inet1.conf
sed -i s:"NETMASK\[0\]=.*":"NETMASK\[0\]=\"255.255.255.0\"": /etc/rc.d/rc.inet1.conf
sed -i s:"USE_DHCP\[0\]=.*":"USE_DHCP\[0\]=\"no\"": /etc/rc.d/rc.inet1.conf
sed -i s:"DHCP_HOSTNAME\[0\]=.*":"DHCP_HOSTNAME\[0\]=\"\"": /etc/rc.d/rc.inet1.conf
#echo ">> restarting network to activate changes"
/etc/rc.d/rc.inet1 restart > /dev/null
# (Re)starting dnsmasq
/etc/rc.d/rc.dnsmasq restart > /dev/nullConsidering my level of expertise I feel like I'm probably missing something pretty obvious, but I can't google something I don't know, so I was hoping you would be able to help me out on where to start to troubleshoot the issue:
Is the way I set up dnsmasq sufficient? In other words, based on my setup (and you can assume proper rc.inet1.conf to use dhcp on the computers that do not run dnsmasq) should slackware "automagically" get an IP address once dnsmasq has come available, regardless of timing between the two? If so, can someone explain to me / point me to documentation that explains how/when Slackware checks for IP addresses for its dhcp controlled interfaces or perhaps pointers on where to look first based on my issue description?
Thanks in advance!