开发板的网络配置文件是"/etc/network/interfaces",可以修改此文件来配置网络设备。例如,默认文件内容如下:

auto lo
iface lo inet loopback
iface ppp0 inet ppp
#	provider gprs-dial
#	provider 3g-dial
	provider quectel-dial
#	provider ppp-dial
auto eth0
iface eth0 inet dhcp
	udhcpc_opts -t 1 -S
auto eth1
iface eth1 inet dhcp
	udhcpc_opts -t 1 -S

## Example bridge between eth0 and wlan0
#auto br0
#iface br0 inet static
#	bridge_ports eth0 wlan0
#	address 192.168.42.50
#	netmask 255.255.255.0


配置静态IP地址

上面的配置文件中eth0和eth1默认配置为DHCP模式,如果要配置eth0为静态地址,可以修改为如下:

注意配置项前要保留tab位置。


auto eth0
iface eth0 inet static
	address 192.168.1.100
	netmask 255.255.255.0
	gateway 192.168.1.1
	udhcpc_opts -t 1 -S


添加DNS地址

为eth0设备配置静态DNS地址,修改如下;

auto eth0
iface eth0 inet static
	address 192.168.1.100
	netmask 255.255.255.0
	gateway 192.168.1.1
	udhcpc_opts -t 1 -S
	dns-nameserver 8.8.8.8
	dns-nameserver 8.8.4.4


无线和有线桥接

当使用WiFi无线网络时,需要与eth0桥接

iface br0 inet dhcp
	bridge_ports eth0 wlan0
	pre-up ifconfig eth0 0.0.0.0 up
	pre-up ifconfig wlan0 0.0.0.0 up
	pre-up iwconfig wlan0 mode master
	pre-up brctl addbr br0
	pre-up brctl addif eth0
	pre-up brctl addif wlan0
	post-down ifconfig eth0 0.0.0.0 down
	post-down ifconfig wlan0 0.0.0.0 down
	post-down brctl delif br0 eth0
	post-down brctl delif br0 wlan0
	post-down brctl delbr br0