busybox udhcpc配置使用及DHCP移植

2021-09-25 02:48:24 字數 2713 閱讀 1072

1.通過busybox udhcpc工具自動分配ip,並設定網絡卡ip.

問題描述:

輸入命令 udhcpc eth0,能夠自動獲取到ip位址,但是通過ifconfig查詢裝置的ip位址時,發現沒有設定網絡卡ip.具體情況如下所示。

[root@funchip ~]# udhcpc eth0

udhcpc: started, v1.30.1

udhcpc: sending discover

udhcpc: sending select for 172.16.0.181

udhcpc: lease of 172.16.0.181 obtained, lease time 604800

[root@funchip ~]# ifconfig

eth0 link encap:ethernet hwaddr 08:90:90:90:90:90

inet addr:172.16.0.86 bcast:172.16.255.255 mask:255.255.0.0

inet6 addr: 240e:fe:3006:6053:a90:90ff:fe90:9090/64 scope:global

up broadcast running multicast mtu:1500 metric:1

rx packets:4511 errors:0 dropped:2329 overruns:0 frame:0

tx packets:23 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

rx bytes:526580 (514.2 kib) tx bytes:4044 (3.9 kib)

lo link encap:local loopback

inet addr:127.0.0.1 mask:255.0.0.0

inet6 addr: ::1/128 scope:host

up loopback running mtu:65536 metric:1

rx packets:0 errors:0 dropped:0 overruns:0 frame:0

tx packets:0 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1

rx bytes:0 (0.0 b) tx bytes:0 (0.0 b)

解決辦法:

將busybox中examples/udhcp/******.script 拷貝至根檔案系統/usr/share/udhcpc,並重命名為default.script. [root@funchip ~]# cp /home/funchip/default.script /usr/share/udhcpc/

[root@funchip ~]# chmod 755 /usr/share/udhcpc/default.script

[root@funchip ~]# udhcpc eth0

udhcpc: started, v1.30.1

setting ip address 0.0.0.0 on eth0

udhcpc: sending discover

udhcpc: sending select for 172.16.0.181

udhcpc: lease of 172.16.0.181 obtained, lease time 604800

setting ip address 172.16.0.181 on eth0

deleting routers

route: siocdelrt: no such process

adding router 172.16.0.1

recreating /etc/resolv.conf

adding dns server 172.16.0.1

[root@funchip ~]# ifconfig

eth0 link encap:ethernet hwaddr 08:90:90:90:90:90

inet addr:172.16.0.181 bcast:172.16.0.255 mask:255.255.255.0

up broadcast running multicast mtu:1500 metric:1

rx packets:472 errors:0 dropped:300 overruns:0 frame:0

tx packets:16 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

rx bytes:51716 (50.5 kib) tx bytes:2366 (2.3 kib)

lo link encap:local loopback

inet addr:127.0.0.1 mask:255.0.0.0

inet6 addr: ::1/128 scope:host

up loopback running mtu:65536 metric:1

rx packets:0 errors:0 dropped:0 overruns:0 frame:0

tx packets:0 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1

rx bytes:0 (0.0 b) tx bytes:0 (0.0 b)

linux配置 網路配置

ip位址,子網掩碼,閘道器 設定ip位址,子網掩碼並啟用 ifconfig eth0 10.192.77.250 netmask 255.255.255.0 up 注 ip,掩碼,閘道器都設定到 etc sysconfig network scripts ifcfg eth0裡面了。設定多ip 可以...

elementui配置 element配置

vue elementui 配置 第一步 安裝elementui node命令 npm i element ui s 第二步 在man.js中配置 import elementui from element ui import element ui lib theme chalk index.css...

Thinkphp 配置 讀取配置

無論何種配置檔案,定義了配置檔案之後,都統一使用系統提供的c方法 可以借助config單詞來幫助記憶 來讀取已有的配置。用法 c 引數名稱 例如,讀取當前的url模式配置引數 model c url model 由於配置引數不區分大小寫,因此下面的寫法是等效的 model c url model 但...