在哪裡添加 ip 連結設定以便它們在啟動時執行?

在哪裡添加 ip 連結設定以便它們在啟動時執行?

我有一個 Raspberry Pi 0 W,我將其設定為共享 USB 設備,我想在某處添加以下內容,以便它們在啟動時執行:

    sudo ip link set dev can0 type can bitrate 500000
    sudo ip link set dev can0 up

我已經放入/etc/network/interfaces

############### CAN BUS CONFIG ###########################
auto can0
iface can0 inet manual
    pre-up ip link set $IFACE type can bitrate 500000 listen-only off
    up /sbin/ifconfig $IFACE up
    down /sbin/ifconfig $IFACE down

我不太確定上面的功能或其好處,有人能解釋一下嗎?

Raspberry Pi 0 W 上的作業系統是:

Raspbian GNU/Linux 11 (bullseye)

答案1

已修復,我修改了 /etc/rc.local 並添加了以下行:

ip link set dev can0 type can bitrate 500000
ip link set dev can0 up

現在一切都很好......或者確實如此,我很快就與我交談過,我還需要添加:

usbip --debug bind -b 1-1
usbip -d

由於某種我不明白的原因,執行 usbip -d 會殺死 can0,然後在鍵入時不再可見: ip link

相關內容