Я работаю с Raspberry Pi Zeros в подсети. Я купил внешние адаптеры Ethernet для каждого из них, чтобы соединить их друг с другом. К сожалению, все эти адаптеры Ethernet имеют одинаковые MAC-адреса, что делает практически невозможным обмен данными между Pis.

Из-за этого я попытался принудительно изменить MAC-адреса, отредактировав /etc/systemd/network/00-default.link в каждом Pi Zero в соответствии с шагами, описанными в этом посте. В конечном итоге я использовал следующий код:

[Match]
MACAddress=00:e0:4c:53:44:58

[Link]
MACAddress=10:00:00:00:00:11

Обратите внимание, что я использовал новый MAC-адрес для каждого Pi

К сожалению, после перезапуска всех моих нулей Pi ни один из MAC-адресов не обновился до новых назначенных значений. Когда я проверяю с помощью ifconfig все они остались прежними. Что я делаю неправильно?

Дополнительная информация:

ip neighbor show дает следующий результат:

pi@raspberrypi:~ $ ip neighbor show
192.168.2.37 dev wlan0 lladdr ac:bc:32:87:93:39 DELAY
192.168.3.12 dev enxb827eb9c0ecf lladdr 00:e0:4c:53:44:58 STALE
192.168.3.10 dev enxb827eb9c0ecf lladdr 00:e0:4c:53:44:58 STALE
192.168.3.11 dev enxb827eb9c0ecf lladdr 00:e0:4c:53:44:58 STALE
192.168.2.1 dev wlan0 lladdr 40:c7:29:4e:4d:f8 STALE

ifconfig показывает:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.3.12  netmask 255.255.255.0  broadcast 192.168.3.255
        inet6 fe80::4db4:2630:6df9:2aeb  prefixlen 64  scopeid 0x20<link>
        ether 00:e0:4c:53:44:58  txqueuelen 1000  (Ethernet)
        RX packets 144  bytes 11482 (11.2 KiB)
        RX errors 1  dropped 0  overruns 0  frame 0
        TX packets 133  bytes 17886 (17.4 KiB)
        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 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

Я также установил статический IP в /etc/dhcpcd.conf примерно так:

interface eth0
static ip_address=192.168.3.12

lsusb выдает результат:

Bus 001 Device 002: ID 0fe6:9700 Kontron (Industrial Computer Source / ICS Advent) DM9601 Fast Ethernet Adapter Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

dmesg выдает результат:

