Hi, I am trying to do this thing useing my shell bash ( sorry for my english )
I have in a file 63 hostnames, i wanna ask to the DHCP admin, to reserv that reserves 63 IP addresses of this hosts, using their mac address.
I have thinked this script:
for ((i=1;i<63;i++)); do
arp $(head -n $i host.txt |tail -n 1) | awk '/Cyp/ {$1 $3}' > host_mac.txt
done;
This are my trys:
Cypuysrv456:~# head -n 1 host.txt |tail -n 1
CypUYNB106
Cypuysrv456:~# ping $(head -n 1 host.txt |tail -n 1)
ping: unknown host CypUYNB106
Cypuysrv456:~# ping CypUYNB106
PING CypUYNB106.hh.Cyp.com (172.Z.X.Y) 56(84) bytes of data.
64 bytes from Cypuynb106.hh.Cyp.com (172.Z.X.Y): icmp_seq=1 ttl=128 time=0.333 ms
64 bytes from Cypuynb074.hh.Cyp.com (172.Z.X.Y): icmp_seq=2 ttl=128 time=0.276 ms
^C
--- CypUYNB106.hh.Cyp.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.276/0.304/0.333/0.033 ms
Cypuysrv456:~#
I'll explain:
Cypuysrv456:~# head -n 1 host.txt |tail -n 1
CypUYNB106
I get the names of the file and the system returns one by one the hostnames
Cypuysrv456:~# ping $(head -n 1 host.txt |tail -n 1)
ping: unknown host CypUYNB106
Dam! it does not recognize the host, maybe the system it can not resolve the hostname.
Cypuysrv456:~# ping CypUYNB106
PING CypUYNB106.hh.Cyp.com (172.Z.X.Y) 56(84) bytes of data.
64 bytes from Cypuynb106.hh.Cyp.com (172.Z.X.Y): icmp_seq=1 ttl=128 time=0.333 ms
64 bytes from Cypuynb074.hh.Cyp.com (172.Z.X.Y): icmp_seq=2 ttl=128 time=0.276 ms
^C
--- CypUYNB106.hh.Cyp.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.276/0.304/0.333/0.033 ms
he could resolve it. :S
� Why not before ?
I change in the file, the hostname with the completely hostname, but no fortune.
Since some days ago i have joined this machine to the domain ( active directory ) this is a gnu/linux server.
� Any idea why the system coud not resolve the name ?
# cat /etc/resolv.conf
domain hh.Cyp.com
search hh.Cyp.com
nameserver 172.Z.X.F
nameserver 172.Z.W.R
Regards,