You are not logged in.

#1 2011-09-16 19:04:36

3do
Member
Registered: 2011-09-11
Posts: 9

[SOLVED] dhcpcd failure

i can connect to the internet with a static ip. But when i use the dhcp it's not possible to get an ip address.(wired connection)
My modem is ZyXell P660W-TX. I thing there is a senseless situation.

Output of dhcpcd command
hardware address 0b:b3:f8:b1:8b:bb is MAC of the modem.(!)

 
[root@archlinux alper]# dhcpcd
dhcpcd[1681]: version 5.2.12 starting
dhcpcd[1681]: eth0: broadcasting for a lease
dhcpcd[1681]: eth0: offered 192.168.1.35 from 192.168.1.1 `P660W-TX'
dhcpcd[1681]: eth0: acknowledged 192.168.1.35 from 192.168.1.1 `P660W-TX'
dhcpcd[1681]: eth0: checking for 192.168.1.35
dhcpcd[1681]: eth0: hardware address 0b:b3:f8:b1:8b:bb claims 192.168.1.35
dhcpcd[1681]: eth0: broadcasting for a lease
dhcpcd[1681]: eth0: offered 192.168.1.33 from 192.168.1.1 `P660W-TX'
dhcpcd[1681]: eth0: acknowledged 192.168.1.33 from 192.168.1.1 `P660W-TX'
dhcpcd[1681]: eth0: checking for 192.168.1.33
dhcpcd[1681]: eth0: hardware address 0b:b3:f8:b1:8b:bb claims 192.168.1.33
dhcpcd[1681]: eth0: broadcasting for a lease
dhcpcd[1681]: eth0: offered 192.168.1.34 from 192.168.1.1 `P660W-TX'
dhcpcd[1681]: eth0: acknowledged 192.168.1.34 from 192.168.1.1 `P660W-TX'
dhcpcd[1681]: eth0: checking for 192.168.1.34
dhcpcd[1681]: eth0: hardware address0b:b3:f8:b1:8b:bb claims 192.168.1.34
dhcpcd[1681]: timed out
dhcpcd[1681]: forked to background, child pid 1701
[root@archlinux alper]# 

rc.conf

#
# /etc/rc.conf - Main Configuration for Arch Linux
#

# -----------------------------------------------------------------------
# LOCALIZATION
# -----------------------------------------------------------------------
#
# LOCALE: available languages can be listed with the 'locale -a' command
# DAEMON_LOCALE: If set to 'yes', use $LOCALE as the locale during daemon
# startup and during the boot process. If set to 'no', the C locale is used.
# HARDWARECLOCK: set to "", "UTC" or "localtime", any other value will result
#   in the hardware clock being left untouched (useful for virtualization)
#   Note: Using "localtime" is discouraged, using "" makes hwclock fall back
#   to the value in /var/lib/hwclock/adjfile
# TIMEZONE: timezones are found in /usr/share/zoneinfo
#   Note: if unset, the value in /etc/localtime is used unchanged
# KEYMAP: keymaps are found in /usr/share/kbd/keymaps
# CONSOLEFONT: found in /usr/share/kbd/consolefonts (only needed for non-US)
# CONSOLEMAP: found in /usr/share/kbd/consoletrans
# USECOLOR: use ANSI color sequences in startup messages
#
LOCALE="en_US.UTF-8"
DAEMON_LOCALE="no"
HARDWARECLOCK="UTC"
TIMEZONE="Europe/Istanbul"
KEYMAP="trq"
CONSOLEFONT=
CONSOLEMAP=
USECOLOR="yes"

# -----------------------------------------------------------------------
# HARDWARE
# -----------------------------------------------------------------------
#
# MODULES: Modules to load at boot-up. Blacklisting is no longer supported.
#   Replace every !module by an entry as on the following line in a file in
#   /etc/modprobe.d:
#     blacklist module
#   See "man modprobe.conf" for details.
#
MODULES=()

# Udev settle timeout (default to 30)
UDEV_TIMEOUT=30

# Scan for FakeRAID (dmraid) Volumes at startup
USEDMRAID="no"

# Scan for BTRFS volumes at startup
USEBTRFS="no"

# Scan for LVM volume groups at startup, required if you use LVM
USELVM="no"

# -----------------------------------------------------------------------
# NETWORKING
# -----------------------------------------------------------------------
#
# HOSTNAME: Hostname of machine. Should also be put in /etc/hosts
#
HOSTNAME="archlinux"

# Use 'ip addr' or 'ls /sys/class/net/' to see all available interfaces.
#
# Wired network setup
#   - interface: name of device (required)
#   - address: IP address (leave blank for DHCP)
#   - netmask: subnet mask (ignored for DHCP) (optional, defaults to 255.255.255.0)
#   - broadcast: broadcast address (ignored for DHCP) (optional)
#   - gateway: default route (ignored for DHCP)
# 
# Static IP example
# interface=eth0
# address=192.168.0.2
# netmask=255.255.255.0
# broadcast=192.168.0.255
# gateway=192.168.0.1
#
# DHCP example
# interface=eth0
# address=
# netmask=
# gateway=