pi@raspberrypi:~ $ dmesg
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.14.34+ (dc4@dc4-XPS13-9333) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611)) #1110 Mon Apr 16 14:51:42 BST 2018
[    0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
[    0.000000] OF: fdt: Machine model: Raspberry Pi Zero Rev 1.3
[    0.000000] Memory policy: Data cache writeback
[    0.000000] cma: Reserved 8 MiB at 0x17400000
[    0.000000] On node 0 totalpages: 98304
[    0.000000] free_area_init_node: node 0, pgdat c09be368, node_mem_map d7c8a400
[    0.000000]   Normal zone: 864 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 98304 pages, LIFO batch:31
[    0.000000] random: fast init done
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0 
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 97440
[    0.000000] Kernel command line: bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708_fb.fbswap=1 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000  dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=PARTUUID=89bc1db8-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles
[    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Memory: 370308K/393216K available (6415K kernel code, 587K rwdata, 1984K rodata, 440K init, 677K bss, 14716K reserved, 8192K cma-reserved)
[    0.000000] Virtual kernel memory layout:
                   vector  : 0xffff0000 - 0xffff1000   (   4 kB)
                   fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
                   vmalloc : 0xd8800000 - 0xff800000   ( 624 MB)
                   lowmem  : 0xc0000000 - 0xd8000000   ( 384 MB)
                   modules : 0xbf000000 - 0xc0000000   (  16 MB)
                     .text : 0xc0008000 - 0xc064c188   (6417 kB)
                     .init : 0xc08c8000 - 0xc0936000   ( 440 kB)
                     .data : 0xc0936000 - 0xc09c8d10   ( 588 kB)
                      .bss : 0xc09ce65c - 0xc0a77ba4   ( 678 kB)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] ftrace: allocating 24081 entries in 71 pages
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000029] sched_clock: 32 bits at 1000kHz, resolution 1000ns, wraps every 2147483647500ns
[    0.000059] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275 ns
[    0.000144] bcm2835: system timer (irq = 27)
[    0.000696] Console: colour dummy device 80x30
[    0.000722] console [tty1] enabled
[    0.000756] Calibrating delay loop... 697.95 BogoMIPS (lpj=3489792)
[    0.060295] pid_max: default: 32768 minimum: 301
[    0.060783] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.060802] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.062076] Disabling memory control group subsystem
[    0.062236] CPU: Testing write buffer coherency: ok
[    0.063310] Setting up static identity map for 0x8200 - 0x8238
[    0.064507] devtmpfs: initialized
[    0.074273] VFP support v0.3: implementor 41 architecture 1 part 20 variant b rev 5
[    0.074648] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.074676] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.075995] pinctrl core: initialized pinctrl subsystem
[    0.077312] NET: Registered protocol family 16
[    0.080259] DMA: preallocated 1024 KiB pool for atomic coherent allocations
[    0.086650] hw-breakpoint: found 6 breakpoint and 1 watchpoint registers.
[    0.086666] hw-breakpoint: maximum watchpoint size is 4 bytes.
[    0.086788] Serial: AMBA PL011 UART driver
[    0.089479] bcm2835-mbox 2000b880.mailbox: mailbox enabled
[    0.128920] bcm2835-dma 20007000.dma: DMA legacy API manager at d880d000, dmachans=0x1
[    0.131193] SCSI subsystem initialized
[    0.131424] usbcore: registered new interface driver usbfs
[    0.131522] usbcore: registered new interface driver hub
[    0.131723] usbcore: registered new device driver usb
[    0.140800] raspberrypi-firmware soc:firmware: Attached to firmware from 2018-04-16 18:21
[    0.142844] clocksource: Switched to clocksource timer
[    0.227945] VFS: Disk quotas dquot_6.6.0
[    0.228066] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    0.228352] FS-Cache: Loaded
[    0.228672] CacheFiles: Loaded
[    0.245507] NET: Registered protocol family 2
[    0.246680] TCP established hash table entries: 4096 (order: 2, 16384 bytes)
[    0.246766] TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
[    0.246860] TCP: Hash tables configured (established 4096 bind 4096)
[    0.247011] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.247040] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.247387] NET: Registered protocol family 1
[    0.248079] RPC: Registered named UNIX socket transport module.
[    0.248090] RPC: Registered udp transport module.
[    0.248095] RPC: Registered tcp transport module.
[    0.248100] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.250051] hw perfevents: no irqs for PMU, sampling events not supported
[    0.250120] hw perfevents: enabled with armv6_1176 PMU driver, 3 counters available
[    0.253895] workingset: timestamp_bits=14 max_order=17 bucket_order=3
[    0.265615] FS-Cache: Netfs 'nfs' registered for caching
[    0.266895] NFS: Registering the id_resolver key type
[    0.266969] Key type id_resolver registered
[    0.266977] Key type id_legacy registered
[    0.267001] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[    0.271488] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251)
[    0.271891] io scheduler noop registered
[    0.271903] io scheduler deadline registered (default)
[    0.272429] io scheduler cfq registered
[    0.272443] io scheduler mq-deadline registered
[    0.272450] io scheduler kyber registered
[    0.274823] BCM2708FB: allocated DMA memory 57500000
[    0.274884] BCM2708FB: allocated DMA channel 0 @ d880d000
[    0.282914] Console: switching to colour frame buffer device 82x26
[    0.290733] bcm2835-rng 20104000.rng: hwrng registered
[    0.290954] vc-mem: phys_addr:0x00000000 mem_base=0x1ec00000 mem_size:0x20000000(512 MiB)
[    0.291937] vc-sm: Videocore shared memory driver
[    0.292521] gpiomem-bcm2835 20200000.gpiomem: Initialised: Registers at 0x20200000
[    0.311056] brd: module loaded
[    0.323056] loop: module loaded
[    0.323077] Loading iSCSI transport class v2.0-870.
[    0.323951] usbcore: registered new interface driver smsc95xx
[    0.323983] dwc_otg: version 3.00a 10-AUG-2012 (platform bus)
[    0.552425] Core Release: 2.80a
[    0.552443] Setting default values for core params
[    0.552481] Finished setting default values for core params
[    0.752794] Using Buffer DMA mode
[    0.752807] Periodic Transfer Interrupt Enhancement - disabled
[    0.752813] Multiprocessor Interrupt Enhancement - disabled
[    0.752824] OTG VER PARAM: 0, OTG VER FLAG: 0
[    0.752959] Dedicated Tx FIFOs mode
[    0.753813] WARN::dwc_otg_hcd_init:1046: FIQ DMA bounce buffers: virt = 0xd7514000 dma = 0x57514000 len=9024
[    0.753842] FIQ FSM acceleration enabled for :
               Non-periodic Split Transactions
               Periodic Split Transactions
               High-Speed Isochronous Endpoints
               Interrupt/Control Split Transaction hack enabled
