Understand the embedded Linux startup network parameter configuration process, will be on the network this part of the chest,
after the network does not pass, there is a solution to the problem of the thinkingLu.
1, the network parameter configuration of the entrance:
/etc/init.d/rcs, such as the next two lines
# Configure the swap back lo address/sbin/ifconfig lo 127.0.0.1# to configure the Ethernet eth0 address/etc/init.d/ifconfig-eth0
2. Enter the Ifconfig-eth0 file:
#!/bin/shecho-n Try to bring eth0 interface up......>/dev/ttysac0# check the/etc/directory for the presence of a eth0-setting file, if present execute if statement if [-f/et C/eth0-setting]; then# read the eth0-setting file to get the value of the IP, Mask, Gateway, DNS, Mac and other variables source/etc/eth0-setting# determine if there is a setting in the file/etc/mtab from NFS boot if Grep-q "/NFS"/ETC/MTAB; Thenecho-n NFS Root ... >/dev/ttysac0else# not from NFS driver, configure IP, mask and other network parameters ifconfig eth0 down ifconfig eth0 hw ether $MAC C1/>ifconfig eth0 $IP netmask $Mask up route add default GW $Gateway fi# Get the value of DNS and write to file/etc/resolv.conf echo Namese RVer $DNS >/etc/resolv.confelse#/etc/directory does not exist eth0-setting file, then manually configure the network parameters if Grep-q "/NFS"/ETC/MTAB; Thenecho-n NFS root ... >/dev/ttysac0else/sbin/ifconfig eth0 192.168.1.230 netmask 255.255.255.0 Upfifiecho done > /dev/ttysac0
With the shell code above, you should at least be informed about:
1. How to set whether to boot from NFS or start normally
2, in which file to change the IP and other network parameters
3, the origin and configuration of DNS. You will know where to modify the parameters when pinging the IP but pinging the domain name in the future
The above mentioned/etc/eth0-setting file is set up with some variables:
ip=192.168.1.230
mask=255.255.255.0
gateway=192.168.1.1
dns=192.168.1.1
Mac=08:90:90:90:90:90
3. Get IP automatically:
Above, for the configuration of fixed IP and other network parameters, then how to achieve automatic allocation of IP, and so on?
#!/bin/shecho-n Try to bring eth0 interface up......>/dev/ttysac0if grep-q "^/dev/root/nfs"/ETC/MTAB; Thenecho-n NFS root ... >/dev/ttysac0elseudhcpc-i Eth0fiecho done >/DEV/TTYSAC0
The startup information is as follows:
Embedded Linux Startup network parameter configuration