Skip to content

Commit 69f4108

Browse files
author
Daniel Hansson
authored
Create ip2.sh
1 parent d207e04 commit 69f4108

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

static/ip2.sh

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

0 commit comments

Comments
 (0)