原创 【米尔-瑞米派Remi Pi-兼容树莓派扩展模块--试用评测】永久IP地址固定

2024-4-17 17:04 1469 5 5 分类: MCU/ 嵌入式 文集: 嵌入式开发
一、根据开发手册网口一节参照如下:自动永久配置静态 IP 地址通过 ifconfig 命令和 ip 命令配置的 IP 地址断电之后就会丢失,如果需要使 IP 地址永久生效,就需要修改网络管理工具相应的配置文件。 使用 systemd-networkd 管理工具配置动态获取 IP 地址

root@myir-remi-1g:~# cd /

root@myir-remi-1g:/# ls

bin   dev         etc   lib    lost+found  mnt  proc  sbin  tmp  var

boot  eeprom.txt  home  lib64  media       opt  run   sys   usr

root@myir-remi-1g:/# ifconfig

can0: flags=193  mtu 72  metric 1

unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 10  (UNSPEC)

RX packets 0  bytes 0 (0.0 B)

RX errors 0  dropped 0  overruns 0  frame 0

TX packets 0  bytes 0 (0.0 B)

TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

docker0: flags=4099  mtu 1500  metric 1

inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255

ether 02:42:30:1b:89:9b  txqueuelen 0  (Ethernet)

RX packets 0  bytes 0 (0.0 B)

RX errors 0  dropped 0  overruns 0  frame 0

TX packets 0  bytes 0 (0.0 B)

TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

eth0: flags=4163  mtu 1500  metric 1

inet 172.18.122.98  netmask 255.255.255.0  broadcast 172.18.122.255

inet6 fe80::8057:13ff:febf:e59b  prefixlen 64  scopeid 0x20

ether 82:57:13:bf:e5:9b  txqueuelen 1000  (Ethernet)

RX packets 3123  bytes 512365 (500.3 KiB)

RX errors 0  dropped 0  overruns 0  frame 0

TX packets 5949  bytes 1736720 (1.6 MiB)

TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

device interrupt 184

 

eth1: flags=4099  mtu 1500  metric 1

inet 192.168.40.234  netmask 255.255.255.0  broadcast 192.168.40.255

ether 9e:63:5b:42:7c:b3  txqueuelen 1000  (Ethernet)

RX packets 0  bytes 0 (0.0 B)

RX errors 0  dropped 0  overruns 0  frame 0

TX packets 0  bytes 0 (0.0 B)

TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

device interrupt 187

 

lo: flags=73  mtu 65536  metric 1

inet 127.0.0.1  netmask 255.0.0.0

inet6 ::1  prefixlen 128  scopeid 0x10

loop  txqueuelen 1000  (Local Loopback)

RX packets 84  bytes 6320 (6.1 KiB)

RX errors 0  dropped 0  overruns 0  frame 0

TX packets 84  bytes 6320 (6.1 KiB)

TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

wlan0: flags=4099  mtu 1500  metric 1

ether c8:fe:0f:3d:94:d8  txqueuelen 1000  (Ethernet)

RX packets 0  bytes 0 (0.0 B)

RX errors 0  dropped 0  overruns 0  frame 0

TX packets 0  bytes 0 (0.0 B)

TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

root@myir-remi-1g:/#

root@myir-remi-1g:/#

root@myir-remi-1g:/#

root@myir-remi-1g:/# ls

bin  boot  dev  eeprom.txt  etc  home  lib  lib64  lost+found  media  mnt  opt  proc  run  sbin  sys  tmp  usr  var

root@myir-remi-1g:/# cd /lib

root@myir-remi-1g:/lib# ls

firmware                 libanl.so.1     libgcc_s.so.1          libnss_compat.so.2    libresolv-2.31.so  modules

ld-2.31.so               libc-2.31.so    libm-2.31.so           libnss_dns-2.31.so    libresolv.so.2     security

ld-linux-aarch64.so.1    libc.so.6       libm.so.6              libnss_dns.so.2       librt-2.31.so      systemd

ld-linux-armhf.so.3      libcap.so.2     libmyir_code.so        libnss_files-2.31.so  librt.so.1         udev

libBrokenLocale-2.31.so  libcap.so.2.32  libnsl-2.31.so         libnss_files.so.2     libutil-2.31.so

libBrokenLocale.so.1     libdl-2.31.so   libnsl.so.1            libpthread-2.31.so    libutil.so.1

libanl-2.31.so           libdl.so.2      libnss_compat-2.31.so  libpthread.so.0       modprobe.d

root@myir-remi-1g:/lib# cd /systemd

-sh: cd: /systemd: No such file or directory

root@myir-remi-1g:/lib# cd systemd/

root@myir-remi-1g:/lib/systemd# ls

journald.conf.d           systemd-backlight               systemd-network-generator     systemd-sysctl

libsystemd-shared-244.so  systemd-boot-check-no-failures  systemd-networkd              systemd-sysv-install

logind.conf.d             systemd-cgroups-agent           systemd-networkd-wait-online  systemd-time-wait-sync

network                   systemd-dissect                 systemd-pstore                systemd-timedated

ntp-units.d               systemd-fsck                    systemd-quotacheck            systemd-timesyncd

resolv.conf               systemd-growfs                  systemd-random-seed           systemd-udevd

