DNS & DHCP使用说明

version 1.0


1. 打开DNS & DHCP说明

开启DHCP 自动获取ip,wifi和eth的开启方式一样,用wlan0 和eth0来区别。

ifconfig eth0 up

udhcpc -i eth0 -s /etc/init.d/udhcpc.script

2. 开启DNS


2.1. DNS依赖dns库文件

21x系列对应的libdns放置在customer/libdns中,如果缺失,可以在/release/dispcam/p3/common/glibc/9.1.0/wifi/libs/libdns 拷贝到对应位置,然后导出路径。

测试时可以将lib放在挂载目录,如挂载目录是/customer/lib,使用export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/customer/lib

20x系列对应的libdns为 libdns.tar.gz

注意:文件解压后,里面的lib是有链接的,拷贝的时候需要注意。


2.2. 添加dns域名服务器

/etc/resolv.conf 添加 nameserver 8.8.8.8, 如果测试的时候,/etc/resolv.conf 文件缺失或不可写入,可以在ssd21x上rootfs_dispcam.mk中默认添加dns server。

ssd20x系列修改rootfs.mk:

touch $(OUTPUTDIR)/rootfs/etc/resolv.conf
echo "nameserver 202.96.128.86" >> $(OUTPUTDIR)/rootfs/etc/resolv.conf
echo "nameserver 8.8.8.8" >> $(OUTPUTDIR)/rootfs/etc/resolv.conf;

测试:

确保板端的网络可以访问外部网络。

/ # ping -I eth0 www.baidu.com
PING www.baidu.com (14.215.177.38): 56 data bytes // dns已解析出ip,但受网络限制无法访问外部网络。

采用无线网络:

/config/wifi # udhcpc -i wlan0 -s /etc/init.d/udhcpc.script
udhcpc (v1.20.2) started
Setting IP address 0.0.0.0 on wlan0
Sending discover...
Sending select for 192.168.1.102...
Lease of 192.168.1.102 obtained, lease time 7200
Setting IP address 192.168.1.102 on wlan0
Deleting routers
route: SIOCDELRT: No such process
Adding router 192.168.1.1
Recreating /appconfigs/resolv.conf
Adding DNS server 10.0.0.254
Adding DNS server 192.168.1.1
/config/wifi # ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr 24:14:07:00:0A:C3 
inet addr:192.168.1.102 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:194 errors:0 dropped:0 overruns:0 frame:0
TX packets:55 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000 
RX bytes:53536 (52.2 KiB) TX bytes:5544 (5.4 KiB)
/config/wifi # ping -I wlan0 www.baidu.com
PING www.baidu.com (163.177.151.109): 56 data bytes
64 bytes from 163.177.151.109: seq=0 ttl=55 time=8.514 ms
64 bytes from 163.177.151.109: seq=1 ttl=55 time=11.114 ms
64 bytes from 163.177.151.109: seq=2 ttl=55 time=8.436 ms
64 bytes from 163.177.151.109: seq=3 ttl=55 time=8.445 ms
64 bytes from 163.177.151.109: seq=4 ttl=55 time=64.754 ms
64 bytes from 163.177.151.109: seq=5 ttl=55 time=8.125 ms