Debian 7.11 Wheezy가 설치된 Beaglebone Black이 있습니다.
Beaglebone에서 생성된 네트워크가 있고 Beaglebone IP 주소가 정적으로 설정되어 있습니다: 192.168.20.1
이것은 내 /etc/network/interfaces
파일입니다:
# 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
고정 IP 192.168.20.1을 사용하는 동안 사용자가 beaglebone에 연결할 수 있는 네트워크를 생성하기 위해 hostapd 및 isc-dhcpd-server 서비스도 실행합니다. 내 isc-dhcp-server는 192.168.20.3-254 주소의 IP는 내 dhcpd.conf
파일입니다.
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;
}
deamon.log 파일에서 dhclient가 어떤 이유로 비글본 IP 주소를 변경했을 수 있음을 발견했습니다.
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
편집하다:/etc/rc.local에서 dhclient가 수행하는 작업은 해당 스크립트에서 실행됩니다.
#!/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}')
내 질문은: 왜 무언가(dhcp)가 내 고정 IP 주소를 변경합니까? 변경되지 않는 고정 IP 주소를 설정할 때 이 문제를 해결하려면 어떻게 해야 합니까?