udhcpc遇到问题
2015-09-18 11:45
253 查看
udhcpc -i eth0
手动运行该命令时,能接收来自DHCP服务器分配的IP地址,但是接收到的IP地址却没有设置到网口eth0,同时dns配置也没有修改。输入ifconfig命令,IP地址为空。
查阅相关资料,发现设备端没有移植dhcpc对应的脚本文件。
解决:在/user/share下建立udhcpc目录,并创建四个文件
-rwxrwxrwx 1 root root 2 Sep 18 10:43 config
-rwxrwxrwx 1 root root 0 Sep 18 10:45 .count (空)
-rwxrwxrwx 1 root root 4559 Sep 18 11:27 default.script
-rwxrwxrwx 1 root root 2 Sep 18 10:44 done
手动运行该命令时,能接收来自DHCP服务器分配的IP地址,但是接收到的IP地址却没有设置到网口eth0,同时dns配置也没有修改。输入ifconfig命令,IP地址为空。
查阅相关资料,发现设备端没有移植dhcpc对应的脚本文件。
解决:在/user/share下建立udhcpc目录,并创建四个文件
-rwxrwxrwx 1 root root 2 Sep 18 10:43 config
-rwxrwxrwx 1 root root 0 Sep 18 10:45 .count (空)
-rwxrwxrwx 1 root root 4559 Sep 18 11:27 default.script
-rwxrwxrwx 1 root root 2 Sep 18 10:44 done
root@ubuntu:/home/nfs/ov9732_hi3518e/udhcpc# cat default.script #!/bin/sh # udhcpc script edited by Tim Riker <Tim@Rikers.org> RESOLV_CONF="/etc/resolv.conf" DHCP_CONFIG="/usr/share/udhcpc" DHCP_READ_FILE=$DHCP_CONFIG/config DHCP_WRITE_FILE=$DHCP_CONFIG/done config="/usr/share/udhcpc/.count" #echo "got input $1" #echo "interface is $interface" [ -n "$1" ] || { echo "Error: should be called from udhcpc"; exit 1; } NETMASK="" [ -n "$subnet" ] && NETMASK="netmask $subnet" BROADCAST="broadcast +" [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" case "$1" in deconfig) echo 0>$config cat $config echo "Setting IP address 0.0.0.0 on $interface" ifconfig $interface 0.0.0.0 ;; renew|bound) read type <$DHCP_READ_FILE echo "Setting IP address $ip on $interface" ifconfig $interface $ip $NETMASK $BROADCAST #if [ "$type" == "0" ] && [ "$interface" == "eth0" ]; then # UPDATE_ROOT=yes #elif [ "$type" == "1" ] && [ "$interface" == "ra0" ]; then # UPDATE_ROOT=yes #else UPDATE_ROOT=yes #fi if [ "$UPDATE_ROOT" == "yes" ]; then echo " need update route and dns with $interface" if [ -n "$router" ] ; then echo "Deleting routers" #while route del default gw 0.0.0.0 dev $interface ; do # : #done #echo "sleep 5 seconds to wait link up: try once" #sleep 5 #metric=0 #for i in $router ; do # echo "Adding router $i" # route add default gw $i dev $interface metric $((metric++)) #done #echo "sleep 5 seconds to wait link up: try again" #sleep 5 metric=0 for i in $router ; do echo "Adding router $i" route add default gw $i dev $interface metric $((metric++)) if [ "$interface" == "eth0" ]; then echo "gw $i" > "/tmp/gw0" else echo "gw $i" > "/tmp/gw1" fi done fi echo "Recreating $RESOLV_CONF" echo -n > $RESOLV_CONF-$$ if [ "$interface" == "eth0" ]; then echo -n > "/tmp/dns0" [ -n "$domain" ] && echo "search $domain" >> "/tmp/dns0" else echo -n > "/tmp/dns1" [ -n "$domain" ] && echo "search $domain" >> "/tmp/dns1" fi #[ -n "$domain" ] && echo "search $domain" >> $RESOLV_CONF-$$ rm /etc/resolv.conf for i in $dns ; do echo " Adding DNS server $i" echo "nameserver $i" >> $RESOLV_CONF-$$ if [ "$interface" == "eth0" ]; then echo "dns $i" >> "/tmp/dns0" else echo "nameserver $1" >> "/etc/resolv.conf" echo "dns $i" >> "/tmp/dns1" fi done echo "Set DNS config" mv $RESOLV_CONF-$$ $RESOLV_CONF echo "DHCP over,send msg to netmgmt" # /home/sendMq 0x80 0x1 0x1ffe 0x1 & else echo "needn't update route to $router" fi echo 1 > $DHCP_WRITE_FILE ;; esac exit 0
root@ubuntu:/home/nfs/ov9732_hi3518e/udhcpc# cat config 1
root@ubuntu:/home/nfs/ov9732_hi3518e/udhcpc# cat done 1
相关文章推荐
- Android中内存泄露监测
- C++标准库:bitset 用法整理 (来自网易 happyboy200032的博客)
- DevExpress源码编译总结 z
- 在Json解析过程中,我为什么用object1.optInt ,和 object1.optString
- CPS冥想 - 2 手撸控制流
- node
- 什么是log4j ?
- 收藏链接
- 适配 ios 9
- IOS9之BitCode
- Android代码截屏
- MongoDB学习记录
- oracle utf8字符集转gbk(转)
- Eclipse、Idea快捷键对比
- 关于xcode7的一些问题
- 数组的形参与实参,通过引用传递数组
- 静态、共享的规则MFC DLL,MFC扩展DLL详解
- poi操作Excel
- 解决Unable to load R3 module ...VBoxDD.dll (VBoxDD):GetLastError=1790
- Java构造方法的含义和使用