[    0.753853] dwc_otg: Microframe scheduler enabled
[    0.754022] WARN::hcd_init_fiq:459: FIQ on core 0 at 0xc049913c
[    0.754036] WARN::hcd_init_fiq:460: FIQ ASM at 0xc0499418 length 36
[    0.754064] WARN::hcd_init_fiq:486: MPHI regs_base at 0xd88a5000
[    0.754145] dwc_otg 20980000.usb: DWC OTG Controller
[    0.754209] dwc_otg 20980000.usb: new USB bus registered, assigned bus number 1
[    0.754284] dwc_otg 20980000.usb: irq 56, io mem 0x00000000
[    0.754338] Init: Port Power? op_state=1
[    0.754344] Init: Power Port (0)
[    0.754746] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    0.754763] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    0.754773] usb usb1: Product: DWC OTG Controller
[    0.754783] usb usb1: Manufacturer: Linux 4.14.34+ dwc_otg_hcd
[    0.754792] usb usb1: SerialNumber: 20980000.usb
[    0.755841] hub 1-0:1.0: USB hub found
[    0.755929] hub 1-0:1.0: 1 port detected
[    0.756906] dwc_otg: FIQ enabled
[    0.756918] dwc_otg: NAK holdoff enabled
[    0.756925] dwc_otg: FIQ split-transaction FSM enabled
[    0.756943] Module dwc_common_port init
[    0.757431] usbcore: registered new interface driver usb-storage
[    0.757870] mousedev: PS/2 mouse device common for all mice
[    0.757928] IR NEC protocol handler initialized
[    0.757937] IR RC5(x/sz) protocol handler initialized
[    0.757942] IR RC6 protocol handler initialized
[    0.757947] IR JVC protocol handler initialized
[    0.757952] IR Sony protocol handler initialized
[    0.757957] IR SANYO protocol handler initialized
[    0.757962] IR Sharp protocol handler initialized
[    0.757967] IR MCE Keyboard/mouse protocol handler initialized
[    0.757971] IR XMP protocol handler initialized
[    0.759220] bcm2835-wdt 20100000.watchdog: Broadcom BCM2835 watchdog timer
[    0.759743] bcm2835-cpufreq: min=700000 max=1000000
[    0.760330] sdhci: Secure Digital Host Controller Interface driver
[    0.760340] sdhci: Copyright(c) Pierre Ossman
[    0.760952] sdhost-bcm2835 20202000.mmc: could not get clk, deferring probe
[    0.761148] sdhci-pltfm: SDHCI platform and OF driver helper
[    0.761864] ledtrig-cpu: registered to indicate activity on CPUs
[    0.762047] hidraw: raw HID events driver (C) Jiri Kosina
[    0.762299] usbcore: registered new interface driver usbhid
[    0.762307] usbhid: USB HID core driver
[    0.763320] vchiq: vchiq_init_state: slot_zero = d7580000, is_master = 0
[    0.765220] [vc_sm_connected_init]: start
[    0.774617] [vc_sm_connected_init]: end - returning 0
[    0.775556] Initializing XFRM netlink socket
[    0.775621] NET: Registered protocol family 17
[    0.775780] Key type dns_resolver registered
[    0.777575] registered taskstats version 1
[    0.785666] uart-pl011 20201000.serial: cts_event_workaround enabled
[    0.785796] 20201000.serial: ttyAMA0 at MMIO 0x20201000 (irq = 81, base_baud = 0) is a PL011 rev2
[    0.785895] console [ttyAMA0] enabled
[    0.789187] sdhost: log_buf @ d7513000 (57513000)
[    0.862919] mmc0: sdhost-bcm2835 loaded - DMA enabled (>1)
[    0.864171] of_cfs_init
[    0.864320] of_cfs_init: OK
[    0.865457] Waiting for root device PARTUUID=89bc1db8-02...
[    0.940799] mmc0: host does not support reading read-only switch, assuming write-enable
[    0.942767] mmc0: Problem switching card into high-speed mode!
[    0.943354] mmc0: new SDHC card at address 0001
[    0.944140] mmcblk0: mmc0:0001 SD16G 7.41 GiB (quirks 0x80000000)
[    0.947065]  mmcblk0: p1 p2
[    0.973489] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    0.973596] VFS: Mounted root (ext4 filesystem) readonly on device 179:2.
[    0.974137] Indeed it is in host mode hprt0 = 00021501
[    1.049913] devtmpfs: mounted
[    1.052380] Freeing unused kernel memory: 440K
[    1.052389] This architecture does not have kernel memory protection.
[    1.182950] usb 1-1: new full-speed USB device number 2 using dwc_otg
[    1.183259] Indeed it is in host mode hprt0 = 00021501
[    1.424142] usb 1-1: New USB device found, idVendor=0fe6, idProduct=9700
[    1.424164] usb 1-1: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[    1.424175] usb 1-1: Product: USB 2.0 10/100M Ethernet Adaptor
[    2.009745] systemd[1]: System time before build time, advancing clock.
[    2.275793] NET: Registered protocol family 10
[    2.277891] Segment Routing with IPv6
[    2.299784] ip_tables: (C) 2000-2006 Netfilter Core Team
[    2.352077] systemd[1]: systemd 232 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN)
[    2.353490] systemd[1]: Detected architecture arm.
[    2.356390] systemd[1]: Set hostname to <raspberrypi>.
[    2.710763] uart-pl011 20201000.serial: no DMA platform data
[    3.764873] systemd[1]: Set up automount Arbitrary Executable File Formats File System Automount Point.
[    3.766038] systemd[1]: Listening on udev Kernel Socket.
[    3.766790] systemd[1]: Listening on fsck to fsckd communication Socket.
[    3.804670] systemd[1]: Started Forward Password Requests to Wall Directory Watch.
[    3.805743] systemd[1]: Listening on Journal Socket.
[    3.807729] systemd[1]: Created slice System Slice.
[    3.814051] systemd[1]: Mounting RPC Pipe File System...
[    4.008481] i2c /dev entries driver
[    6.022129] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[    6.654041] systemd-journald[80]: Received request to flush runtime journal from PID 1
[    9.630719] snd_bcm2835: module is from the staging directory, the quality is unknown, you have been warned.
[    9.703900] bcm2835_alsa bcm2835_alsa: card created with 8 channels
[   10.945104] dm9601 1-1:1.0 eth0: register 'dm9601' at usb-20980000.usb-1, Davicom DM96xx USB 10/100 Ethernet, 00:e0:4c:53:44:58
[   10.949769] usbcore: registered new interface driver dm9601
[   10.971385] usbcore: registered new interface driver sr9700
[   16.499971] enc28j60 spi0.0: enc28j60 Ethernet driver 1.02 loaded
[   16.537004] enc28j60 spi0.0: enc28j60 chip not found
[   16.537113] enc28j60: probe of spi0.0 failed with error -5
[   17.189760] dm9601 1-1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xFFFF
[   17.236312] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[   17.240649] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   17.276623] dm9601 1-1:1.0 eth0: kevent 4 may have been dropped
[   17.284604] dm9601 1-1:1.0 eth0: kevent 4 may have been dropped
[   17.312928] dm9601 1-1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xFFFF
[   17.411699] dm9601 1-1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xFFFF
[   19.120593] random: crng init done
[   19.977363] Adding 102396k swap on /var/swap.  Priority:-2 extents:1 across:102396k SSFS
[   28.390600] usb 1-1: unexpected tiny rx frame
[   31.630396] fuse init (API version 7.26)

1 ответ1

0

Вот мое совершенно необоснованное предположение, прежде чем я потерял сознание на ночь.

У вас больше интерфейсов, чем только у USB-адаптера Ethernet, и * в вашем файле .link также больше, чем просто у USB-адаптера. В частности, оно соответствует петлевому устройству lo .

После networkd изменил МАС - адрес первого устройства оно соответствует (что, вероятно , lo из - за наличия наименьшую IfIndex), он не может использовать тот же MAC на любой другой интерфейс - ядро отказывается такого рода дубликата операции. Таким образом, ваш новый MAC-адрес не может быть помещен в eth0, потому что он занят lo.

Чтобы предотвратить это (предполагая, что это действительно проблема), добавьте дополнительные совпадения - например, совпадение с помощью Driver или OriginalName.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками .