blog/source/_posts/2015-01-06-static-mac-address-for-bananapi.markdown

38 lines
1.2 KiB
Markdown
Raw Normal View History

2015-01-06 19:32:43 +00:00
---
layout: post
title: "Static MAC-Address for bananapi"
date: 2015-01-06 20:20:39 +0100
comments: true
---
The bananapi does currently assign random mac addresses to its ethnernet nic,
which is bad if you want to assign static dhcp leases. To solve this issue just
create the following udev rule:
``` plain /etc/udev/rules.d/75-static-mac
ACTION=="add", SUBSYSTEM=="net", ATTR{dev_id}=="0x0", RUN+="/usr/bin/ip link set dev %k address XX:XX:XX:XX:XX:XX"
```
Replace XX:XX:XX:XX:XX:XX with your current mac address:
``` bash
$ ip address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN group
default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
group default qlen 1000
link/ether 02:8a:03:43:02:2a brd ff:ff:ff:ff:ff:ff
inet 192.168.1.56/24 brd 192.168.1.255 scope global eth0
inet6 fe80::8a:3ff:fe43:22a/64 scope link
valid_lft forever preferred_lft forever
inet6 fe80::9985:bd71:3b59:4875/64 scope link
valid_lft forever preferred_lft forever
```
which is `02:8a:03:43:02:2a` in my case.