野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 13062|回复: 1

[求助] 如何关闭DHCP

[复制链接]

发表于 2020-7-8 08:42:10 | 显示全部楼层 |阅读模式
最近需要将Pro板子设为静态IP,在/etc/network/interfaces文件中,把eth1配置修改如下。
auto eth1
iface eth1 inet static
    address 192.168.1.2
    netmask 255.255.255.252
    network 192.168.1.0
    gateway 192.168.1.1



但板子开机后仍旧是自动获取的IP地址,所以请问一下,如果我想让板子一开机就是自己设置的静态地址,该怎么设置呢?
回复

使用道具 举报

发表于 2020-7-8 14:09:35 | 显示全部楼层
本帖最后由 wjsxgd 于 2020-7-8 14:10 编辑

有两个方法:
1、在/opt/scripts/boot/psplash_quit.sh的末尾增加:(论坛里有,没有试过,应该是可以的)
    sudo ifconfig eth1 down
    sudo ifconfig eth1 192.168.x.x up
2、采用connman工具
在/var/lib/connman/下,建立connman的配置文件eth.config
  1. [global]
  2. Name = eth
  3. Description = eth network configuration

  4. [service_wired_ethernet]
  5. Type = ethernet
  6. IPv4 = 192.168.x.y/255.255.255.0/192.168.x.1  // 地址按自己的内容填写
复制代码
命令行下查看:
$ connmanctl
connmanctl> services                        // 查看网络设备列表,即查看下一句命令的eth_name
connmanctl> services <eth_name>    // 查看当前的网络配置
回复 支持 0 反对 1

使用道具 举报

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

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-5-13 08:11 , Processed in 0.033167 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表