IMX6ULL开发板设置静态IP

静态IP设置

  • 编辑 /etc/network/interface文件
  • 重启网卡
  • 设置开机自动启动

编辑 /etc/network/interface文件

vi /etc/network/interfaces
//可以看到如下内容# Wired or wireless interfaces
auto eth0
iface eth0 inet dhcp
iface eth1 inet dhcp

这段代码表示网卡设置动态获取IP,我们把eth0注释掉。

# Wired or wireless interfaces
auto eth0
#iface eth0 inet dhcp  //注释这一行
iface eth1 inet dhcp

然后在文件内添加如下指令

iface eth0 inet static  //设置eth0为静态的IP地址方式
address 192.168.1.111   //你的IP地址
netmask 255.255.255.0   //子网掩码
gateway 192.168.1.1     //网关
broadcast 192.168.1.255 //广播

整个文件如下:

# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
 
# The loopback interface
auto lo
iface lo inet loopback
 
# Wireless interfaces
iface wlan0 inet dhcp
        wireless_mode managed
        wireless_essid any
        wpa-driver wext
        wpa-conf /etc/wpa_supplicant.conf
 
iface atml0 inet dhcp
 
# Wired or wireless interfaces
auto eth0
#iface eth0 inet dhcp
iface eth1 inet dhcp
 
iface eth0 inet static
address 192.168.1.111
netmask 255.255.255.0
gateway 192.168.1.1
broadcast 192.168.1.255
 
# Ethernet/RNDIS gadget (g_ether)
# ... or on host side, usbnet and random hwaddr
iface usb0 inet static
        address 192.168.7.2
        netmask 255.255.255.0
        network 192.168.7.0
        gateway 192.168.7.1
 
# Bluetooth networking
iface bnep0 inet dhcp

重启网卡

/etc/init.d/networking restart

设置开机自动启动

在/etc/init.d/rc下修改
在文件的最后加入以下命令就可以了

ifconfig eth0 192.168.1.111 netmask 255.255.255.0
route add default gw 192.168.1.1

也可以通过以下命令追加到文件中:

echo "ifconfig eth0 192.168.xxx.xxx netmask 255.255.255.0" | tee -a /etc/init.d/rc
echo "route add default gw 192.168.xxx.1" | tee -a /etc/init.d/rc

你可能感兴趣的:(IMX6ULL学习--裸机篇)