[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openbsd-misc
Subject:    Fwd: netbooting OpenBSD (6.0) i386 and amd64 clients from one server
From:       Sven-Volker Nowarra <peb.nowarra () bluewin ! ch>
Date:       2017-01-30 1:58:37
Message-ID: DF55DE93-1A21-4C59-88CD-CE923F3A926F () bluewin ! ch
[Download RAW message or body]

>> ...
>>
>> $ ./tftpd_rewrite
>> $ doas chgrp _tftpd /tmp/tftpd_rewrite.sock ; doas chmod g+w
/tmp/tftpd_rewrite.sock
>> $ doas tftpd -v -r /tmp/tftpd_rewrite.sock /home/vm
>>
>> $ tftp 127.0.0.1
>> tftp> get /etc/boot.conf
>> Received 38 bytes in 0.0 seconds
>>
>> $ syslogc daemon | tail -n1
>> Jan 29 01:51:49 t440s tftpd[626]: 127.0.0.1: read request for
'/etc/boot.conf'
>> $ cat boot.conf
>> set tty com0
>> boot tftp:/bsd.rd.i386
>
> nice proof of concept :-)
> thx! works well with OpenBSD's tftpd.
> Same logic does not apply to in.tftpd or atftpd. I had copied the OpenBSD
"pxeboot" (amd64 and i386, they differ a bit) to my Linux box. As you can see
in the second line, the requested filename "boot.conf" has no additional IP
address or MAC to filter on:
>
>  in.tftpd[2131]: RRQ from 192.168.88.253 filename /i386/bsd60_i386_pxeboot
>> in.tftpd[2132]: remap: input: /etc/boot.conf
>  in.tftpd[2132]: remap: done
>  in.tftpd[2132]: RRQ from 192.168.88.253 filename /etc/boot.conf
>  in.tftpd[2133]: remap: input: /etc/random.seed
>  in.tftpd[2133]: remap: done
>  in.tftpd[2133]: RRQ from 192.168.88.253 filename /etc/random.seed
>  in.tftpd[2133]: sending NAK (1, File not found) to 192.168.88.253
>  in.tftpd[2134]: remap: input: /bsd
>  in.tftpd[2134]: remap: done
>  in.tftpd[2134]: RRQ from 192.168.88.253 filename /bsd
>  in.tftpd[2134]: sending NAK (1, File not found) to 192.168.88.253
>
> This way, when creating a remapping based on the raw filename, it would
apply to i386 and amd64.
> Anyhow, I will update my doc with the solution for OpenBSD. Already a good
step forwards.
> At the same time I will also update with Anton's remark for a dual server.
>

I am wrong! I have played around with in.tftpd. I could get my OpenBSD systems
to properly netboot i386 and amd64 in the same network segment. Here is all
the configs I used, to achieve OpenBSD clients booting from in.tftpd and it's
"filename remapping":

/etc/hosts:
192.168.88.253 mvbcxfw1.svn.localdomain mvbcxfw1
192.168.88.254 mvbcxfw2.svn.localdomain mvbcxfw2

/etc/tftp.remap:
r /etc/boot.conf /etc/boot.conf.\i

This translates into: for all requests [r] that come with a filename
"/etc/boot.conf" replace it with the filename "/etc/boot.conf" and
attach a dot and the IP address of the tftpd requesting client [\i]. (man
in.tftpd)

/etc/dhcpd.conf
...
group {
  filename "/pxeboot";
  next-server 192.168.88.8;
  host mvbcxfw1 {
    option host-name "mvbcxfw1";
    hardware ethernet 00:47:11:12:01:27;
    fixed-address mvbcxfw1;
  }
  host mvbcxfw2 {
    option host-name "mvbcxfw2";
    hardware ethernet 00:47:11:12:01:28;
    fixed-address mvbcxfw2;
  }
}

I created two files in the /srv/tftpboot/etc/ directory:

/srv/tftpboot/etc/boot.conf.192.168.88.253:
echo #####
echo ##### in.tftpd greetings to client 192.168.88.253
echo #####
boot /i386/bsd60_i386_bsd.rd

/srv/tftpboot/etc/boot.conf.192.168.88.254:
echo #####
echo ##### in.tftpd greetings to client 192.168.88.254
echo #####
boot /amd64/bsd60_amd64_bsd.rd

I then start the xinetd, with the in.tftpd activated. The config file
/etc/xinetd.d/tftp:
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
group = tftp
server = /usr/sbin/in.tftpd
server_args = -m /etc/tftpd.remap -vvv -s /srv/tftpboot
}

Alternativly, one can also do a manual start:
/usr/sbin/in.tftpd -l -m /etc/tftpd.remap -vvv -s /srv/tftpboot

I boot my first i386 client, and see this in journalctl -f
/usr/sbin/in.tftpd:
  Jan 30 02:04:33 mleap42ix in.tftpd[4125]: remap: input: /pxeboot
  Jan 30 02:04:33 mleap42ix in.tftpd[4125]: remap: done
  Jan 30 02:04:33 mleap42ix in.tftpd[4125]: RRQ from 192.168.88.253 filename
/pxeboot
  Jan 30 02:04:33 mleap42ix in.tftpd[4126]: remap: input: /etc/boot.conf
  Jan 30 02:04:33 mleap42ix in.tftpd[4126]: remap: rule 0: rewrite:
/etc/boot.conf.192.168.88.253
  Jan 30 02:04:33 mleap42ix in.tftpd[4126]: remap: done
  Jan 30 02:04:33 mleap42ix in.tftpd[4126]: RRQ from 192.168.88.253 filename
/etc/boot.conf remapped to /etc/boot.conf.192.168.88.253
...
  Jan 30 02:04:33 mleap42ix in.tftpd[4128]: remap: input:
/i386/bsd60_i386_bsd.rd
  Jan 30 02:04:33 mleap42ix in.tftpd[4128]: remap: done
  Jan 30 02:04:33 mleap42ix in.tftpd[4128]: RRQ from 192.168.88.253 filename
/i386/bsd60_i386_bsd.rd

Line number 5 and line number 7 show the change. So with this one can define a
per IP address config file, and define in the boot.conf .<IP> whichever kernel
we want to boot. The equivalent result for the amd64 client would show the
remapping, and boot the amd64 kernel.

rgds,
Volker

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic