TI中文支持网
TI专业的中文技术问题搜集分享网站

AM335x linux kernel 4.19.94 如何设置静态ip地址

你好,

AM335x linux kernel 4.19.94 如何设置静态ip地址,sdk开发包为ti-processor-sdk-linux-am335x-evm-06.03.00.106

Shine:

可以通过ifconfig 命令设置静态IP地址。ifconfig ethx <ip> netmask <mask> up

,

Leon Sun1:

你好,我的意思是每次启动都是同一个ip地址,不需要再次配置ip地址

,

Shine:

在etc/network/interfaces里设置,请参考下面的帖子。
e2e.ti.com/…/298242

,

Leon Sun1:

你好,修改/etc/network/interfaces文件并不能实现静态ip的功能,而设置uboot的参数会出现无法保存的问题,提示:Saving Environment to FAT… Failed (1),还有没有别的办法?

,

Shine:

看到您用的是最新的SDK,新的SDK是使用Systemd来进行启动管理,还需要对systemd中相应的服务进行修改,请参考下面的帖子修改脚本,加上ExecStart=/sbin/ifup ethx 试试。
e2e.ti.com/…/2035119

,

Leon Sun1:

你好,我按照您推荐的方法试过,但是网卡无法自启动,每次系统启动后必须手动敲命令ifup eth0才能启动网卡,网卡启动后的IP地址与interfaces文件配置的一致,而且文章中说的是“ExecStart= ExecStart=/sbin/ifup ethx”,请问无法自启动网卡的问题是什么原因?

,

Shine:

那就试试直接在/etc/systemd/network目录新建一个网卡配置文件,如/etc/systemd/network/01-eth-static.network.

—- File contents —–
[Match]
Name=eth0

[Network]
Address=xxxx
Broadcast=xxxx
Netmask=xxxx
Gateway =xxxx

—– EOF ———–
wiki.archlinux.org/…/Systemd-networkd

,

Leon Sun1:

你好,问题已经解决,非常感谢

总结一下,首先需要关闭DHCP功能,修改下面这个文件

 Stop the dhcp  from /lib/systemd/network/80-container-host0.network, i.e.:

     #  This file is part of systemd.                                                                                                                        

     #                                                                                                                                                        

     #  systemd is free software; you can redistribute it and/or modify it                                                                                    

     #  under the terms of the GNU Lesser General Public License as published by                                                                              

     #  the Free Software Foundation; either version 2.1 of the License, or                                                                                  

     #  (at your option) any later version.                                                                                                                  

     [Match]                                                                                                                                                  

     Virtualization=container                                                                                                                                

      Name=host0                                                                                                                                              

     [Network]                                                                                                                                                

     #DHCP=yes                               /*THE DEFAULT FILE has this set to YES, so comment this line*/                                                                                                                           

      LinkLocalAddressing=yes                                                                                                                                  

     #[DHCP]                                       /*THE DEFAULT FILE has this  setting, so COMMENT this line*/                                                                                                       #UseTimezone=yes                  /*THE DEFAULT FILE has this set to YES, so comment this line*/     

———————————————–EOF—————————————————————

然后在“/lib/systemd/network/”目录下添加配置文件,文件名为01-eth-static.network,内容如下:

[Match]Name=eth0[Network]Address=192.168.10.20/24Broadcast=192.168.10.255Netmask=255.255.255.0Gateway=192.168.10.1

————————————-EOF——————————————–

如有其他错误请指出,谢谢!

,

Shine:

非常感谢分享解决方法!

,

user6394011:

按照这种方法设置成了静态IP,但是拔掉网线还是会等待超时,这个问题怎么解决

,

Leon Sun1:

是的,在我这里也是这样,拔掉网线ip地址就变了,不过插上网线还是可以恢复之前设置的IP地址的

,

user4229940:

写个脚本,系统启动后自动设置下IP地址应该就可以了
可以通过ifconfig 命令设置静态IP地址。
ifconfig ethx <ip> netmask <mask> up

赞(0)
未经允许不得转载:TI中文支持网 » AM335x linux kernel 4.19.94 如何设置静态ip地址
分享到: 更多 (0)