system                    systemd-hibernate-resume        systemd-remount-fs            systemd-update-done

system-generators         systemd-hostnamed               systemd-reply-password        systemd-update-utmp

system-preset             systemd-initctl                 systemd-resolved              systemd-user-runtime-dir

system-shutdown           systemd-journald                systemd-rfkill                systemd-user-sessions

system-sleep              systemd-localed                 systemd-shutdown              systemd-vconsole-setup

system.conf.d             systemd-logind                  systemd-sleep                 systemd-volatile-root

systemd                   systemd-makefs                  systemd-socket-proxyd

systemd-ac-power          systemd-modules-load            systemd-sulogin-shell

root@myir-remi-1g:/lib/systemd# cd network/

root@myir-remi-1g:/lib/systemd/network# ls

80-container-host0.network  80-container-vz.network  80-wifi-ap.network.example       80-wired.network

80-container-ve.network     80-wifi-adhoc.network    80-wifi-station.network.example  99-default.link

root@myir-remi-1g:/lib/systemd/network# cat 80-wi

80-wifi-adhoc.network            80-wifi-station.network.example

80-wifi-ap.network.example       80-wired.network

root@myir-remi-1g:/lib/systemd/network# cat 80-wired.network

[Match]

Name=en* eth*

KernelCommandLine=!nfsroot

KernelCommandLine=!ip

 

[Network]

DHCP=yes

 

[DHCP]

RouteMetric=10

ClientIdentifier=mac

root@myir-remi-1g:/lib/systemd/network#

root@myir-remi-1g:/lib/systemd/network#

root@myir-remi-1g:/lib/systemd/network#

root@myir-remi-1g:/lib/systemd/network# ls

80-container-host0.network  80-container-vz.network  80-wifi-ap.network.example       80-wired.network

80-container-ve.network     80-wifi-adhoc.network    80-wifi-station.network.example  99-default.link

root@myir-remi-1g:/lib/systemd/network# ls

80-container-host0.network  80-container-vz.network  80-wifi-ap.network.example       80-wired.network

80-container-ve.network     80-wifi-adhoc.network    80-wifi-station.network.example  99-default.link

root@myir-remi-1g:/lib/systemd/network# vi 10-wired.network

root@myir-remi-1g:/lib/systemd/network# ls

80-container-host0.network  80-container-vz.network  80-wifi-ap.network.example       80-wired.network

80-container-ve.network     80-wifi-adhoc.network    80-wifi-station.network.example  99-default.link

root@myir-remi-1g:/lib/systemd/network#

root@myir-remi-1g:/lib/systemd/network#

root@myir-remi-1g:/lib/systemd/network#  vi /etc/systemd/network/10-eth0-static.network

root@myir-remi-1g:/lib/systemd/network# ls

80-container-host0.network  80-container-vz.network  80-wifi-ap.network.example       80-wired.network

80-container-ve.network     80-wifi-adhoc.network    80-wifi-station.network.example  99-default.link

root@myir-remi-1g:/lib/systemd/network# cat /etc/systemd/network/10-eth0-static.network

[Match]

Name=eth0

[Network]

Address=172.18.122.98/24

Gateway=172.18.122.1

root@myir-remi-1g:/lib/systemd/network# ls

80-container-host0.network  80-container-vz.network  80-wifi-ap.network.example       80-wired.network

80-container-ve.network     80-wifi-adhoc.network    80-wifi-station.network.example  99-default.link

root@myir-remi-1g:/lib/systemd/network# ls -a

.   80-container-host0.network  80-container-vz.network  80-wifi-ap.network.example       80-wired.network

..  80-container-ve.network     80-wifi-adhoc.network    80-wifi-station.network.example  99-default.link

root@myir-remi-1g:/lib/systemd/network# cd /etc/systemd/network/

root@myir-remi-1g:/etc/systemd/network# ls

10-eth0-static.network

root@myir-remi-1g:/etc/systemd/network# systemctl restart systemd-networkd.service

root@myir-remi-1g:/etc/systemd/network# ifconfig eth0

eth0: flags=4163  mtu 1500  metric 1

inet 172.18.122.98  netmask 255.255.255.0  broadcast 172.18.122.255

inet6 fe80::8057:13ff:febf:e59b  prefixlen 64  scopeid 0x20

ether 82:57:13:bf:e5:9b  txqueuelen 1000  (Ethernet)

RX packets 4403  bytes 660158 (644.6 KiB)

RX errors 0  dropped 0  overruns 0  frame 0

TX packets 6540  bytes 1836362 (1.7 MiB)

TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

device interrupt 184

结果IP在开发板重新启动后地址又变回默认的IP地址。后来查阅相关的资料才知道/usr/share/myir_test/age.sh里面文件需要屏蔽,于是用CP命令将整个文件夹重新命名。随后IP地址设置成功。

   总的来说开发如果需要开发自动的东西需要做的事情很多,最好自己刷一个新的系统以便后面开发工作进行。

 

 

作者: 智者学派, 来源:面包板社区

链接: https://mbb.eet-china.com/blog/uid-me-1681418.html

版权声明:本文为博主原创,未经本人允许,禁止转载!

文章评论0条评论)

登录后参与讨论
我要评论
0
5
关闭 站长推荐上一条 /2 下一条