LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices



Reply
 
Search this Thread
Old 06-11-2012, 08:19 PM   #1
irfan.acar
LQ Newbie
 
Registered: Jun 2012
Posts: 2

Rep: Reputation: Disabled
rc.inet1 patch for DHCP on multiple network interfaces


Hello,

When polling DHCP servers on multiple network interfaces, DHCP options for
one interface might end up being used for another interface. Included is a
patch for /etc/rc.d/rc.inet1 in Slackware 13.37 which fixes this.

For example, assume that /etc/rc.d/rc.inet1.conf is configured as below:

USE_DHCP[0]="yes"
DHCP_KEEPGW[0]="yes"
USE_DHCP[1]="yes"

This will cause the execution of two instances of the DHCP client as:

/sbin/dhcpcd -t 10 -G eth0
/sbin/dhcpcd -t 10 -G eth1

whereas what we had intended was to run:

/sbin/dhcpcd -t 10 -G eth0
/sbin/dhcpcd -t 10 eth1

The patch below fixes this by replacing the variable DHCP_OPTIONS with an
array.

-irfan



--- rc.inet1 2009-08-26 17:25:44.000000000 +0300
+++ rc.inet1 2012-06-12 03:01:10.531000082 +0300
@@ -105,13 +105,13 @@
. /etc/rc.d/rc.wireless ${1} start # Initialize any wireless parameters
fi
if [ "${USE_DHCP[$i]}" = "yes" ]; then # use DHCP to bring interface up
- [ ${DHCP_HOSTNAME[$i]} ] && DHCP_OPTIONS="-h ${DHCP_HOSTNAME[$i]}"
- [ "${DHCP_KEEPRESOLV[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -C resolv.conf"
- [ "${DHCP_KEEPNTP[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -C ntp.conf"
- [ "${DHCP_KEEPGW[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -G"
- [ "${DHCP_DEBUG[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -d"
- [ "${DHCP_NOIPV4LL[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -L"
- [ ${DHCP_IPADDR[$i]} ] && DHCP_OPTIONS="$DHCP_OPTIONS -r ${DHCP_IPADDR[$i]}"
+ [ ${DHCP_HOSTNAME[$i]} ] && DHCP_OPTIONS[$i]="-h ${DHCP_HOSTNAME[$i]}"
+ [ "${DHCP_KEEPRESOLV[$i]}" = "yes" ] && DHCP_OPTIONS[$i]="${DHCP_OPTIONS[$i]} -C resolv.conf"
+ [ "${DHCP_KEEPNTP[$i]}" = "yes" ] && DHCP_OPTIONS[$i]="${DHCP_OPTIONS[$i]} -C ntp.conf"
+ [ "${DHCP_KEEPGW[$i]}" = "yes" ] && DHCP_OPTIONS[$i]="${DHCP_OPTIONS[$i]} -G"
+ [ "${DHCP_DEBUG[$i]}" = "yes" ] && DHCP_OPTIONS[$i]="${DHCP_OPTIONS[$i]} -d"
+ [ "${DHCP_NOIPV4LL[$i]}" = "yes" ] && DHCP_OPTIONS[$i]="${DHCP_OPTIONS[$i]} -L"
+ [ ${DHCP_IPADDR[$i]} ] && DHCP_OPTIONS[$i]="${DHCP_OPTIONS[$i]} -r ${DHCP_IPADDR[$i]}"
echo "Polling for DHCP server on interface ${1}:"
# If you set a timeout, you get one, even if the kernel doesn't think that
# your device is connected, in case /sys isn't right (which it usually isn't
@@ -132,8 +132,8 @@
#fi
#### (end commented out)
# 10 seconds should be a reasonable default DHCP timeout. 30 was too much.
- echo "/etc/rc.d/rc.inet1: /sbin/dhcpcd -t ${DHCP_TIMEOUT[$i]:-10} ${DHCP_OPTIONS} ${1}" | $LOGGER
- /sbin/dhcpcd -t ${DHCP_TIMEOUT[$i]:-10} ${DHCP_OPTIONS} ${1}
+ echo "/etc/rc.d/rc.inet1: /sbin/dhcpcd -t ${DHCP_TIMEOUT[$i]:-10} ${DHCP_OPTIONS[$i]} ${1}" | $LOGGER
+ /sbin/dhcpcd -t ${DHCP_TIMEOUT[$i]:-10} ${DHCP_OPTIONS[$i]} ${1}
else # bring up interface using a static IP address
if [ ! "${IPADDR[$i]}" = "" ]; then # skip unconfigured interfaces
# Determine broadcast address from the IP address and netmask:
 
Old 06-12-2012, 04:32 AM   #2
FeyFre
Member
 
Registered: Jun 2010
Location: Ukraine, Vinnitsa
Distribution: Slackware
Posts: 308

Rep: Reputation: 22
You did a lot of unnecessary changes. It was enough to add line `DHCP_OPTIONS=""` right after `if [ "${USE_DHCP[$i]}" = "yes" ]; then # use DHCP to bring interface up` condition check. There is no reason to save each option. It will be never used.
 
1 members found this post helpful.
Old 06-12-2012, 05:23 AM   #3
XGizzmo
Member
 
Registered: Mar 2007
Distribution: Slackware
Posts: 264

Rep: Reputation: 68
FayFre is 100% correct, DHCP_OPTIONS just needs to be cleared out for each iteration of the loop.
 
Old 06-20-2012, 07:31 AM   #4
irfan.acar
LQ Newbie
 
Registered: Jun 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
Different strokes for different folks... Although clearing DHCP_OPTIONS in if_up() is sufficient, I prefer to use an array to emphasize that each network interface has its own DHCP options.

-irfan
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting up a DHCP server with multiple network interfaces - Debian Srz0rz Linux - Networking 5 06-09-2011 12:33 AM
Debian, dhcp, and 2+ network interfaces chrisrees Linux - Newbie 3 02-15-2008 04:39 AM
Multiple, simultaneous network interfaces indienick Linux - Networking 4 07-31-2006 11:33 AM
Manually specify network interfaces for DHCP NetAX Linux - Networking 1 04-22-2004 05:03 AM
Virtual network interfaces that use dhcp titakker Linux - Networking 1 09-23-2003 01:10 AM


All times are GMT -5. The time now is 04:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration