野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 25552|回复: 1

[求助] imx6 debian设置静态ip

[复制链接]
发表于 2021-3-22 15:48:07 | 显示全部楼层 |阅读模式
想在debian上设置静态ip,就是 不是dhcp方式,在野火的资料中貌似没找到相关内容,然后网上找方法:按照网上的方法找到了网络的配置文件:
/etc/network/interfaces
打开该文件:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#auto eth0
#iface eth0 inet dhcp
# Example to keep MAC address between reboots
#hwaddress ether DE:AD:BE:EF:CA:FE

auto eth1
iface eth1 inet static
    address 192.168.1.88
    gateway 192.168.1.1
    netmask 255.255.255.0
    dns-nameservers 8.8.8.8.8.8.4.4


# The secondary network interface
auto eth2
iface eth2 inet dhcp

##connman: ethX static config
#connmanctl services
#Using the appropriate ethernet service, tell connman to setup a static IP address for that service:
#sudo connmanctl config <service> --ipv4 manual <ip_addr> <netmask> <gateway> --nameservers <dns_server>

##connman: WiFi
#
#connmanctl
#connmanctl> tether wifi off
#connmanctl> enable wifi
#connmanctl> scan wifi
#connmanctl> services
#connmanctl> agent on
#connmanctl> connect wifi_*_managed_psk
#connmanctl> quit

# Ethernet/RNDIS gadget (g_ether)
# Used by: /opt/scripts/boot/autoconfigure_usb0.sh
iface usb0 inet static
    address 192.168.7.2
    netmask 255.255.255.252
    network 192.168.7.0
    gateway 192.168.7.1




auto eth1
iface eth1 inet static
    address 192.168.1.88
    gateway 192.168.1.1
    netmask 255.255.255.0
    dns-nameservers 8.8.8.8.8.8.4.4

这个是我按照他的格式想设置静态ip,但是执行ifconfig eth1  restart以后发现并没有什么改变,ifconfig的内容是这样的:
eth1: flags=-28669<UP,BROADCAST,MULTICAST,DYNAMIC>  mtu 1500
        ether 72:1d:75:33:b4:ea  txqueuelen 1000  (Ethernet)
        RX packets 269  bytes 21518 (21.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 91  bytes 31434 (30.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.81  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::3892:bcff:fe7d:d057  prefixlen 64  scopeid 0x20<link>
        ether 3a:92:bc:7d:d0:57  txqueuelen 1000  (Ethernet)
        RX packets 92467  bytes 10802336 (10.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 84150  bytes 7482959 (7.1 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 2  bytes 221 (221.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2  bytes 221 (221.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


eth2是dhcp的,求问大神应该怎么设置能够保证重启了以后是静态ip,是配置一下就可以了还是需要写启动文件来设置?
回复

使用道具 举报

发表于 2021-3-23 09:53:55 | 显示全部楼层
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-23 15:39 , Processed in 0.039078 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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