I wanted to get the IP of my DHCP server into a bash variable.
like : IP="192.168.1.254"
I know this IP can be found in /var/lib/dhcp/dhclient.leases or in /var/log/syslog but I don't know of to extract it and put it in variable during my script (bash)
EDIT: file dhclient.leases look's like
lease {
  interface "eth0";
  fixed-address 192.168.1.200;
  option subnet-mask 255.255.255.0;
  option routers 192.168.1.254;
  option dhcp-lease-time 7200;
  option dhcp-message-type 5;
  option domain-name-servers 192.168.1.254;
  option dhcp-server-identifier 192.168.1.254;
  option host-name "bertin-Latitude-E6430s";
  option domain-name "laboelec";
  renew 1 2015/02/16 10:54:34;
  rebind 1 2015/02/16 11:53:49;
  expire 1 2015/02/16 12:08:49;
}
I want the IP from line option dhcp-server-identifier 192.168.1.254;.
                        
To more compatibility I finally opted for a simple solution which is to send the IP server like a string on broadcast every seconds. For that I use socat (because netcat can't send message to braodcast) my DHCP server run this script in background: