S905定制类镜像设置网络及mac

Moderator: 论坛版主

Post Reply
User avatar
wusheng
4
Posts: 211
Joined: Thu Nov 01, 2018 10:13 am

S905定制类镜像设置网络及mac

Post by wusheng » Tue Aug 13, 2019 5:23 am

在机顶盒定制镜像中,有开放出自定义设置网络网络的位置

以R3300-L镜像为例:(修改自N1镜像)

将镜像烧录到U盘后,拔插一次U盘
进入U盘BOOT分区,
复制一份interfaces.bak文件并修改为interfaces
armbian用户可直接修改/etc/network/interfaces效果相同
修改interfaces文件
设置MAC示例

Code: Select all

...省略
allow-hotplug eth0
no-auto-down eth0
iface eth0 inet dhcp
hwaddress ether 17:56:ac:4c:bd:d9

....省略
设置静态IP示例1

Code: Select all

....省略
allow-hotplug eth0
no-auto-down eth0
iface eth0 inet static
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
....省略
设置静态IP示例2

Code: Select all

....省略
allow-hotplug eth0
no-auto-down eth0
iface eth0 inet static
address 172.16.5.2
netmask 255.255.0.0
gateway 172.16.0.1
dns-nameservers 8.8.8.8 8.8.4.4
....省略
修改完成后保存并插入U盘启动
armbian直接改/etc/network/interfaces的用户运行下面命令重连网络

Code: Select all

systemctl restart networking
普通用户请忽略:

内部步骤为:
检查boot分区是否有interfaces文件,有则备份原镜像内文件并将boot分区文件复制到/etc/network/interfaces,
如果没有interfaces文件,则将/etc/network/interfaces.bak还原到/etc/network/interfaces
详细文件请看,脚本文件路径为/root/set_mac.sh

Code: Select all

#!/bin/bash

if [[ -f /boot/interfaces ]]; then
    [[ ! -f /etc/network/interfaces.bak ]]&&mv /etc/network/interfaces /etc/network/interfaces.bak
    cp /boot/interfaces /etc/network/interfaces
    systemctl restart networking
fi
if [[ ! -f /boot/interfaces ]]; then
    if [[ -f /boot/interfaces.bak ]]; then
        if [[ -f /etc/network/interfaces.bak ]]; then
            mv /etc/network/interfaces.bak /etc/network/interfaces
            systemctl restart networking
        else
            mv /boot/interfaces.bak /etc/network/interfaces
            systemctl restart networking
        fi

    fi
fi
注:部分基于18.04 的armbian镜像采用netplan管理网络,此帖方法不适用
有未记录问题联系https://t.me/wusheng

Post Reply