interface=eth0
address=
netmask=
broadcast=
gateway=

# Setting this to "yes" will skip network shutdown.
# This is required if your root device is on NFS.
NETWORK_PERSIST="no"

# Enable these netcfg profiles at boot-up. These are useful if you happen to
# need more advanced network features than the simple network service
# supports, such as multiple network configurations (ie, laptop users)
#   - set to 'menu' to present a menu during boot-up (dialog package required)
#   - prefix an entry with a ! to disable it
#
# Network profiles are found in /etc/network.d
#
# This requires the netcfg package
#
#NETWORKS=(main)

# -----------------------------------------------------------------------
# DAEMONS
# -----------------------------------------------------------------------
#
# Daemons to start at boot-up (in this order)
#   - prefix a daemon with a ! to disable it
#   - prefix a daemon with a @ to start it up in the background
#
# If something other takes care of your hardware clock (ntpd, dual-boot...)
# you should disable 'hwclock' here.
#
DAEMONS=(hwclock syslog-ng network netfs crond dbus @alsa gdm @httpd @mysqld networkmanager)

Last edited by 3do (2011-09-17 10:09:43)

Offline

#2 2011-09-16 20:32:53

3do
Member
Registered: 2011-09-11
Posts: 9

Re: [SOLVED] dhcpcd failure

i fixed the problem myself. I used a different dhcp client. (dhclient)

i changed the /etc/rc.d/network file and it's fine now. (tested on wired and wireless connection)

