Configuring iSCSI initiator using iscsicli.exe RRS feed

  • Question

  • Hello,

    I'm trying to login to target using iscsi.exe. I want to specify the source IP for the connection. I'll get that option when I do it through MS iSCSI GUI. I don't see that option in command line.

    My target IP is & my source IP is I tried the following command and it was successfull (connection was established). But the established connection had "" as source IP.

    C:\WINDOWS\system32>iscsicli logintarget T 3260 Root\SCSIADAPTER\0000_0 * * * * * * * * * * * 0

     Please advice me how to specify source IP for connection through command line.

     Thanks in advance,


    Monday, November 13, 2006 9:34 PM


  • netsh interface ipv4>show interfaces

    Idx  Met   MTU   State        Name
    ---  ---  -----  -----------  -------------------
      1   50 4294967295  connected    Loopback Pseudo-Interface 1
      6   20   1500  connected    Cluster
      7   20   1500  connected    Corp
     17   20   1300  disconnected  Local Area Connection* 10

    netsh interface ipv4>

    What more are you looking for?


    Monday, November 20, 2006 1:37 PM

All replies

  • Hi,

    Take a look at teh last answer in this thread: It looks like your syntax is off a little.


    Wednesday, November 15, 2006 2:45 PM
  • Here is a series of commands I use (from my step-by-step) when configuring my server core cluster node to connect to an iSCSI target

    8.  Configure the ISCSI Initiator to start automatically.

    sc \\<server_name> config msiscsi start= auto

    9.  Connect to the ISCSI Target and setup a persistent login

    iscsicli QAddTargetPortal <Portal IP Address>

    iscsicli ListTargets

    iscsicli QloginTarget <target_iqn>

    iscsicli PersistentLoginTarget <target_iqn> T * * * * * * * * * * * * * * * 0

    iscsicli ListPersistentTargets

    iscsicli ReportTargetMappings


    Wednesday, November 15, 2006 5:33 PM
  • Thanks for replies!

    I checked that post. But it doesn't talk about specifying the source IP while login.

    After doing some search, I found that I need to use <portnumber> parameter in the command. But that paramaeter is an index to NIC available on the server. For example, if I have two NiCs (& its IPs are & on the server. To use anyone of them as a source IP for the connection I should use either 0 or 1.

    But I'm not sure how the NICs are mapped to the index. Can anyone please help to find out how NICs on the server mapped to the index?



    Thursday, November 16, 2006 5:13 PM
  • netsh interface ipv4>show interfaces

    Idx  Met   MTU   State        Name
    ---  ---  -----  -----------  -------------------
      1   50 4294967295  connected    Loopback Pseudo-Interface 1
      6   20   1500  connected    Cluster
      7   20   1500  connected    Corp
     17   20   1300  disconnected  Local Area Connection* 10

    netsh interface ipv4>

    What more are you looking for?


    Monday, November 20, 2006 1:37 PM
  • Thanks Chuck Timon & Andrew!!


    Wednesday, November 29, 2006 9:56 PM
  • Can you tell me where to find your step-by-step guide?

    Tuesday, October 30, 2007 5:17 PM
  • Hi,


    You can find all the Windows Server 2008 step by step guides at:




    Wednesday, October 31, 2007 12:59 AM
  • Which specific guide are your iscsicli instructions in?





    Tuesday, April 8, 2008 7:44 PM
  • You can setup the iSCSI targets remotely using storage explorer gui. 



    Thursday, April 10, 2008 1:27 AM
  • When using the above sequence of commands on my Server Core, connecting to the MS iSCSI Target on Win2008, it yields me with a read-only disk when issuing a "lis dis" on the Server Core node.


    DiskPart shows "The media is write protected".


    Any ideas?




    • Proposed as answer by Hiram Celis Wednesday, September 10, 2008 9:36 PM
    Sunday, April 20, 2008 11:25 AM
  • Hi,
    same problem here. Any one with the same problem ? Rob, do you fix it?

    p.s. sorry for my bad english

    Sunday, June 1, 2008 6:59 PM
  • What you're experiencing is the result of an incorrect configuration of the iSCSI initiator in case you use full multipathing (multiple network pathes, multiple adapters and multiple iSCSI controlers): the iSCSI initiator has no way to know what route it should use to connect to the target and it revert to read-only mode (safe).

    Unfortunately, the instructions here are inadequate for multipathing and the iscsicli command line itself will make it very hard to do it right.

    Here is a script I wrote to help automate the deployment of some windows 2008 servers that needed to connect to our Dell MD3000i. You will need to edit these parameters to match your system according to the iscscicli documentation. They will produce two scripts: on that will setup the iCSCI initiator  and configure the  persistent targets and logins and another one that should reset  the iSCSI initiator. It's designed to work with my iSCSI SAN and some of the variable names reflect this.

    One thing that you'll have to watch for is the ip130Port and ip131Port values: these are the indexes of the SOURCE adapter to use with each network (i.e. that's what tells the initiator what IP to use for each path). Unfortunately, these indexes seems to change every time you hiccup and I was unable to find a way to get that index through a script. That means that the reset script will likely become invalid the instant someone touches the network configuration, activate the firewall, opens a VPN connection or updates a network driver.

    Note to MS: if you seriously intend people to use Windows core install, you will need to replace iscsicli.exe with a tool that is actually usable from the command-line. So far, that thing is really sub-standard and nearly unusable. Specifically, it needs proper error reporting, proper parameter handling and at least a minimal scriptability. As it is, that utility is a total waste of time.

    Good luck,

    rem @echo off 
    set setupscript=c:\admin\script\_setup_iscsi.cmd 
    set resetscript=c:\admin\script\_reset_iscsi.cmd 
    rem iSCSI network informations 
    set ip130Net=192.168.130. 
    set ip131Net=192.168.131. 
    set iptarget1=101 
    set iptarget2=102 
    set ip131Port=2 
    set ip130port=3 
    set IPportNumber=3260 
    rem iSCSI target definition 
    set ReportToPNP=T 
    set InitiatorInstance="Root\ISCSIPRT\0000_0" 
    Set SecurityFlags=0x0 
    set LoginFlags=0x2 
    set HeaderDigest=* 
    set DataDigest=* 
    set MaxConnections=* 
    set DefaultTTW=* 
    set DefaultTTR=* 
    set Username=* 
    set Password=* 
    set AuthType=0 
    set Key=* 
    set MappingCount=0 
    set TargetPortalSocket=%IPportNumber% 
    echo @echo off > %resetscript% 
    echo @echo off > %setupscript% 
    goto DoWork 
    echo echo Adding target portals >> %setupscript% 
    echo iscsicli AddTargetPortal %ip130Net%%iptarget1% %IPportNumber% "Root\ISCSIPRT\0000_0" %ip130Port% * * * * * * * * * * >> %setupscript% 
    echo iscsicli AddTargetPortal %ip131Net%%iptarget1% %IPportNumber% "Root\ISCSIPRT\0000_0" %ip131Port% * * * * * * * * * * >> %setupscript% 
    echo iscsicli AddTargetPortal %ip130Net%%iptarget2% %IPportNumber% "Root\ISCSIPRT\0000_0" %ip130Port% * * * * * * * * * * >> %setupscript% 
    echo iscsicli AddTargetPortal %ip131Net%%iptarget2% %IPportNumber% "Root\ISCSIPRT\0000_0" %ip131Port% * * * * * * * * * * >> %setupscript% 
    echo echo refreshing target portals >> %setupscript% 
    echo iscsicli RefreshTargetPortal %ip130Net%%iptarget1% %IPportNumber% >> %setupscript% 
    echo iscsicli RefreshTargetPortal %ip131Net%%iptarget1% %IPportNumber% >> %setupscript% 
    echo iscsicli RefreshTargetPortal %ip130Net%%iptarget2% %IPportNumber% >> %setupscript% 
    echo iscsicli RefreshTargetPortal %ip131Net%%iptarget2% %IPportNumber% >> %setupscript% 
    echo echo Adding persistent targets logins>> %setupscript% 
    set params_1=%TargetName% %ReportToPNP% 
    set params_2=%SecurityFlags% %LoginFlags% %HeaderDigest% %DataDigest% %MaxConnections% %DefaultTTW% %DefaultTTR% %Username% %Password% %AuthType% %Key% %MappingCount% 
    echo iscsicli PersistentLoginTarget %params_1% %ip130Net%%iptarget1% %TargetPortalSocket% %InitiatorInstance% %ip130Port% %params_2% >> %setupscript% 
    echo iscsicli PersistentLoginTarget %params_1% %ip130Net%%iptarget2% %TargetPortalSocket% %InitiatorInstance% %ip130Port% %params_2% >> %setupscript% 
    echo iscsicli PersistentLoginTarget %params_1% %ip131Net%%iptarget1% %TargetPortalSocket% %InitiatorInstance% %ip131Port% %params_2% >> %setupscript% 
    echo iscsicli PersistentLoginTarget %params_1% %ip131Net%%iptarget2% %TargetPortalSocket% %InitiatorInstance% %ip131Port% %params_2% >> %setupscript% 
    echo clearing the persistent targets 
    echo iscsicli RemovePersistentTarget %InitiatorInstance% %TargetName% %ip130Port% %ip130Net%%iptarget1% %IPportNumber% >> %resetscript% 
    echo iscsicli RemovePersistentTarget %InitiatorInstance% %TargetName% %ip130Port% %ip130Net%%iptarget2% %IPportNumber% >> %resetscript% 
    echo iscsicli RemovePersistentTarget %InitiatorInstance% %TargetName% %ip131Port% %ip131Net%%iptarget1% %IPportNumber% >> %resetscript% 
    echo iscsicli RemovePersistentTarget %InitiatorInstance% %TargetName% %ip131Port% %ip131Net%%iptarget2% %IPportNumber% >> %resetscript% 
    echo echo clearing target portals >> %resetscript% 
    echo iscsicli RemoveTargetPortal %ip130Net%%iptarget1% %IPportNumber% %InitiatorInstance% %ip130Port% >> %resetscript% 
    echo iscsicli RemoveTargetPortal %ip131Net%%iptarget1% %IPportNumber% %InitiatorInstance% %ip131Port% >> %resetscript% 
    echo iscsicli RemoveTargetPortal %ip130Net%%iptarget2% %IPportNumber% %InitiatorInstance% %ip130Port% >> %resetscript% 
    echo iscsicli RemoveTargetPortal %ip131Net%%iptarget2% %IPportNumber% %InitiatorInstance% %ip131Port% >> %resetscript% 
    goto end 

    • Proposed as answer by Kazumi Okayama Saturday, April 10, 2010 1:33 AM
    Friday, June 6, 2008 9:49 AM
  • What are you running as a target? Server 2008 with WinTarget? - Server 2008, Exchange 2007 Tutorials
    Friday, July 11, 2008 1:48 AM
  • Rob Scheepens said:

    When using the above sequence of commands on my Server Core, connecting to the MS iSCSI Target on Win2008, it yields me with a read-only disk when issuing a "lis dis" on the Server Core node.


    DiskPart shows "The media is write protected".


    Any ideas?




    To enable write propertie on disk you must run the follow command:


    This will permit the partition/volume creation and i recommend you enable Remote management and edit the storage part from a graphical interface to prevent issues.


    Wednesday, September 10, 2008 9:40 PM
  • We are having a similar issue using multi-path drivers with the MD3000i, thanks for putting the script togther.  We are trying to create a Hyper-V Fail Over Cluster, but first we need the storage setup correctly.  We have had a case open with Dell for over a week now on this issue and it seems that one of three things are happening:

    1. Multiple technicians from our company and Dell cannot make multipathing work with the MD3000, keep getting perferrred path errors, fails the controller over..also event log errors and unwritable LUNS
    2. Documentation from Dell is not working, followed multiple times line by line
    3. Not sure if the equipment is faulty or not, but appearantly this is not triggering a KNOWN error for Dell's techs

    Question:  How has the MD3000i worked with server core installations?  At this time we have one server plugged directly into one of the array controllers and cannot write to the LUN to create a partition...  Does the MD3000i working with a multi-pathed iscsi initiator on server core work at all (Broadcom NetExtreme II 5708x2)?  Is there something that needs to be done with the MPIO software?  There is no instruction from Dell on this that we have found, so far it looks like the "Host Driver" setup for the driver and the configuration tool software from the MD3000i resource CD should be able to configure this and we have went through this a few times.  Dell says it is a supported hardware configuration we have, but their support has exhausted alot of resources and cannot get it working so far. I found the elusive initiator port numbers, (which aren't the Idx numbers in Netsh by the way) by using a trial and error method, described in another post.  Then I used this script to create setup and reset scripts.  After using these we are still seeing the same errors...could this be a hardware issue?

    So at this point we have lost ALOT of time and money, and we would like to know if ANYONE has a MD3000i working with a server core cluster that is multipathed?  Dell says that is is, but if its not we need another solution...and FAST!  Any gurus out there?  Please help!!  Thanks for your help on this!!!!!!!!!

    Increasing Efficiency
    Sunday, February 8, 2009 6:51 PM
  • hello,

    I'm looking for install a cluster Hyper-v Between 2 servers and a MD3000I
    My first server is a Windows 2008 ENT
    The second one is a Windows 2008 ENT Core server.

    After severals tests, i Can plug my MD3000I on the First server. I can logon 4 times for making 4 sessions on the MD3000i.
    2 sessions on the first group
    2 sessions on the second group
    All is ok. I see All Disks, i can read and write on all disks.

    Now, i have a problem with the Core server edition.
    I can only plug one session on one group.
    If i Logout, I can plus my server on the other group but not the 2 groups on the same times.

    I can logon only one time.
    The first time it's ok: The operation completed successfully.
    all other times i have: The target has already been logged in via an iSCSI session.

    All my command are ok.
    When i do a iscsicli sessionlist, the initiator portal is

    I think this IP address make the error.

    On the graphical version, I was forced to use a static ip address like 192.168.130.X or 192.168.131.X

    Do you know how can I change the starting IP ?

    Is you cluster OK with core servers.


    Friday, June 26, 2009 3:07 PM
  • Hello,

     I have almost the same problem my config is, one nic for iscsi network with two ip binded and, target is single controller HP MSA 2012i array with two target portals and, i have server core so cli is needed, it's possible to configure MCS (multiple connections) not MPIO using cli, i want to connect with one nic to both target portals or it's impossible doit this way? I'm using default port's 3260

    Recently the target is connected to here is config

    Total of 1 mappings returned Session Id : fffffa8009fca438-4000013700000001 Target Name : Initiator : Root\ISCSIPRT\0000_0 Initiator Scsi Device : \\.\Scsi2: Initiator Bus : 0 Initiator Target Id : 0 Target Lun: 0x0 <--> OS Lun: 0x0

    Thank's for answers, regards

    • Edited by OOSOO Friday, July 31, 2009 12:24 PM
    Friday, July 31, 2009 12:16 PM
  • Update!  After many months of troubleshooting, we finally convenced Dell to replace the hardware a couple months ago.  It turns out we had one bad port on an MD3000i dual port controller setup.  Once that was replaced we have had no issues with it.  Just goes to show, don't count out the hardware!  That being said, iscsicli is still a painful process...BUT we found this article and it made a WORLD of difference on the config of iscsi on 2008 core (unsupported, but even the Dell techs were looking for this article as I recall while we were working through it).

    Increasing Efficiency
    Tuesday, August 4, 2009 4:11 PM