[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: DNS-DHCP solution for linux?



I'm not quite sure what you mean.  For me, dhcpcd does assign a DNS server
via the /etc/dhcp/resolv.conf which it generates.  However, it does not
update several other things I would like it to and it does change some
things I would like it to leave alone. In order to update these things, I
use the dhcpcd -c option in /etc/init.d/dhcpc like this:

"start-stop-daemon --start --quiet --exec $DAEMON -- -c /etc/dhcpc/fix_netstuff $IFACE"

I have included my fix_netstuff script.  It updates various things, maybe
it will be a help to someone.  It is set up for _my_ computer, you'll have
to alter it if you mean to use it.  It is fairly sloppy, I'm no shell
script master.

Eric.

 On Tue, 1 Dec 1998, Ben Jorgensen wrote:

> Is there any such? It would be nice not having to update the DNS server by
> hand all the time. And using DHCP to assign IP:s automatically could solve
> this if there was a tool for updating the DNS server.
> 
> //ben
> -- 
> http://surf.to/anTiX
> 
> 
> -- 
> Unsubscribe?  mail -s unsubscribe debian-user-request@lists.debian.org < /dev/null
> 
#!/bin/sh

TIMESERVR=`grep TIMESERVR /etc/dhcpc/hostinfo-eth0 | awk -F'=' '{print $2;}'` > /etc/dhcpc/resolv.conf
echo $TIMESERVR
IPADDR=`grep IPADDR /etc/dhcpc/hostinfo-eth0 | awk -F'=' '{print $2;}'`
echo $IPADDR
NETMASK=`grep NETMASK /etc/dhcpc/hostinfo-eth0 | awk -F'=' '{print $2;}'`
echo $NETMASK
NETWORK=`grep IPADDR /etc/dhcpc/hostinfo-eth0 | awk -F'=' '{print $2;}' | awk -F'.' -v OFS='.' '{print $1, $2, $3, 0}'`
echo $NETWORK
BROADCAST=`grep BROADCAST /etc/dhcpc/hostinfo-eth0 | awk -F'=' '{print $2;}'`
echo $BROADCAST
ROUTER=`grep ROUTER /etc/dhcpc/hostinfo-eth0 | awk -F'=' '{print $2;}'`
echo $ROUTER

## Fix that damn dhcpc assigned hostname
hostname `cat /etc/hostname`

## Fix that damn dhcpc assigned resolv.conf
echo "nameserver $TIMESERVR" > /etc/dhcpc/resolv.conf
echo '' >> /etc/dhcpc/resolv.conf
echo 'domain ml.org' >> /etc/dhcpc/resolv.conf
echo 'search iit.edu' >> /etc/dhcpc/resolv.conf

## Fix /etc/hosts to reflect current IP
echo "`grep -v "127.0.0.1" /etc/hosts | grep -v goomba`" > /etc/hosts
echo '127.0.0.1 localhost loopback' >> /etc/hosts
echo "$IPADDR goomba" >> /etc/hosts

## Fix /etc/init.d/network to reflect dhcp-gotten settings
echo '#! /bin/sh' > /etc/init.d/network
echo 'ifconfig lo 127.0.0.1' >> /etc/init.d/network
echo 'route add -net 127.0.0.0' >> /etc/init.d/network
echo "IPADDR=$IPADDR" >> /etc/init.d/network
echo "NETMASK=$NETMASK" >> /etc/init.d/network
echo "NETWORK=$NETWORK" >> /etc/init.d/network
echo "BROADCAST=$BROADCAST" >> /etc/init.d/network
echo "GATEWAY=$ROUTER" >> /etc/init.d/network
echo 'ifconfig eth0 ${IPADDR} netmask ${NETMASK} broadcast ${BROADCAST}' >> /etc/init.d/network
echo 'route add -net ${NETWORK}' >> /etc/init.d/network
echo '[ "${GATEWAY}" ] && route add default gw ${GATEWAY} metric 1' >> /etc/init.d/network

## Fix /etc/networks to reflect dhcp-gotten settings
echo `grep -v localnet /etc/networks` > /etc/networks
echo "localnet $NETWORK" >> /etc/networks

## Fix /etc/hosts.allow to reflect dhcp-gotten settings
echo `cat /etc/hosts.allow | grep -v "portmap:"` > /etc/hosts.allow
echo "portmap: $NETWORK/$NETMASK" >> /etc/hosts.allow

Reply to: