# iSCSI connection error on FreeBSD 12.2



## Giteh (Jan 19, 2021)

Hi,

So I've got FreeBSD with configured iSCSI server which is serving ZFS volumes. The goal is to install some version of ESXi on this ZFS volume and then boot another machine from it using iPXE. It is booletproof soulltion - it is working for years on older versions of FreeBSD. I've got two servers where this solution works first running FreeBSD 11.2 second 11.3. I wanted to set up third one. I installed FreeBSD 12.2 and it doesn't work. I checked it on two different machines both with FreeBSD 12.2 and on both get the same result.

Let me explain full pipeline. Here is ipxe script

```
#!ipxe

sanboot iscsi:{{master_ip}}::::iqn.myiqn:${hostname}-{{iscsi_path}} || goto boot

:boot
sanhook iscsi:{{master_ip}}::::iqn.myiqn:${hostname}-{{iscsi_path}}
kernel http://{{www_ip}}/{{path}}/efi/boot/bootx64.efi -c http://{{www_ip}}/{{path}}/boot.cfg ks=http://{{www_ip}}/ks.cfg BOOTIF=01-${mac:hexhyp}
boot
```

So the idea is to try sanboot command and if it doesn't work attach drive by sanhook and then boot into ESXi iso located on web server. The insaller should be able to see iSCSI drive.
Sanhook goes without any errors and in fact I can see on iSCSI server that for a short time there is iSCSI connection to the target (ctladm islist). But after going into ESXi installer there is no disk there. Also on iSCSI server it seems like there is no connection (no records on ctladm islist).

Here is my ctl.conf file. I'm using ucl format.

```
"auth-group": {
        "auth-Te": {
            "auth-type": "none",
        }
    },
    "lun": {
        "Te-esxi..esxi-7.0U1-16850804": {
            "path": "/dev/zvol/zdata/host/Te/esxi/esxi-7.0U1-16850804"
        }
    },
    "target": {
        "iqn.myiqn:Te-esxi..esxi-7.0U1-16850804": {
            "lun": [
                {
                    "number": 0,
                    "name": "Te-esxi..esxi-7.0U1-16850804"
                }
            ],
            "auth-group": "auth-Te"
        }
    },
  
    "portal-group": {
        "default": {
            "listen": [
                "0.0.0.0:3260",
                "[::]:3260"
            ],
            "discovery-auth-group": "no-authentication"
        }
    }
```

It seems like something changed in FreeBSD iscsi handle that blocks ESXi installer from connecting to the iSCSI target.
I'll try on FreeBSD 11.4 and update this post later.


----------



## Giteh (Jan 19, 2021)

It appears also on FreeBSD 12.1
I checked and there is some changes made in ctld in 11.x - 12.x change maybe it is related to some of those.
I also checked with different OSes (FreeBSD and WinPE): I called sanhook command and then booted OS  using ipxe and checked if after boot there will be iSCSI disk visible. In FreeBSD it wasn't but in WinPE I was able to see it...
It seems strange to me but I guest that something changed with ipxe -> FreeBSD iSCSI communication that cause that.


----------



## usdmatt (Jan 19, 2021)

If it worked on 11 and not 12, it may be worth an email to the freebsd-scsi@freebsd.org list.


----------



## Giteh (Jan 23, 2021)

After long debug I figured it out and the reason was hiliarous. So it wasn’t related to FreeBSD. It appears that ESXi installer checks if name of iSCSI target has correct format: iqn.YYYY.MM.reversed.domain
If it’s wrong it just doesn’t connect the drive. 
Hope this thread will save week of debuging to someone else...


----------

