回答

收藏

嵌入式学习-ElfBoard ELF 1-设置静态和动态IP的方法

其他 其他 1249 人阅读 | 0 人回复 | 2023-10-31

本帖最后由 eefocus_3944881 于 2023-10-31 09:47 编辑

一、设置静态IP
1.配置文件路径/etc/network/interfaces
root@ELF1:~# vi /etc/network/interfaces

2.根据实际情况进行配置修改
例如修改eth0的IP为192.168.1.232:
# Wired or wireless interfaces
auto eth0
#iface eth0 inet dhcp
#iface eth1 inet dhcp
iface eth0 inet static
address 192.168.1.232
netmask 255.255.255.0
#       gateway 192.168.0.1
hwaddress ether aa:cc:dd:ee:ff:dd
效果如下:



3.设置DNS
root@ELF1:~# vi /etc/autorun.sh
添加如下内容:
echo "nameserver 8.8.8.8" >/etc/resolv.conf
效果如下:



4.重启服务
root@ELF1:~# /etc/init.d/networking restart


5.查看eth0的IP
root@ELF1:~# ifconfig eth0

IP设置成功。

二、设置动态IP
设置动态获取IP时,只需将/etc/network/interfaces文件改为如下形式,其它步骤与设置静态IP相同。
例如设置eth0为动态获取IP:
# Wired or wireless interfaces
auto eth0
iface eth0 inet dhcp
#iface eth1 inet dhcp
#iface eth0 inet static
#       address 192.168.1.232
#       netmask 255.255.255.0
#       gateway 192.168.0.1
#       hwaddress ether aa:cc:dd:ee:ff:dd
效果如下:



分享到:
回复

使用道具 举报

您需要登录后才可以回帖 注册/登录

本版积分规则

关闭

站长推荐上一条 /3 下一条