diff options
Diffstat (limited to 'linux/conf/rc.d/net')
-rwxr-xr-x | linux/conf/rc.d/net | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/linux/conf/rc.d/net b/linux/conf/rc.d/net new file mode 100755 index 0000000..a4c566a --- /dev/null +++ b/linux/conf/rc.d/net @@ -0,0 +1,54 @@ +#!/bin/sh +# +# /etc/rc.d/net: start/stop network interface +# + +# Connection type: "DHCP" or "static" +TYPE="DHCP" + +# For "static" connections, specify your settings here: +# To see your available devices run "ip link". +DEV=ens3 +ADDR=192.168.1.100 +MASK=24 +GW=192.168.1.1 + +# Optional settings: +DHCPOPTS="-t 10" + +/sbin/ifconfig dummy down > /dev/null 2>&1 +/sbin/ifconfig dummy0 down > /dev/null 2>&1 +/sbin/ifconfig ifb0 down > /dev/null 2>&1 +/sbin/ifconfig ifb1 down > /dev/null 2>&1 +/sbin/ifconfig bond0 down > /dev/null 2>&1 + +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 + /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 + |