Can NOT establish connection from db2 client to db2 server v11.5



    1. I installed Db2 v11.5.7.0 on Linux/x86_64 inside my virtual PC using VirtualBox on Windows 10.
    2. I created database with name TEST1
    3. I connected to database using Unix socket: db2 connect to TEST1 and connection successfully completed.
    4. Check for DB2COMM setting: db2set DB2COMM and output is DB2COMM=TCPIP
    5. Just to make sure TCP/IP connection works to Db2 I created local node and catalog database:
    db2 catalog tcpip node loctcp remote localhost server 50000
    db2 catalog database test1 as tcptest1 at node loctcp
    db2 terminate
    db2 connect to tcptest1 user db2inst1 using 
    

    and connection successfully completed.

    1. Now on my PC VirtualBox Windows 10 host I set port forwarding Host Port: 60127 and Guest Port: 50000.
    2. On my Windows PC: netstat -an -p tcp | find ":60127" I can see connection is in LISTENING state.
    3. On my Windows PC:
    db2 catalog tcpip node remtcp remote localhost server 60127
    db2 catalog database test1 as tcptest1 at node remtcp
    db2 terminate
    
    1. On my Windows PC connect to database

    db2 connect to tcptest1 user db2inst1 using

    PROBLEM: It looks like connection hangs. After few minutes I get error in Db2 client:

    SQL30081N A communication error has been detected. Communication protocol being used: "TCP/IP". Communication API being used: "SOCKETS". Location where the error was detected: "127.0.0.1". Communication function detecting the error: "recv". Protocol specific error code(s): "10054", "*", "0". SQLSTATE=08001

    1. Trying to understand the problem. On Linux server: a) I have checked for firewall and it is disabled. b) IPv6 is disabled c) Db2 is listening on 50000 port using IPv4
    2. Wireshark on Windows listening to 60127 port. a) TCP connection is established b) Db2 DRDA connection never appears.
    3. Tcpdump on Linux server capturing 50000 port network traffic. a) TCP connection is established b) Db2 DRDA connection never appears.

    It appears something is wrong inside Linux virtual machine, but steps 4 and 5 everything should be fine with Db2 TCP/IP connection.

    Any idea what else to check why Db2 client connection does not work?

    P.S. I have exact same installation with Db2 v11.1 and Db2 connection from my PC is working fine.



  • I have solved the problem. It was firewall problem.

    My assumption on step 10 was wrong. I only checked the iptables rules:

    sudo iptables -nvL
    

    which having ALLOWED for all of the policies, so I assumed firewall is disabled (or has no effect).

    But there was another firewall firewalld service enabled and running:

    sudo systemctl status firewalld
    

    I have stopped and disabled it:

    sudo systemctl stop firewalld
    sudo systemctl disable firewalld
    sudo systemctl mask firewalld
    

    Or instead of above three commands I could add firewall exception to allow 50000 port of my Db2 service:

    firewall-cmd --add-port=50000/tcp
    

    Note: My steps 11 and 12 were wrong assumption. I have analyzed network packets in more detail. I see only TCP SYN packet was received from Db2 Windows client and there was no TCP SYN/ACK response from Db2 server machine back to client. There was no TCP connection established (because it was blocked by firewall), obviously there could not be any DRDA protocol established, because of dependency on TCP connection.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2