Skip to content

Commit 7d0d7eb

Browse files
author
Daniel Hansson
authored
Update ip.sh
1 parent 1f22fbb commit 7d0d7eb

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

static/ip.sh

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
11
#!/bin/sh
22

3+
# This file is only used if IFACE fail in the startup-script
4+
35
IFCONFIG="/sbin/ifconfig"
46
INTERFACES="/etc/network/interfaces"
57

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)
810
NETMASK=$($IFCONFIG | grep -w inet |grep -v 127.0.0.1| awk '{print $4}' | cut -d ":" -f 2)
911
GATEWAY=$(route -n|grep "UG"|grep -v "UGH"|cut -f 10 -d " ")
1012

1113
cat <<-IPCONFIG > "$INTERFACES"
1214
source /etc/network/interfaces.d/*
13-
1415
# The loopback network interface
15-
auto lo $IFACE
16-
iface lo inet loopback
17-
16+
auto lo $IFACE
17+
iface lo inet loopback
1818
# 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
2324
# Best practice is to change the static address
2425
# 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
2931
# Exit and save: [CTRL+X] + [Y] + [ENTER]
3032
# Exit without saving: [CTRL+X]
31-
3233
IPCONFIG
3334

3435
exit 0

0 commit comments

Comments
 (0)