IMX6ULL开发板设置静态IP

编辑 /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
  • 7
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值