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

Re: Getting hostname

On Thu Feb 14 2002 at 17:34, seth vidal wrote:

> Content-Type: text/plain
> Content-Transfer-Encoding: quoted-printable

Gnargh!  I *hate* quoted-UNprintable!!!!  (ugliness that appeard
below fixed)

> On Thu, 2002-02-14 at 17:23, Richard Wilson wrote:
> > Does someone know off hand how I can get the hostname during a kickstart
> > build, within the %post section.
> > I'm setting static IP's and the hostnames will be in the DNS table.
> ip=`/sbin/ifconfig eth0 |grep 'inet addr' |awk {'print $2;'}|cut -c 6-`
> hostname=`/usr/bin/host $ip|cut -d ' ' -f5 | cut -d. -f1`

/sbin/ifconfig is now obselete, has been since the introduction of
the 2.2.x kernels.

There are many ways to do this sort of thing, and I would suggest
doing it like this:

ip=$(/sbin/ip -o a s dev eth0 | grep inet | awk '{print $4}' | cut -d/ -f1)
hostname=$(host $ip | sed -e 's,^.* pointer \(.*\)\.$,\1,')

The new networking configuration tool is /sbin/ip -- and it is a
VERY powerful utility!  With it you have almost total control over
all aspects of your network configuration, including arp, routing,
addresses, device states, routing **RULES** (very powerful!!),
ip tunnels and so on.  "/sbin/ip help" and you'll start to get an
idea what is capable of.  "/sbin/ip address help" and "/sbin/ip
route help" (or "ip r h") will be even more revealing.

ifconfig can only do a fraction of what /sbin/ip allows you to do.

Go get the advanced routing howto and find out what you are missing
out on.


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