martes, diciembre 05, 2006

wifi con dhcpcd

Primero instalamos la paquete Dhcpcd-2.0.8.

tar xf dhcpcd-2.0.8.tar.bz2
cd dhcpcd-2.0.8
./configure --prefix="/usr/local/dhcp"
make
make install

Luego en /etc/sysconfig/network-devices/services creamos el fichero dhcpcd:
# Based upon lfs-bootscripts-1.12 $network_devices/if{down,up}
# Rewritten by Nathan Coulson
# Adapted for dhcpcd by DJ Lucas

#$LastChangedBy: dnicholson $
#$Date: 2006-10-01 13:07:56 -0500 (Sun, 01 Oct 2006) $

. /etc/sysconfig/rc
. $rc_functions
. $IFCONFIG


DAEMON="/usr/local/dhcp/sbin/dhcpcd"

PIDFILE="/var/run/dhcpcd-$1.pid"
LEASEINFO="/var/lib/dhcpc/dhcpcd-$1.info"

case "$2" in
up)
boot_mesg -n "Starting dhcpcd on the $1 interface..."
# Test to see if there is a stale pid file
if [ -f "$PIDFILE" ]
then
ps `cat "$PIDFILE"` | grep dhcpcd > /dev/null
if [ $? != 0 ]
then
rm -f /var/run/dhcpcd-$1.pid > /dev/null
else
boot_mesg "dhcpcd already running!" ${WARNING}
echo_warning
exit 2
fi
fi
$DAEMON $1 $DHCP_START
# Save the return value
RET="$?"
# Print the assigned settings if requested
if [ "$RET" = "0" -a "$PRINTIP" = "yes" ]; then
. /var/lib/dhcpc/dhcpcd-$1.info
if [ "$PRINTALL" = "yes" ]; then
echo ""
echo_ok
boot_mesg " DHCP Assigned Settings for $1:"
boot_mesg_flush
boot_mesg " IP Address: $IPADDR"
boot_mesg_flush
boot_mesg " Subnet Mask: $NETMASK"
boot_mesg_flush
boot_mesg " Default Gateway: $GATEWAY"
boot_mesg_flush
boot_mesg " DNS Server: $DNS"
boot_mesg_flush
else
boot_mesg " IP Addresss: ""$IPADDR"
echo_ok
fi
else
echo ""
$(exit "$RET")
evaluate_retval
fi
;;

down)
boot_mesg -n "Stopping dhcpcd on the $1 interface..."
# Do nothing with the client daemon if we have an infinate
# lease time as the client exits when started in this case,
# just echo OK.
if [ -e $LEASEINFO ]
then
. $LEASEINFO

if [ "$LEASETIME" = "4294967295" ]
then
# do nothing, just echo ok
echo ""
echo_ok
else
if [ -n "$DHCP_STOP" ]
then
$DAEMON $1 $DHCP_STOP &> /dev/null
RET="$?"
if [ "$RET" -eq 0 ]; then
echo ""
echo_ok
elif [ "$RET" -eq 1 ]; then
boot_mesg "dhcpcd not running!" ${WARNING}
echo_warning
else
echo ""
echo_failure
fi
else
echo ""
killproc dhcpcd
fi
fi
else
boot_mesg -n "LEASEINFO Test failed! - " ${WARNING}
boot_mesg "dhcpcd is not running!" ${WARNING}
echo_warning
exit 1
fi
;;

*)
echo "Usage: $0 [interface] {up|down}"
exit 1
;;
esac

# End $network_devices/services/dhcpcd

chmod 755 dhcpcd

Luego en /etc/sysconfig/network-devices/ifconfig.eth1 (nuestra interfaz wifi) creamos el fichero dhcpcd:
ONBOOT="no"
SERVICE="dhcpcd"
DHCP_START=""
DHCP_STOP="-k"

# Set PRINTIP="yes" to have the script print
# the DHCP assigned IP address
PRINTIP="yes"

# Set PRINTALL="yes" to print the DHCP assigned values for
# IP, SM, DG, and 1st NS. This requires PRINTIP="yes".
PRINTALL="yes"

y levantamos el interfaz: /etc/sysconfig/network-devices/ifup eth1

No hay comentarios: