Skip to content

Instantly share code, notes, and snippets.

Created September 30, 2010 07:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/604172 to your computer and use it in GitHub Desktop.
Save anonymous/604172 to your computer and use it in GitHub Desktop.
From efa1f5eadfd36159486aaf253852d646a7192148 Mon Sep 17 00:00:00 2001
From: Plamen Petrov <pvp@fs.uni-ruse.bg>
Date: Thu, 30 Sep 2010 10:04:04 +0300
Subject: [PATCH] Make CRUX net configuration easy for DHCP
Signed-off-by: Plamen Petrov <pvp@fs.uni-ruse.bg>
---
iproute2/.md5sum | 2 +-
iproute2/net.iproute2 | 30 +++++++++++++++++++++++-------
2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/iproute2/.md5sum b/iproute2/.md5sum
index 8cda67b..6ea0f0f 100644
--- a/iproute2/.md5sum
+++ b/iproute2/.md5sum
@@ -1,2 +1,2 @@
b0f281b3124bf04669e18f5fe16d4934 iproute2-2.6.35.tar.bz2
-0b01b0404718d043adf55cfa314c80bd net.iproute2
+612aa126ebdcfc7b44ee80f43683b6ba net.iproute2
diff --git a/iproute2/net.iproute2 b/iproute2/net.iproute2
index d3c9e3c..7659409 100644
--- a/iproute2/net.iproute2
+++ b/iproute2/net.iproute2
@@ -3,21 +3,37 @@
# /etc/rc.d/net: start/stop network
#
+# Set the folloing to 1 to make this script use DHCP for network configuration
+
+USE_DHCP=0
+
+# Please, note that if you don't use DHCP, you need to edit this file with correct
+# IP in place of the dummy 192.168.1.100/24 and edit /etc/resolv.conf appropriately
+
case $1 in
start)
# loopback
/sbin/ip addr add 127.0.0.1/8 dev lo broadcast + scope host
/sbin/ip link set lo up
# ethernet
- /sbin/ip addr add 192.168.1.100/24 dev eth0 broadcast +
- /sbin/ip link set eth0 up
- # default route
- /sbin/ip route add default via 192.168.1.1
+ if [ "${USE_DHCP}" -eq "1" ] ; then
+ # dhcpcd takes care of IP, netmask, default route, and resolver configuration for us
+ /sbin/dhcpcd eth0
+ else
+ /sbin/ip addr add 192.168.1.100/24 dev eth0 broadcast +
+ /sbin/ip link set eth0 up
+ # default route
+ /sbin/ip route add default via 192.168.1.1
+ fi
;;
stop)
- /sbin/ip route del default
- /sbin/ip link set eth0 down
- /sbin/ip addr del 192.168.1.100/24 dev eth0
+ if [ "${USE_DHCP}" -eq "1" ] ; then
+ /bin/kill -s TERM `pidof /sbin/dhcpcd`
+ else
+ /sbin/ip route del default
+ /sbin/ip link set eth0 down
+ /sbin/ip addr del 192.168.1.100/24 dev eth0
+ fi
/sbin/ip link set lo down
/sbin/ip addr del 127.0.0.1/8 dev lo
;;
--
1.7.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment