DNS & DHCP Reference
1. Enable DNS & DHCP¶
Enable DHCP to obtain ip automatically. The method to Enable wifi and eth is the same, using wlan0 and eth0 to distinguish them.
ifconfig eth0 up udhcpc -i eth0 -s /etc/init.d/udhcpc.script
2. Enable DNS¶
2.1. DNS Library¶
The libdns corresponding to the 21x series is in customer/libdns. If not, you can copy it from /release/dispcam/p3/common/glibc/9.1.0/wifi/libs/libdns
, and then export the path.
You can put lib in the mount directory during testing. For example, the mount directory is /customer/lib, export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/customer/lib.
The libdns corresponding to the 20x series is libdns.tar.gz.
Note: After the file is decompressed, the libs may have a hyperlink. Please pay attention when copying.
2.2. Add DNS Domain Name¶
Add nameserver 8.8.8.8
in /etc/resolv.conf
, if there is no /etc/resolv.conf
or cannot be written during testing, you can add dns server by default in rootfs_dispcam.mk
of ssd21x .
Modify rootfs.mk
in ssd20x series:
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;
Test:
Ensure that the board's network can access the external network.
/ # ping -I eth0 www.baidu.com PING www.baidu.com (14.215.177.38): 56 data bytes // dns has resolved the ip but cannot access the external network due to network restrictions.
Use wireless network:
/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