first install dhclient and then edit /etc/rc.d/network. Change the all 'dhcpcd' -> 'dhclient' with CRTL + H smile (i'm not kidding)

#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

for s in wireless bonding bridges dhclient; do
	[[ -f /etc/conf.d/$s ]] && . "/etc/conf.d/$s"
done

# helper function to determine if legacy network support is needed
need_legacy() {
	# complain when `interface' is unset and `INTERFACES' has profiles enabled
	if [[ -z $interface && ${INTERFACES[@]##!*} ]]; then
		return 0 # need legacy
	fi

	return 1 # enough present for iproute2 support
}

deprecated() {
	printf "${C_FAIL}Warning:${C_CLEAR} Your network settings are deprecated.\n"
	printf "  Please refer to /etc/rc.conf on how to define a single wired\n"
	printf "  connection, or use a utility such as netcfg.\n"
}

network_up() {
	ip link set dev $interface up || return 1

	if [[ $address ]]; then
		ip addr add $address/${netmask:-24} broadcast ${broadcast:-+} dev $interface || return 1
		[[ $gateway ]] && { ip route add default via $gateway || return 1; }
	else
		dhclient $DHCPCD_ARGS $interface || return 1
	fi
}

network_down() {
	if [[ -f /var/run/dhclient-$interface.pid ]]; then
		dhclient -k $interface || return 1
	else
		ip addr flush dev $interface || return 1
	fi

	ip link set dev $interface down || return 1
}

ifup() {
	local ifcfg=${!1}

	if [[ ! $1 ]]; then
		echo "usage: $0 ifup <interface_name>"
		return 1
	fi

	# Get the name of the interface from the first token in the string
	if [[ $ifcfg = dhcp ]]; then
		ifname=$1
	else
		ifname=${ifcfg%% *}
	fi

	ifconfig $ifname up

	wi_up $1 || return 1

	if [[ $ifcfg = dhcp ]]; then
		# remove the .pid file if it exists
		rm -f /var/run/dhclient-${1}.pid >/dev/null 2>&1
		rm -f /var/run/dhclient-${1}.cache >/dev/null 2>&1
		dhclient $DHCPCD_ARGS ${1}
	else
		ifconfig $ifcfg
	fi
}

wi_up() {
	local iwcfg=wlan_$1

	[[ ${!iwcfg} ]] || return 0

	iwconfig ${!iwcfg}
	[[ $WIRELESS_TIMEOUT ]] || WIRELESS_TIMEOUT=2
	sleep $WIRELESS_TIMEOUT

	bssid=$(iwgetid $1 -ra)
	if [[ $bssid = 00:00:00:00:00:00 ]]; then
		printhl "Could not associate $1 - try increasing WIRELESS_TIMEOUT and check network is WEP or has no security"
		return 1
	fi
	return 0
}

ifdown() {
	local ifcfg=${!1}

	if [[ ! $1 ]]; then
		echo "usage: $0 ifdown <interface_name>"
		return 1
	fi

	if [[ $ifcfg = dhcp && -f /var/run/dhclient-${1}.pid ]]; then
		dhclient -k ${1} >/dev/null 2>&1
	fi
	# Always bring the interface itself down
	ifconfig ${1} down >/dev/null 2>&1
}

iflist() {
	for ifline in ${INTERFACES[@]}; do
		if [[ $ifline = ${ifline#!} ]]; then
			printf " $ifline:\t"
		else
			printf "$ifline:\t"
		fi
		echo ${!ifline#!}
	done
}

rtup() {
	local routecfg=${!1}

	if [[ ! $1 ]]; then
		echo "usage: $0 rtup <route_name>"
		return 1
	fi

	if [[ $routecfg =~ :: ]]; then
		route -A inet6 add $routecfg
	else
		route add $routecfg
	fi
}

rtdown() {
	local routecfg=${!1}

	if [[ ! $1 ]]; then
		echo "usage: $0 rtdown <route_name>"
		return 1
	fi

	if [[ $routecfg =~ :: ]]; then
		route -A inet6 del $routecfg
	else
		route del $routecfg
	fi
}

rtlist() {
	for rtline in ${ROUTES[@]}; do
		if [[ $rtline = ${rtline#!} ]]; then
			printf " $rtline:\t"
		else
			printf "$rtline:\t"
		fi
		echo ${!rtline#!}
	done
}

bond_up() {
	for ifline in ${BOND_INTERFACES[@]}; do
		if [[ $ifline = ${ifline#!} ]]; then
			bondcfg="bond_$ifline"
			if [[ ${!bondcfg} ]]; then
				ifenslave $ifline ${!bondcfg} || error=1
			fi
		fi
	done
}

bond_down() {
	for ifline in ${BOND_INTERFACES[@]}; do
		if [[ $ifline = ${ifline#!} ]]; then
			bondcfg="bond_$ifline"
			ifenslave -d $ifline ${!bondcfg} || error=1
		fi
	done
}

bridge_up() {
	for br in ${BRIDGE_INTERFACES[@]}; do
		if [[ $br = ${br#!} ]]; then
			# if the bridge already exists, remove it
			if [[ $(ifconfig $br 2>/dev/null) ]]; then
				ifconfig $br down
				brctl delbr $br
			fi
			brctl addbr $br
			brifs="bridge_$br"
			for brif in ${!brifs}; do
				if [[ $brif = ${brif#!} ]]; then
					for ifline in ${BOND_INTERFACES[@]}; do
						if [[ $brif = $ifline && $ifline = ${ifline#!} ]]; then
							ifup $ifline
							bondcfg="bond_$ifline"
							ifenslave $ifline ${!bondcfg} || error=1
							unset bond_$ifline
						fi
					done

					brctl addif $br $brif || error=1
				fi
			done
		fi
	done
}

bridge_down() {
	for br in ${BRIDGE_INTERFACES[@]}; do
		if [[ $br = ${br#!} ]]; then
			brctl delbr $br
		fi
	done
}


case "$1" in
	start)
		# deprecation check
		need_legacy && deprecated
		if ! ck_daemon network; then
			echo "Network is already running.  Try 'network restart'"
			exit
		fi
		stat_busy "Starting Network"
		error=0
		if need_legacy; then
			# bring up bridge interfaces
			bridge_up
			# bring up ethernet interfaces
			for ifline in ${INTERFACES[@]}; do
				if [[ $ifline = ${ifline#!} ]]; then
					ifup $ifline || error=1
				fi
			done
			# bring up bond interfaces
			bond_up
			# bring up routes
			for rtline in "${ROUTES[@]}"; do
				if [ "$rtline" = "${rtline#!}" ]; then
					rtup $rtline || error=1
				fi
			done
		else
			network_up
		fi
		if ((error == 0)); then
			add_daemon network
			stat_done
		else
			stat_fail
		fi
		;;
	stop)
		# deprecation check
		need_legacy && deprecated
		if [[ $NETWORK_PERSIST =~ yes|YES && $RUNLEVEL == [06] ]]; then
			status "Skipping Network Shutdown" true
			exit 0
		fi

		stat_busy "Stopping Network"
		rm_daemon network
		error=0
		if need_legacy; then
			for rtline in "${ROUTES[@]}"; do
				if [[ $rtline = ${rtline#!} ]]; then
					rtdown $rtline || error=1
				fi
			done
			# bring down bond interfaces
			bond_down
			for ifline in ${INTERFACES[@]}; do
				if [[ $ifline = ${ifline#!} ]]; then
					ifdown $ifline || error=1
				fi
			done
			# bring down bridge interfaces
			bridge_down
		else
			network_down
		fi
		if ((error == 0)); then
			stat_done
		else
			stat_fail
		fi
		;;
	restart)
		$0 stop
		sleep 2
		$0 start
		;;
	ifup|ifdown|iflist|rtup|rtdown|rtlist)
		# deprecation check
		deprecated
		$1 $2
		;;
	*)
		echo "usage: $0 {start|stop|restart}"
		echo "       $0 {ifup|ifdown|iflist|rtup|rtdown|rtlist}";;
esac

# vim: set ts=2 sw=2 noet:

dhcpcd may has a logical error. i'don't know.

Offline

#3 2011-09-16 21:09:42

the sad clown
Member
From: 192.168.0.X
Registered: 2011-03-20
Posts: 837

Re: [SOLVED] dhcpcd failure

That seems to be a common theme recently, that dhclient is working better than dhcpcd.  I'm still using dhcpcd because I haven't had any problem with it, but there does seem to be a significant number of people for whom the switch has proven to be a solution.

Last edited by the sad clown (2011-09-16 21:10:30)


I laugh, yet the joke is on me

Offline

Board footer

Powered by FluxBB