
This article explains how to create an iSCSI gateway on a Debian server to host block storage over iSCSI.
Terms used in this guide:
For example, you could use a Vultr cloud server as the Target, and a Bare Metal server as the Initiator.
This guide uses Debian, but the steps are similar for any Linux distribution that supports Open-iSCSI.
Deploy a new Debian 11 server as the Target.
Create a block storage subscription and attach it to the Target server.
SSH to the Target server as root.
Install targetcli and open-iscsi
Enable the iSCSI daemon and start it.
Run targetcli to enter the command line interface for iSCSI configuration. The prompt changes to /> after the command is run.
Navigate to the Block Storage backstore.
For each mounted Block Storage volume, create a backstore. Here is an example that creates one backstore for a subscription at /dev/vdb, named vdb.
Create the Target IQN. The IQN name format is iqn.YEAR-MONTH.domain:targetname. The domain is reversed as a convention, so a domain of example.com is expressed as com.example. The target name can be whatever you want it to be. This example uses target.
Create a LUN mapping to the block device.
Set the ACLs to enable bi-directional CHAP authentication.
initiator as the example name. The example Initiator username is initiator_user and the password is initiator_password. The example Target username is target_user and the password is target_password.
Change to the root directory, save your targetcli configuration, and then exit.
Enable the targetclid service. This step is required to reload the configuration when the Target server restarts.
Verify the iSCSI service is listening on port 3260 with the following command. IP address 0.0.0.0 means the service is listening on all interfaces.
Configure the firewall to open port 3260 to the Initiator. Debian 11 uses ufw as its default firewall. Substitute the Initiator's IP address for 10.10.10.123 used in this example. We strongly recommend you only enable a private network interface that is connected to a Vultr VPC.
SSH to your Initiator server as root, which can be any APT or RPM-based server that supports open-iscsi.
On the Initiator, install open-iscsi and start the iscsid service.
APT-based Linux
RPM-based Linux
Open /etc/iscsi/initiatorname.iscsi in a text editor.
Set the iSCSI Initiator name to match the name you set on the iSCSI Target server. For example, this guide uses iqn.2022-05.com.example:initiator.
Save and exit the file.
Open /etc/iscsi/iscsid.conf in a text editor.
Edit the file as shown to configure authentication.
Restart the iscsid service to set the new configuration.
Discover the target on the Initiator.
Log in to the Target server. This is only required once; the iscsid.service you created earlier will restart the connection when the machine is rebooted.
The disk should now be mounted over iSCSI on the Initiator. You can check this with lsblk. In this example, sda is the target.
The Block Storage volume is now available to the Initiator over iSCSI, and you can mount it to the Linux filesystem like any other block device. For more information, see the "Mount Block Storage" topic.
To learn more about iSCSI and targetcli, see:
0 Comments
Be the first to comment and share your perspective with the community.