When I run this snippet on my Raspberry Pi 3 with Ethernet cable connected it works and sends the message on UDP multicast but when the ethernet is disconnected if gives the error message
import socket
from socket import IPPROTO_IPV6
import struct
PORT = 26000
ADDR = 'ff01::1' #IPV6 Multicast Address
addrInfo = socket.getaddrinfo(ADDR, None)[0]
mcast_sock = socket.socket(addrInfo[0], socket.SOCK_DGRAM)
mcast_sock.setsockopt(IPPROTO_IPV6, socket.IPV6_MULTICAST_HOPS, 1)
mcast_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
mcast_sock.bind(('', PORT))
#Join Multicast grp.
group = socket.inet_pton(addrInfo[0], addrInfo[4][0])
mreq = group + struct.pack('#I', 0)
mcast_sock.setsockopt(IPPROTO_IPV6, socket.IPV6_JOIN_GROUP, mreq)
mcast_sock.sendto(b"Message", (ADDR, PORT))
Error Message when only Wlan0 interface is up
Traceback (most recent call last):
File "test.py", line 20, in <module>
mcast_sock.sendto(b"Message", (ADDR, PORT))
socket.error: [Errno 99] Cannot assign requested address
ifconfig:
eth0 Link encap:Ethernet HWaddr b8:27:eb:13:e8:41
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:16716 errors:0 dropped:7224 overruns:0 frame:0
TX packets:408 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1017246 (993.4 KiB) TX bytes:56739 (55.4 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
wlan0 Link encap:Ethernet HWaddr b8:27:eb:46:bd:14
inet addr:10.90.128.72 Bcast:10.90.128.255 Mask:255.255.255.0
inet6 addr: fe80::a4dd:c183:1f7a:5f43/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:58481 errors:0 dropped:41915 overruns:0 frame:0
TX packets:5196 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:12027273 (11.4 MiB) TX bytes:925411 (903.7 KiB)
seems that the local routing favored eth0 over wlan0
ip -6 route show table local
local ::1 dev lo proto kernel metric 256
local ::1 dev lo proto none metric 0
local fe80::a4dd:c183:1f7a:5f43 dev lo proto none metric 0
ff00::/8 dev eth0 metric 256
ff00::/8 dev wlan0 metric 256
Found this solution
How to send multicast packets via a specfic interface in Linux
so I ran the following command:
ip -6 route add ff01::/16 dev lo table local
Then it works :)
Related
I have a tcpdump command that captures tcp handshake (0x16) and cipher change (0x14) packets. I'd like to be able to look at the output and see which ones are the handshake and which ones are the cipher change. Is there any way to alter the format of the output to show that information?
I could save it to a file and look at it in wireshark but I want to see that information in the CLI output.
tcpdump -i eth -nn -v port 48240 and '((tcp[((tcp[12] & 0xf0) >>2)] = 0x16) or (tcp[((tcp[12] & 0xf0) >>2)] = 0x14))'
dropped privs to tcpdump
tcpdump: listening on eth, link-type EN10MB (Ethernet), capture size 262144 bytes
10:03:31.999584 IP (tos 0x0, ttl 64, id 57840, offset 0, flags [DF], proto TCP (6), length 85)
10.118.192.12.2182 > 10.118.192.11.48240: Flags [P.], cksum 0x93d2 (correct), seq 3711068413:3711068446, ack 1143145831, win 16993, options [nop,nop,TS val 1192314306 ecr 1000785770], length 33
10:03:32.000338 IP (tos 0x0, ttl 64, id 4324, offset 0, flags [DF], proto TCP (6), length 326)
10.118.192.11.48240 > 10.118.192.12.2182: Flags [P.], cksum 0x96d4 (incorrect -> 0x8a16), seq 1:275, ack 33, win 16923, options [nop,nop,TS val 1000786035 ecr 1192314306], length 274
10:03:32.000802 IP (tos 0x0, ttl 64, id 57842, offset 0, flags [DF], proto TCP (6), length 190)
10.118.192.12.2182 > 10.118.192.11.48240: Flags [P.], cksum 0x2745 (correct), seq 33:171, ack 275, win 16993, options [nop,nop,TS val 1192314307 ecr 1000786035], length 138
10:03:32.000903 IP (tos 0x0, ttl 64, id 57843, offset 0, flags [DF], proto TCP (6), length 82)
10.118.192.12.2182 > 10.118.192.11.48240: Flags [P.], cksum 0x3df9 (correct), seq 171:201, ack 275, win 16993, options [nop,nop,TS val 1192314307 ecr 1000786035], length 30
10:03:32.000961 IP (tos 0x0, ttl 64, id 57844, offset 0, flags [DF], proto TCP (6), length 97)
10.118.192.12.2182 > 10.118.192.11.48240: Flags [P.], cksum 0x10ed (correct), seq 201:246, ack 275, win 16993, options [nop,nop,TS val 1192314307 ecr 1000786035], length 45
10:03:32.001095 IP (tos 0x0, ttl 64, id 4326, offset 0, flags [DF], proto TCP (6), length 82)
10.118.192.11.48240 > 10.118.192.12.2182: Flags [P.], cksum 0x95e0 (incorrect -> 0x796b), seq 275:305, ack 246, win 16923, options [nop,nop,TS val 1000786036 ecr 1192314307], length 30
10:03:32.001135 IP (tos 0x0, ttl 64, id 4327, offset 0, flags [DF], proto TCP (6), length 97)
10.118.192.11.48240 > 10.118.192.12.2182: Flags [P.], cksum 0x95ef (incorrect -> 0x6ae6), seq 305:350, ack 246, win 16923, options [nop,nop,TS val 1000786036 ecr 1192314307], length 45
10:07:43.518141 IP (tos 0x0, ttl 64, id 6012, offset 0, flags [DF], proto TCP (6), length 26896)
10.118.192.11.48240 > 10.118.192.12.2182: Flags [.], cksum 0xfe9e (incorrect -> 0x208f), seq 3235659:3262503, ack 3057000, win 16923, options [nop,nop,TS val 1001037553 ecr 1192565825], length 26844
I'm running qemu-system-x86_64 with my new pci device. And i want to use IRQ 17 (Since driver from kernel listen for IRQ 17). But my PCI device take IRQ 10 or 11. base on interrupt_pin(A,B,C,E).
Then i want to send irq to kernel module by qemu_irq_pulse.
This is how i allocate irq:
pci_config_set_interrupt_pin(pci_dev->config, 1);
d->irq = pci_allocate_irq(pci_dev)
root#hostname:~# cat /proc/interrupts
CPU0
0: 48 IO-APIC 2-edge timer
1: 9 IO-APIC 1-edge i8042
4: 1440 IO-APIC 4-edge ttyS0
8: 1 IO-APIC 8-edge rtc0
9: 0 IO-APIC 9-fasteoi acpi
12: 125 IO-APIC 12-edge i8042
24: 773 PCI-MSI 512000-edge ahci[0000:00:1f.2]
25: 355 PCI-MSI 32768-edge eth0-rx-0
26: 160 PCI-MSI 32769-edge eth0-tx-0
27: 1 PCI-MSI 32770-edge eth0
lspci -nk -vv:
00:1f.3 0880: 10de:0101 (rev 01)
Subsystem: 1af4:1100
Control: I/O+ Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Interrupt: pin A routed to IRQ 10
Capabilities: [80] MSI: Enable- Count=1/1 Maskable- 64bit+
Address: 0000000000000000 Data: 0000
Kernel driver failed to request irq since it trying to attach to IRQ 17. I don't want to change kernel side.
This is what i want to see:
root#hostname:~# cat /proc/interrupts
CPU0
0: 2213 IO-APIC
17: 0 IO-APIC 17-fasteoi some_kernel_driver_name
How to allocate interrupt 17 for PCI device in qemu?
Im not sure it is correct answer but for me it helps:
Add to ACPI:
irqs = 17;
aml_append(crs, aml_interrupt(AML_CONSUMER, AML_EDGE,
AML_ACTIVE_HIGH, AML_SHARED,
&irqs, 1));
Also PCI interrupt number looks like somehow depends on PCI vendor_id and device_id.
Setup:
created a network namespace.
created a veth pair vetha and vethb with vethb end in the
namespace and other in the host.
added an ip 192.168.122.50 to the vethb
Started a redis server in a container in that network namespace
Sending requests to the redis server directly from the client running on same host named as secondaryvm. However, it throws : Failed to connect to Redis: Connection timed out error. Cannot understand why is this happening, so looked at tcpdump stream by sniffing on vetha, same is posted below:
21:48:33.764967 IP (tos 0x0, ttl 64, id 31361, offset 0, flags [DF], proto TCP (6), length 60)
secondaryvm.34540 > 192.168.122.50.6379: Flags [S], cksum 0x75d6 (incorrect -> 0xe169), seq 3863373484, win 64240, options [mss 1460,sackOK,TS val 3417390465 ecr 0,nop,wscale 7], length 0
21:48:38.884975 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 192.168.122.50 tell secondaryvm, length 28
21:48:38.885101 ARP, Ethernet (len 6), IPv4 (len 4), Reply 192.168.122.50 is-at 1a:8c:7f:8b:4d:e0 (oui Unknown), length 28
21:49:16.138726 IP (tos 0x0, ttl 64, id 29195, offset 0, flags [DF], proto TCP (6), length 60)
secondaryvm.34544 > 192.168.122.50.6379: Flags [S], cksum 0x75d6 (incorrect -> 0xe563), seq 550142628, win 64240, options [mss 1460,sackOK,TS val 3417432839 ecr 0,nop,wscale 7], length 0
21:49:17.156952 IP (tos 0x0, ttl 64, id 29196, offset 0, flags [DF], proto TCP (6), length 60)
secondaryvm.34544 > 192.168.122.50.6379: Flags [S], cksum 0x75d6 (incorrect -> 0xe169), seq 550142628, win 64240, options [mss 1460,sackOK,TS val 3417433857 ecr 0,nop,wscale 7], length 0
21:49:19.173031 IP (tos 0x0, ttl 64, id 29197, offset 0, flags [DF], proto TCP (6), length 60)
secondaryvm.34544 > 192.168.122.50.6379: Flags [S], cksum 0x75d6 (incorrect -> 0xd989), seq 550142628, win 64240, options [mss 1460,sackOK,TS val 3417435873 ecr 0,nop,wscale 7], length 0
21:49:22.405182 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 192.168.122.50 tell secondaryvm, length 28
21:49:22.405262 ARP, Ethernet (len 6), IPv4 (len 4), Reply 192.168.122.50 is-at 1a:8c:7f:8b:4d:e0 (oui Unknown), length 28
21:49:23.429054 IP (tos 0x0, ttl 64, id 29198, offset 0, flags [DF], proto TCP (6), length 60)
secondaryvm.34544 > 192.168.122.50.6379: Flags [S], cksum 0x75d6 (incorrect -> 0xc8e9), seq 550142628, win 64240, options [mss 1460,sackOK,TS val 3417440129 ecr 0,nop,wscale 7], length 0
21:49:31.621030 IP (tos 0x0, ttl 64, id 29199, offset 0, flags [DF], proto TCP (6), length 60)
secondaryvm.34544 > 192.168.122.50.6379: Flags [S], cksum 0x75d6 (incorrect -> 0xa8e9), seq 550142628, win 64240, options [mss 1460,sackOK,TS val 3417448321 ecr 0,nop,wscale 7], length 0
21:49:47.749024 IP (tos 0x0, ttl 64, id 29200, offset 0, flags [DF], proto TCP (6), length 60)
secondaryvm.34544 > 192.168.122.50.6379: Flags [S], cksum 0x75d6 (incorrect -> 0x69e9), seq 550142628, win 64240, options [mss 1460,sackOK,TS val 3417464449 ecr 0,nop,wscale 7], length 0
21:50:20.261084 IP (tos 0x0, ttl 64, id 29201, offset 0, flags [DF], proto TCP (6), length 60)
secondaryvm.34544 > 192.168.122.50.6379: Flags [S], cksum 0x75d6 (incorrect -> 0xeae8), seq 550142628, win 64240, options [mss 1460,sackOK,TS val 3417496961 ecr 0,nop,wscale 7], length 0
21:50:25.381045 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 192.168.122.50 tell secondaryvm, length 28
21:50:25.381176 ARP, Ethernet (len 6), IPv4 (len 4), Reply 192.168.122.50 is-at 1a:8c:7f:8b:4d:e0 (oui Unknown), length 28
Redis server is up and the client is getting connected to it according to the terminal output but not according to the tcpdump output. according to tcpdump output, client is trying to connect but didn't achieve the connection establishment successfully.
Terminal output at the client side:
========================100==================================================
terminate called after throwing an instance of 'sw::redis::TimeoutError'
what(): Failed to connect to Redis: Connection timed out
Aborted (core dumped)
Client's code(written in redis-plus-plus):
int main(){
auto redis = Redis("tcp://192.168.122.50:6379);
sleep(5);
int ep = 100;
while(true){
cout<<"===================="<<ep<<"======================\n";
auto pipe = redis.pipeline(false);
for(int i=1; i<=500; i++){
string s = to_string(i);
if(i%2 == 1){
pipe.set(s, s);
}
else {
string st = to_string(i-1);
pipe.get(st);
}
}
auto pipe_replies = pipe.exec();
pipe.discard();
}
According to the terminal's output, it successfully established the connection.
Cannot understand what is happening here.
Is it like line auto redis = Redis("tcp://192.168.122.50:6379"); doesn't establish the connection?
redis-server is surely up then why the connection is not established looking at the tcp stream?
Redis version 6.0.9 and IT IS running on port 6379.
How to prevent this error?
EDIT:
I've followed below steps/commands to set up network namespace:
#!/bin/bash
sudo ip netns ls
sudo ip netns add alpine_network
sudo ip link add name veth-host type veth peer name veth-alpine
sudo ip link set veth-alpine netns alpine_network
sudo ip netns exec alpine_network ip addr add 192.168.122.50/24 dev veth-alpine
sudo ip netns exec alpine_network ip link set veth-alpine up
sudo ip netns exec alpine_network ip link set lo up
sudo ip link set veth-host up
sudo ip route add 192.168.122.50/32 dev veth-host
sudo ip netns exec alpine_network ip route add default via 192.168.122.50 dev veth-alpine
OS Platform and Distribution (e.g., Linux Ubuntu 16.04): linux Ubuntu 16.04
TensorFlow installed from (source or binary): binary
TensorFlow version (use command below): v1.4.0-rc1
Python version: 3.5.5
CUDA/cuDNN version: CUDA 8.0 / cuDNN 6
GPU model and memory: nvidia gtx 1080
I am new to Tensorflow. So this could easily be some silly installation error that I don't see.
I open python to test TF installation:
import tensorflow as tf
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
Resulting in:
I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX
2018-04-11 21:39:44.830140: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Found device 0 with properties:
name: GeForce GTX 1080 major: 6 minor: 1 memoryClockRate(GHz): 1.8475
pciBusID: 0000:01:00.0
totalMemory: 7.92GiB freeMemory: 78.94MiB
2018-04-11 21:39:44.830178: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1080, pci bus id: 0000:01:00.0, compute capability: 6.1)
2018-04-11 21:39:44.832231: E tensorflow/stream_executor/cuda/cuda_driver.cc:936] failed to allocate 78.94M (82771968 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY
2018-04-11 21:39:44.834394: E tensorflow/stream_executor/cuda/cuda_driver.cc:936] failed to allocate 71.04M (74494976 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY
2018-04-11 21:39:44.835825: E tensorflow/stream_executor/cuda/cuda_driver.cc:936] failed to allocate 63.94M (67045632 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY
2018-04-11 21:39:44.837560: E tensorflow/stream_executor/cuda/cuda_driver.cc:936] failed to allocate 57.55M (60341248 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY
2018-04-11 21:39:44.839233: E tensorflow/stream_executor/cuda/cuda_driver.cc:936] failed to allocate 51.79M (54307328 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY
2018-04-11 21:39:44.841757: E tensorflow/stream_executor/cuda/cuda_driver.cc:936] failed to allocate 46.61M (48876800 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY
2018-04-11 21:39:44.843632: E tensorflow/stream_executor/cuda/cuda_driver.cc:936] failed to allocate 41.95M (43989248 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY
2018-04-11 21:39:44.845588: E tensorflow/stream_executor/cuda/cuda_driver.cc:936] failed to allocate 37.76M (39590400 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY
2018-04-11 21:39:44.847229: E tensorflow/stream_executor/cuda/cuda_driver.cc:936] failed to allocate 33.98M (35631360 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY
2018-04-11 21:39:44.849278: E tensorflow/stream_executor/cuda/cuda_driver.cc:936] failed to allocate 30.58M (32068352 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY
2018-04-11 21:39:44.850967: E tensorflow/stream_executor/cuda/cuda_driver.cc:936] failed to allocate 27.52M (28861696 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY
[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 6037705122138393497
, name: "/device:GPU:0"
device_type: "GPU"
memory_limit: 82771968
locality {
bus_id: 1
}
incarnation: 11403601020071115295
physical_device_desc: "device: 0, name: GeForce GTX 1080, pci bus id: 0000:01:00.0, compute capability: 6.1"
]
Supposing your question is "Why does Tensorflow allocate all available GPU memory even though much less memory would be enough for my program?", then the answer is that they do this to reduce GPU memory fragmentation. You can change this default behavior with some settings like config.gpu_options.allow_growth and config.gpu_options.per_process_gpu_memory_fraction to make Tensorflow less memory hungry at the expense of allowing some potential memory fragmentation to occur. Detailed explanation in the Tensorflow Programmer's Guide Using GPU chapter.
I have 3 servers with WHM and I want to transfer some files from server1 and server2 to server3.
I did a backup of files on server1, database backup on server2 and now I need to get files from server1 and server2 to server3 using SSH.
I login to server3 using SSH and I use wget command to get files from server1 - works fine. When I try to use wget to get files from server2 I get "connection refused" error.
What could be a problem?
EDIT: I used online tool to check is ports are opened at server2 and I found that ports 22 and 80 are closed. This is very strange because when I login to WHM and check firewall configuration both ports are listed under TCP_IN, TCP_OUT, UDP_IN and UDP_OUT.
How can I open ports with ssh or whm?
I also did this check for server1 and ports are opened, so I guess this is why I can't get files from server2, because ports 22 and 80 are closed.
Here's the output of netstat -lan | egrep LISTEN
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:587 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:2095 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:783 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:2096 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:465 0.0.0.0:* LISTEN
tcp 0 0 208.85.2.142:53 0.0.0.0:* LISTEN
tcp 0 0 208.85.2.141:53 0.0.0.0:* LISTEN
tcp 0 0 208.85.2.140:53 0.0.0.0:* LISTEN
tcp 0 0 208.85.2.139:53 0.0.0.0:* LISTEN
tcp 0 0 208.85.2.138:53 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:993 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:2082 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:2083 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:995 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:2086 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:2087 0.0.0.0:* LISTEN
tcp6 0 0 :::587 :::* LISTEN
tcp6 0 0 :::110 :::* LISTEN
tcp6 0 0 :::143 :::* LISTEN
tcp6 0 0 ::1:783 :::* LISTEN
tcp6 0 0 :::111 :::* LISTEN
tcp6 0 0 :::80 :::* LISTEN
tcp6 0 0 :::465 :::* LISTEN
tcp6 0 0 :::21 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 :::25 :::* LISTEN
tcp6 0 0 :::443 :::* LISTEN
tcp6 0 0 :::993 :::* LISTEN
tcp6 0 0 :::995 :::* LISTEN
unix 2 [ ACC ] STREAM LISTENING 238522 /var/cpanel/php-fpm/cpanelphpmyadmin/sock
unix 2 [ ACC ] STREAM LISTENING 1051941 /var/lib/mysql/mysql.sock
unix 2 [ ACC ] STREAM LISTENING 14357 /run/systemd/journal/stdout
unix 2 [ ACC ] STREAM LISTENING 743720 /var/run/dovecot/stats
unix 2 [ ACC ] STREAM LISTENING 743726 /var/run/dovecot/ssl-params
unix 2 [ ACC ] STREAM LISTENING 1329315 /usr/local/cpanel/var/cpauthd.sock
unix 2 [ ACC ] STREAM LISTENING 1329316 /usr/local/cpanel/var/cpdoveauthd.sock
unix 2 [ ACC ] STREAM LISTENING 1318256 /var/cpanel/userhomes/cpanelconnecttrack/p0f.socket
unix 2 [ ACC ] STREAM LISTENING 743728 /var/run/dovecot/login/ssl-params
unix 2 [ ACC ] STREAM LISTENING 743732 /var/run/dovecot/replicator
unix 2 [ ACC ] STREAM LISTENING 743736 /var/run/dovecot/replication-notify
unix 2 [ ACC ] STREAM LISTENING 247837 /var/clamd
unix 2 [ ACC ] STREAM LISTENING 743739 /var/run/dovecot/login/pop3
unix 2 [ ACC ] STREAM LISTENING 1053251 /var/run/cphulkd.sock
unix 2 [ ACC ] STREAM LISTENING 743747 /var/run/dovecot/log-errors
unix 2 [ ACC ] STREAM LISTENING 743751 /var/run/dovecot/lmtp
unix 2 [ ACC ] STREAM LISTENING 743755 /var/run/dovecot/ipc
unix 2 [ ACC ] STREAM LISTENING 743757 /var/run/dovecot/login/ipc-proxy
unix 2 [ ACC ] STREAM LISTENING 25680 /run/systemd/private
unix 2 [ ACC ] STREAM LISTENING 743761 /var/run/dovecot/indexer-worker
unix 2 [ ACC ] STREAM LISTENING 962684 /var/cpanel/php-fpm/operationsports/sock
unix 2 [ ACC ] STREAM LISTENING 743765 /var/run/dovecot/indexer
unix 2 [ ACC ] STREAM LISTENING 743767 /var/run/dovecot/login/imap
unix 2 [ ACC ] STREAM LISTENING 753466 /var/cpanel/dnsadmin/sock
unix 2 [ ACC ] STREAM LISTENING 12377 /var/run/dbus/system_bus_socket
unix 2 [ ACC ] STREAM LISTENING 743771 /var/run/dovecot/imap-master
unix 2 [ ACC ] STREAM LISTENING 12380 /var/run/rpcbind.sock
unix 2 [ ACC ] STREAM LISTENING 743775 /var/run/dovecot/imap-urlauth-worker
unix 2 [ ACC ] STREAM LISTENING 743777 /var/run/dovecot/token-login/imap-urlauth
unix 2 [ ACC ] STREAM LISTENING 743781 /var/run/dovecot/imap-urlauth
unix 2 [ ACC ] STREAM LISTENING 743789 /var/run/dovecot/imap-hibernate
unix 2 [ ACC ] STREAM LISTENING 743793 /var/run/dovecot/doveadm-server
unix 2 [ ACC ] STREAM LISTENING 743797 /var/run/dovecot/dns-client
unix 2 [ ACC ] STREAM LISTENING 743801 /var/run/dovecot/director-admin
unix 2 [ ACC ] STREAM LISTENING 743805 /var/run/dovecot/dict
unix 2 [ ACC ] STREAM LISTENING 743809 /var/run/dovecot/dict-async
unix 2 [ ACC ] STREAM LISTENING 743813 /var/run/dovecot/config
unix 2 [ ACC ] STREAM LISTENING 743815 /var/run/dovecot/login/login
unix 2 [ ACC ] STREAM LISTENING 743817 /var/run/dovecot/token-login/tokenlogin
unix 2 [ ACC ] STREAM LISTENING 743821 /var/run/dovecot/auth-login
unix 2 [ ACC ] STREAM LISTENING 743825 /var/run/dovecot/auth-client
unix 2 [ ACC ] STREAM LISTENING 743829 /var/run/dovecot/auth-userdb
unix 2 [ ACC ] STREAM LISTENING 743833 /var/run/dovecot/auth-master
unix 2 [ ACC ] STREAM LISTENING 221082 /var/run/nscd/socket
unix 2 [ ACC ] STREAM LISTENING 743837 /var/run/dovecot/auth-worker
unix 2 [ ACC ] STREAM LISTENING 743841 /var/run/dovecot/anvil
unix 2 [ ACC ] SEQPACKET LISTENING 25763 /run/udev/control
unix 2 [ ACC ] STREAM LISTENING 743845 /var/run/dovecot/anvil-auth-penalty
unix 2 [ ACC ] STREAM LISTENING 743849 /var/run/dovecot/quota-status
unix 2 [ ACC ] STREAM LISTENING 743852 /var/run/dovecot/master
unix 2 [ ACC ] STREAM LISTENING 1313199 /etc/apache2/run/cgid_sock.28821
unix 2 [ ACC ] STREAM LISTENING 671672 /var/run/ftpd.sock
unix 2 [ ACC ] STREAM LISTENING 1329314 /usr/local/cpanel/var/cpwrapd.sock
unix 2 [ ACC ] STREAM LISTENING 238524 /var/cpanel/php-fpm/cpanelphppgadmin/sock
unix 2 [ ACC ] STREAM LISTENING 238526 /var/cpanel/php-fpm/cpanelroundcube/sock
EDIT: I checked /etc/ssh/sshd_config on server1 and server2 and everything is the same, but for some reason server2 is refusing connection.
Problem is solved. I used online tool to check for opened ports and ports 22 and 80 were closed and that is why connection was refused.
Thank you all for help.