core/iproute2/net.iproute2

49 lines
832 B
Plaintext
Raw Normal View History

#!/bin/sh
#
2014-04-15 21:34:12 +02:00
# /etc/rc.d/net: start/stop network interface
#
2014-07-01 21:18:48 +02:00
# Connection type: "DHCP" or "static"
TYPE="DHCP"
# For "static" connections, specify your settings here:
# To see your available devices run "ip link".
2014-04-15 21:34:12 +02:00
DEV=enp11s0
2014-07-01 21:18:48 +02:00
ADDR=192.168.1.100
2014-04-15 21:34:12 +02:00
MASK=24
GW=192.168.1.1
2014-07-01 21:18:48 +02:00
# Optional settings:
DHCPOPTS="-t 10"
2014-07-01 21:18:48 +02:00
case $1 in
2014-04-15 21:34:12 +02:00
start)
2014-12-26 09:49:28 +01:00
if [ "${TYPE}" = "DHCP" ]; then
2014-07-01 21:18:48 +02:00
/sbin/dhcpcd ${DHCPOPTS}
2014-04-15 21:34:12 +02:00
else
/sbin/ip addr add ${ADDR}/${MASK} dev ${DEV} broadcast +
/sbin/ip link set ${DEV} up
/sbin/ip route add default via ${GW}
fi
;;
stop)
2014-12-26 09:49:28 +01:00
if [ "${TYPE}" = "DHCP" ]; then
2014-04-15 21:34:12 +02:00
/sbin/dhcpcd -x
else
/sbin/ip route del default
/sbin/ip link set ${DEV} down
/sbin/ip addr del ${ADDR}/${MASK} dev ${DEV}
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 [start|stop|restart]"
;;
esac
# End of file
2014-04-15 21:34:12 +02:00