1

I have Beaglebone Black with installation of Debian 7.11 Wheezy

I have network which is created from Beaglebone and the Beaglebone IP address is set to be static: 192.168.20.1

This is my /etc/network/interfaces file:

# The wireless network interface
#allow-hotplug wlan0
auto wlan0
#iface wlan0 inet dhcp
#    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface wlan0 inet static
    address 192.168.20.1
    netmask 255.255.255.0

When I use static IP 192.168.20.1 I also run hostapd and isc-dhcpd-server services, for can create network with which users can connect to beaglebone: My isc-dhcp-server is set to put IP address from 192.168.20.3-254 This is my dhcpd.conf file:

subnet 192.168.20.0 netmask 255.255.255.0 {
  range 192.168.20.3 192.168.20.254;
  option broadcast-address 192.168.20.255;
  default-lease-time 600;
  max-lease-time 7200;
}

I found on deamon.log file for some reason dhclient is probably change the beaglebone IP address

Mar 20 11:36:01 smartgrow dhclient: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 4
Mar 20 11:36:01 smartgrow rc.local[717]: sudo: unable to resolve host smartgrow
Mar 20 11:36:02 smartgrow dhclient: DHCPREQUEST on wlan0 to 255.255.255.255 port 67
Mar 20 11:36:02 smartgrow dhclient: DHCPOFFER from 192.168.20.1
Mar 20 11:36:02 smartgrow dhclient: DHCPACK from 192.168.20.1
Mar 20 11:36:02 smartgrow samba[2929]: Reloading /etc/samba/smb.conf: smbd only.
Mar 20 11:36:02 smartgrow dhclient: bound to 192.168.20.5 -- renewal in 281 seconds.
Mar 20 11:36:04 smartgrow ntpd[864]: Listen normally on 7 wlan0 192.168.20.5 UDP 123

EDIT: The thing which dhclient make something on /etc/rc.local is run on that script

#!/bin/sh

if [ -f /etc/wpa_supplicant/wpa_supplicant.conf ] # If file exist
then
    version=$(sudo /bin/cat /home/network/option.gse)
    if [ "$version" = "static" ]
    then
        sudo cp /home/scripts/user /etc/network/interfaces
    else
        sudo cp /home/scripts/dynamic /etc/network/interfaces
    fi
else
    sudo cp /home/scripts/static /etc/network/interfaces
fi

/etc/init.d/isc-dhcp-server stop
/etc/init.d/hostapd stop

ip addr flush dev wlan0
ip link set wlan0 up

/etc/init.d/networking restart

ip=$(/sbin/ifconfig wlan0 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}') # Get IP address for wlan0
case "$ip" in
    192.168.20.* | "")
        {
            sudo cp /home/scripts/static /etc/network/interfaces
            /etc/init.d/hostapd stop
            ifconfig wlan0 192.168.20.1/24
            ip addr flush dev wlan0
            ip link set wlan0 up
            /etc/init.d/networking restart
            sleep 10
            wifis=$(iwlist wlan0 scann | grep ESSID | cut -d: -f2)
            echo $wifis > /var/www/smart-grow-controller/storage/cache/wifi-list
            /etc/init.d/isc-dhcp-server restart
            /etc/init.d/hostapd restart
        };;
    *)
        {
            ips=$(sudo arp-scan --interface=wlan0 --localnet| awk '{print $1}'|tail -n +3|head -n -2)
            first=$(echo $ips | cut -d' ' -f1)
            if ping -c 1 -W 1 "$first"
            then
                /etc/init.d/isc-dhcp-server stop
                /etc/init.d/hostapd stop
            else
                sudo cp /home/scripts/static /etc/network/interfaces
                            ifconfig wlan0 192.168.20.1/24
                            ip addr flush dev wlan0
                            ip link set wlan0 up
                            /etc/init.d/networking restart
                            sleep 10
                            wifis=$(iwlist wlan0 scann | grep ESSID | cut -d: -f2)
                            echo $wifis > /wifi-list-path/wifi-list
                /etc/init.d/networking restart
                            /etc/init.d/isc-dhcp-server restart
                            /etc/init.d/hostapd restart
            fi
        };;
esac

/etc/init.d/samba restart

ip=$(/sbin/ifconfig wlan0 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}')
mask=$(/sbin/ifconfig wlan0 | awk '/Mask:/{ print $4; }')
gateway=$(ip route show default | awk '/default/ {print $3}')

My questions is: Why is something (dhcp) change my static IP address? And how to resolve that, when I put static IP address to not be changed?

  • As a first step, find out why dhclient is started at all. Check /etc/rc.local or the position of its startup logs for hints. – Ferenc Wágner Mar 22 at 8:40
  • @FerencWágner Actually the dhclient is doing something in /etc/rc.local, but the change of IP address from static to dynamic is happen few minutes/hours later, after /etc/rc.local was executed. I edit my question what I doing on /etc/rc.local – evelikov92 Mar 25 at 11:22
  • Your /etc/rc.local overwrites your /etc/network/interfaces, so it's hard to say anything, but why do you think it starts dhclient? – Ferenc Wágner Mar 25 at 17:14
  • @FerencWágner because of the deamon.log file. I think is from there. I'm not sure btw. The /etc/network/interfaces is that what I show on my question – evelikov92 Apr 1 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.