IBM i Global

IBM iΒ 

A space for professionals working with IBM’s integrated OS for Power systems to exchange ideas, ask questions, and share expertise on topics like RPG and COBOL development, application modernization, open source integration, system administration, and business continuity.


#Power


#IBMi
Β View Only
Expand all | Collapse all

DNS Settings in QSH vs Bash

  • 1.  DNS Settings in QSH vs Bash

    Posted Tue January 09, 2024 09:49 AM

    Hi All

    Is anyone on here familiar with the DNS setup, or rather differences, when accessing an IBM i through SSH to an interactive shell session vs QSH on a regular TN5250 session?

    I have a weird one - in green screen DNS all works as expected (as per CFGTCP settings)

    In QSH - I get a resolution failure for any attempts to resolve. It eventually times out with no servers found.

    In Bash/KSH/SH directly through an SSH session it all works as expected.

    In the QSHELL session, I can resolve stuff if I do "host destination_name DNS_server_ip" but unless I do that it fails to resolve.

    Is there an environment variable here somewhere that tells it where to look? In AIX it would be done in /etc/resolv.conf - is that relevant?

    This is on a V7R3 box if it makes any difference?

    Thanks in advance

    Cheers

    Andrew



    ------------------------------
    Andrew Smith
    ------------------------------


  • 2.  RE: DNS Settings in QSH vs Bash

    Posted Wed January 10, 2024 01:41 AM
    Edited by Satid Singkorapoom Wed January 10, 2024 01:42 AM

    Dear Andrew

    I did a Google search with "ibm i qshell dns" and found this Technote :  DNS Queries from PASE and QSH are failing at  https://www.ibm.com/support/pages/dns-queries-pase-and-qsh-are-failing.  It mentions about  /etc/resolv.conf file that you asked about.  Please follow its instruction to see if it helps or not.    



    ------------------------------
    Chance favors only the prepared mind.
    -- Louis Pasteur
    ------------------------------
    Satid S.
    ------------------------------



  • 3.  RE: DNS Settings in QSH vs Bash

    Posted Wed January 10, 2024 05:09 AM

    Hi Satid,

     

    Thank you so much! That did the trick for the most part.

    I was overthinking it – like I said in the UNIX world you'd normally use resolv.conf to specify the DNS servers for a host.

    But I was thinking that IBM I uses CFGTCP so it couldn't possibly be that simple as to specify them there too! 😊

     

    I've made the necessary changes and it resolves in QP2TERM sessions. Strangely, it still doesn't resolve in QSHELL but I think that I can get around that anyway.  Might be that QSH requires an IPL to read those files, in which case I'll find out next week after the weekly IPL of the LPAR.

     

    Thanks very much for your help, it is greatly appreciated.

     

    Cheers

     

    Andrew

     

     






  • 4.  RE: DNS Settings in QSH vs Bash

    Posted Wed January 10, 2024 05:28 AM

    Andrew, if you need a quick fix for specific hosts, you can also add host table entries in green screen. I have for instance SSH picking those up in PASE, even though they are not being resolved by DNS. 



    ------------------------------
    Kurt Thomas
    ------------------------------



  • 5.  RE: DNS Settings in QSH vs Bash

    Posted Wed January 10, 2024 05:35 AM

    Hi Kurt,

     

    Thanks for that – I will give that a go as well.

    Although running batch jobs from green screen resolve correctly if invoking a shell script through QP2SHELL instead of QSH. Weird one actually.

     

    SBMJOB CMD(call QP2SHELL2 'shell script') – resolves DNS correctly after adding netsvc.conf & resolv.conf

     

    SBMJOB CMD(QSH 'shell script') – doesn't resolve anything through DNS

     

    No explanation as to why it is like that, but I can live with the workaround for the moment 😊

     

    Cheers

     

    Andrew

     

     






  • 6.  RE: DNS Settings in QSH vs Bash

    Posted Wed January 10, 2024 07:32 AM

    What commands do you use to resolve?  Basically I am trying it here but ping, nslookup, telnet, tracert are all commands not found in STRQSH or CALL QP2TERM.



    ------------------------------
    Robert Berendt IBMChampion
    ------------------------------



  • 7.  RE: DNS Settings in QSH vs Bash

    Posted Wed January 10, 2024 07:41 AM

    For DNS-only resolution, you can use dig:

    dig yourhost

    For DNS+host table entries, you can use ssh -v yourhost, which may or may not succeed, but which will show you the resolved address.



    ------------------------------
    Kurt Thomas
    ------------------------------



  • 8.  RE: DNS Settings in QSH vs Bash

    Posted Wed January 10, 2024 07:41 AM

    Hi Robert,

     

    I've used a mixture but the main one here is curl (from the Open Source Packages) as I am accessing a REST API using it.

     

    I've also copied some packages from an AIX 7.2 box to get access to things like ping, but I don't think that is the recommended way of doing things 😊

    "dig +search" works from QP2TERM but when I use curl from QSH I get the following:

     

    curl: (6) getaddrinfo() thread failed to start

     

    Running it from QP2TERM I get the expected result

     

    Cheers

     

    Andrew

     






  • 9.  RE: DNS Settings in QSH vs Bash

    Posted Wed January 10, 2024 07:54 AM

    STRQSH

                                                             QSH Command Entry         
                                                                                       
       $                                                                               
     > dig nra.org                                                                     
       qsh: 001-0019 Error found searching for command dig. No such path or directory. 
       $                                                                               

    F3 exit

    CALL QP2TERM

                                                          /QOpenSys/usr/bin/-sh
                                                                               
      $                                                                        
    > dig nra.org                                                              
      /QOpenSys/usr/bin/-sh: dig:  not found.                                  
      $                                                                        

    IBM i 7.5, 

    PTF Group             Level
    SF99959                  42
    SF99958                  23
    SF99957                   3
    SF99956                   1
    SF99955                   7
    SF99954                  11
    SF99953                   2
    SF99952                  12
    SF99951                   5
    SF99950                   5
    SF99751                   4
    SF99750               23306

    SF99677                   4
    SF99676                   6
    SF99673                   3
    SF99671                   9



    ------------------------------
    Robert Berendt IBMChampion
    ------------------------------



  • 10.  RE: DNS Settings in QSH vs Bash

    Posted Wed January 10, 2024 08:28 AM

    It's in /usr/bin/dig for me. If it is not for you, not sure why. Maybe IBM did not compile it for 7.5. 



    ------------------------------
    Kurt Thomas
    ------------------------------



  • 11.  RE: DNS Settings in QSH vs Bash

    Posted Wed January 10, 2024 08:45 AM

    WRKLNK OBJ('/usr/bin/di*')

    Object link
    dirname    

    I have buku authority.



    ------------------------------
    Robert Berendt IBMChampion
    ------------------------------



  • 12.  RE: DNS Settings in QSH vs Bash

    Posted Wed January 10, 2024 02:36 PM

    I ran into this and found it very confusing myself.  It works like this:

       $                                                                                     
     > ping www.google.com                                                                   
       qsh: 001-0019 Error found searching for command ping. No such path or directory.      
       $                                                                                     
     > system ping www.google.com                                                            
       TCP3203:  Verifying connection to host system WWW.GOOGLE.COM at address 142.250.65.164
       TCP3215:  PING reply 1 from 142.250.65.164 took 38 ms. 256 bytes. TTL 58.             
       TCP3215:  PING reply 2 from 142.250.65.164 took 38 ms. 256 bytes. TTL 58.             
       TCP3215:  PING reply 3 from 142.250.65.164 took 39 ms. 256 bytes. TTL 58.             
       TCP3215:  PING reply 4 from 142.250.65.164 took 38 ms. 256 bytes. TTL 58.             
       TCP3215:  PING reply 5 from 142.250.65.164 took 38 ms. 256 bytes. TTL 58.             
       TCP3211:  Round-trip (in milliseconds) min/avg/max = 38/38/39.                        
       TCP3210:  Connection verification statistics: 5 of 5 successful (100 %).              
       CPC2206:  Ownership of object QZSHSYSTEM in QTEMP type *USRSPC changed.               
       $                                                                                     
                                                                                             



    ------------------------------
    Steven Riedmueller
    Certified IBM i Admin
    Speaker, Mentor, and Advocate
    ------------------------------



  • 13.  RE: DNS Settings in QSH vs Bash

    Posted Wed January 10, 2024 03:16 PM

    Steven,

    I believe system tells it to run an os command.  For example

    system crtbndrpg

    actually ran something.  Therefore it's not running the same as these people are doing.  They were experiencing different results from running ping from the os vs ping from within qsh (without system).



    ------------------------------
    Robert Berendt IBMChampion
    ------------------------------



  • 14.  RE: DNS Settings in QSH vs Bash

    Posted Wed January 10, 2024 03:25 PM

    Good point, I'm curious whether they would have the same DNS resolution issue using "system ping" as they were having with "native" PASE commands.  I thought it was weird that there isn't a PASE equivalent ping, and that you have to use "system ping".  Since it clearly is running the QSYS version of ping and piping the output into the QSH session, I would guess that you're right and this wouldn't reproduce the problem.



    ------------------------------
    Steven Riedmueller
    Certified IBM i Admin
    Speaker, Mentor, and Advocate
    ------------------------------



  • 15.  RE: DNS Settings in QSH vs Bash

    Posted Tue January 16, 2024 07:24 AM
    Edited by ac Tue January 16, 2024 07:32 AM

    In QSH remember to set var ADDENVVAR ENVVAR(QIBM_MULTI_THREADED) VALUE(Y) REPLACE(*YES)

    to enable multithreading, otherwise many PASE programs cannot work

    in SSH or QP2TERM is already on ...... or start the job with ALWMLTTHD on

    ciao



    ------------------------------
    --ft
    ------------------------------



  • 16.  RE: DNS Settings in QSH vs Bash

    Posted Wed January 10, 2024 09:16 AM

    i got the same on V7.5

    host lparname 1.2.3.4

    returns not found

    but...

    host lparname.domainname.net 1.2.3.4 

    does return the info.  

    quick view is that command line uses the configured "domain name" and domain search" configuration

    might be time for a PMR...



    ------------------------------
    Bryan Dietz
    ------------------------------