]>
Commit | Line | Data |
---|---|---|
7b616db4 JS |
1 | #!/bin/bash |
2 | ############################################################################ | |
3 | # # | |
4 | # This file is part of the IPFire Firewall. # | |
5 | # # | |
6 | # IPFire is free software; you can redistribute it and/or modify # | |
7 | # it under the terms of the GNU General Public License as published by # | |
8 | # the Free Software Foundation; either version 2 of the License, or # | |
9 | # (at your option) any later version. # | |
10 | # # | |
11 | # IPFire is distributed in the hope that it will be useful, # | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
14 | # GNU General Public License for more details. # | |
15 | # # | |
16 | # You should have received a copy of the GNU General Public License # | |
17 | # along with IPFire; if not, write to the Free Software # | |
18 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # | |
19 | # # | |
20 | # Copyright (C) 2016 IPFire Team <info@ipfire.org> # | |
21 | # # | |
22 | ############################################################################ | |
23 | ||
24 | [ -n "${INTERFACE}" ] || exit 2 | |
25 | ||
26 | PHYSICAL_INTERFACE="${INTERFACE}" | |
27 | VIRTUAL_INTERFACE="${INTERFACE%phys}" | |
28 | #VIRTUAL_INTERFACE="${VIRTUAL_INTERFACE}0" | |
29 | ||
30 | # Do nothing if the physical interface does not end with "phys" | |
31 | case "${PHYSICAL_INTERFACE}" in | |
32 | *phys) | |
33 | ;; | |
34 | *) | |
35 | exit 0 | |
36 | ;; | |
37 | esac | |
38 | ||
39 | ADDRESS="$(</sys/class/net/${PHYSICAL_INTERFACE}/address)" | |
40 | rand="$(</proc/sys/kernel/random/uuid)" | |
41 | rand="${rand//-/}" | |
42 | GENERATED_ADDRESS=$(echo "02:${rand:0:2}:${rand:2:2}:${rand:4:2}:${rand:6:2}:${rand:8:2}") | |
43 | ||
44 | ip link add link "${PHYSICAL_INTERFACE}" "${VIRTUAL_INTERFACE}" address "${ADDRESS}" type macvlan mode bridge | |
45 | ip link set "${PHYSICAL_INTERFACE}" address "${GENERATED_ADDRESS}" | |
46 | ip link set "${PHYSICAL_INTERFACE}" up |