#!/bin/sh # # /etc/rc.d/net: start/stop network interface # # Connection type: "DHCP" or "static" TYPE="static" # For "static" connections, specify your settings here: # To see your available devices run "ip link". DEV=enp8s0 ADDR=10.0.0.1 MASK=24 GW=10.0.0.1 # Optional settings: DHCPOPTS="-h $(/bin/hostname) -C resolv.conf $DEV" case $1 in start) if [ "${TYPE}" = "DHCP" ]; then /sbin/dhcpcd ${DHCPOPTS} 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) if [ "${TYPE}" = "DHCP" ]; then /usr/bin/pkill -F /var/run/dhcpcd-${DEV}.pid else # /sbin/ip route del default /sbin/ip route flush dev ${DEV} /sbin/ip link set ${DEV} down /sbin/ip addr flush dev ${DEV} fi ;; restart) $0 stop $0 start ;; *) echo "Usage: $0 [start|stop|restart]" ;; esac # End of file