方法一:network设置
cd /etc/network
cp interfaces interfaces.bak
vi interfaces//配置IP地址、MASK等网络参数
/etc/init.d/networkingrestart//激活配置参数
或者/etc/rc.d/init.d/networkingrestart
Ifconfig//查看网络配置参数
Example:
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.51
netmask 255.255.255.0
gateway 192.168.1.1
方法二:uboot参数传递
在Linux-ARM开发中也可以将uboot中设置ipaddr传递给Linux内核,如:
setenv bootargs_mmc 'setenv bootargs ${bootargs} ip=${ipaddr} root=/dev/mmcblk0p1rootwait'
uboot将ipaddr传递给Linux内核,Linux启动后,PHY初始化后,将进行网络参数的配置:
PHY: 1:01 - Link is Up - 100/Full
P-Config: Guessing netmask 255.255.255.0
IP-Config: Complete:
device=eth0, addr=192.168.0.85, mask=255.255.255.0, gw=255.25