Hello, 2011/10/2 Ireneusz Szcześniak <irek.szczesn...@gmail.com>: > Hi, > > I'm planning to install an image of Debian to a number of computers. Each of > these computers will have the same configuration except the hostname and the > IP address. The IP configuration has to be static. I can't use a DHCP > server. > > QUESTION; Is there a way to assign a hostname and a static IP address at > boot time depending on the MAC address of the computer's network interface > card? If you know which macs you will have, you can make an init script which generate /etc/network/interface and /etc/hostname and /etc/hosts the first boot and then remove itself.
Imagine: $ cat /etc/machines mac1 ip1 hostname1 .... macN ipN hostname N $ cat /etc/init.d/10setnetworkonlyfirstboot #!/bin/bash mymac=$(ip add show dev eth0 | awk '/ether/ {print $2}') myhost=$(awk "/$mymac/ {print \$3}") myip=$(awk "/$mymac/ {print \$2}") sed -i "s/IP/$myip" /etc/network/interfaces # and probably some changes in /etc/hosts sed -i "s/HOSTNAME/$myhost" /etc/hostname # and probably some changes in /etc/hosts rm -f /etc/init.d/10setnetworkonlyfirstboot $ cat /etc/network/interfaces auto eth0 iface eth0 inet static address IP network xxx gateway yyy $ cat /etc/hostname HOSTNAME Do you think this is a good approach ? It is not very elegant, but maybe it works. Regards, -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/CAL5yMZS7LCV89=epUiVV1b8E_0=obzp7w87nbeydfgwuqj9...@mail.gmail.com