|
1 | 1 | #!/bin/sh |
2 | 2 |
|
| 3 | +# This file is only used if IFACE fail in the startup-script |
| 4 | + |
3 | 5 | IFCONFIG="/sbin/ifconfig" |
4 | 6 | INTERFACES="/etc/network/interfaces" |
5 | 7 |
|
6 | | -IFACE=$(lshw -c network | grep "logical name" | awk '{print $3; exit}') |
7 | | -ADDRESS=$($IFCONFIG | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1') |
| 8 | +IFACE=$(ip -o link show | awk '{print $2,$9}' | grep 'UP' | cut -d ':' -f 1) |
| 9 | +ADDRESS=$(hostname -I | cut -d ' ' -f 1) |
8 | 10 | NETMASK=$($IFCONFIG | grep -w inet |grep -v 127.0.0.1| awk '{print $4}' | cut -d ":" -f 2) |
9 | 11 | GATEWAY=$(route -n|grep "UG"|grep -v "UGH"|cut -f 10 -d " ") |
10 | 12 |
|
11 | 13 | cat <<-IPCONFIG > "$INTERFACES" |
12 | 14 | source /etc/network/interfaces.d/* |
13 | | -
|
14 | 15 | # The loopback network interface |
15 | | - auto lo $IFACE |
16 | | - iface lo inet loopback |
17 | | -
|
| 16 | +auto lo $IFACE |
| 17 | +iface lo inet loopback |
18 | 18 | # The primary network interface |
19 | | - iface $IFACE inet static |
20 | | - pre-up /sbin/ethtool -K $IFACE tso off |
21 | | - pre-up /sbin/ethtool -K $IFACE gso off |
22 | | -
|
| 19 | +iface $IFACE inet static |
| 20 | +pre-up /sbin/ethtool -K $IFACE tso off |
| 21 | +pre-up /sbin/ethtool -K $IFACE gso off |
| 22 | +# Fixes https://github.com/nextcloud/vm/issues/92: |
| 23 | +pre-up ip link set dev $IFACE mtu 1430 |
23 | 24 | # Best practice is to change the static address |
24 | 25 | # to something outside your DHCP range. |
25 | | - address $ADDRESS |
26 | | - netmask $NETMASK |
27 | | - gateway $GATEWAY |
28 | | -
|
| 26 | +address $ADDRESS |
| 27 | +netmask $NETMASK |
| 28 | +gateway $GATEWAY |
| 29 | +# This is an autoconfigured IPv6 interface |
| 30 | +# iface $IFACE inet6 auto |
29 | 31 | # Exit and save: [CTRL+X] + [Y] + [ENTER] |
30 | 32 | # Exit without saving: [CTRL+X] |
31 | | -
|
32 | 33 | IPCONFIG |
33 | 34 |
|
34 | 35 | exit 0 |
0 commit comments