nrpe : Network server bind failure (98: Address already in use) - linux

I have installed iCinga and nrpe in same machine. I am using nrpe for monitor many linux machine, so I installed nrpe locally also.
When I start my nrep locally service nrpe start it sows error like in /var/log/messages
nrpe : Network server bind failure (98: Address already in use)
I have google it that issue, and find the 5666 port usage
[root#cosrh6-74 conf.d]# netstat -apn | grep :5666
tcp 0 0 127.0.0.1:50539 10.104.16.212:5666 TIME_WAIT -
tcp 0 0 127.0.0.1:50608 10.104.16.212:5666 TIME_WAIT -
tcp 0 0 127.0.0.1:41987 10.104.16.210:5666 TIME_WAIT -
tcp 0 1 127.0.0.1:42001 10.104.16.210:5666 SYN_SENT -
tcp 0 0 127.0.0.1:50576 10.104.16.212:5666 TIME_WAIT -
tcp 0 0 127.0.0.1:41927 10.104.16.210:5666 TIME_WAIT -
tcp 0 0 127.0.0.1:52598 10.3.81.172:5666 TIME_WAIT -
tcp 0 0 127.0.0.1:52624 10.3.81.172:5666 TIME_WAIT -
tcp 0 0 127.0.0.1:41962 10.104.16.210:5666 TIME_WAIT -
tcp 0 0 127.0.0.1:41979 10.104.16.210:5666 TIME_WAIT -
tcp 0 0 127.0.0.1:52566 10.3.81.172:5666 TIME_WAIT -
tcp 0 0 127.0.0.1:41928 10.104.16.210:5666 TIME_WAIT -
tcp 0 0 127.0.0.1:52569 10.3.81.172:5666 TIME_WAIT -
tcp 0 0 127.0.0.1:41955 10.104.16.210:5666 TIME_WAIT -
tcp 0 0 127.0.0.1:52587 10.3.81.172:5666 TIME_WAIT -
tcp 0 0 127.0.0.1:50586 10.104.16.212:5666 TIME_WAIT -
tcp 0 0 127.0.0.1:50547 10.104.16.212:5666 TIME_WAIT -
tcp 0 0 127.0.0.1:52588 10.3.81.172:5666 TIME_WAIT -
tcp 0 0 127.0.0.1:50609 10.104.16.212:5666 TIME_WAIT -
tcp 0 0 127.0.0.1:50567 10.104.16.212:5666 TIME_WAIT -
tcp 0 0 127.0.0.1:52592 10.3.81.172:5666 TIME_WAIT -
tcp 0 0 :::5666 :::* LISTEN 757/xinetd
I I have changed /etc/nagios/nrpe.cfg port to 56666 from 5666.
How can I configure different port in host configuration(different port for different host) in icinga2 server to monitor machines with nrpe running in different ports?
Is this right to change port? Or any other way to do this? Please correct me if I did anything wrong?

In each host definition add:
vars.nrpe_port = <host_nrpe_port>
Ref: docs.icinga.org

Added port in command.conf file like this,
object CheckCommand "check-nrpe" {
import "plugin-check-command"
command = ["/usr/local/nagios/libexec/check_nrpe"]
"-p" ="56666"
"-H" ="$host$"
"-c" = "$nrpe_command$"
"-a" = $nrpe_arguments$"
}
"-p" ="56666" Works for me!!
EDIT:
Or we can pass like arguments from host configuration ( keeping port number in host configuration like #7171u answer) .

Related

Use multiple interface to create tcp outbound connection to single IP and port(TCP server)

A TCP connection is determined by a 5-tuple: [local IP, local port, remote IP, remote port, protocol]. I can't change the remote IP, remote port, protocol. Now how can I create more than 65K(plan is to create more than 2L) concurrent TCP connection(which holds the connection for the logger time) from the same client when the ephemeral port is constant(1024–65535) on the client-side?
Question:
Multiple interfaces(multiple IP from the same client instance)can use the same ephemeral port to create an outbound TCP connection?
written one TCP client which is creating 15 TCP concurrent connections(holding for logger time) using eth1(10) and eth2(5) interface and enable only 10 ephemeral ports to use(49001 - 49010 ip_local_port_range file). And eth0 default interface doesn't use any port from 49001 - 49010 except 49001.
Now when I am trying to send a curl command getting an error
curl http://google.com -v
* Rebuilt URL to: http://google.com/
* Trying XXX.XXXX.XXXX.46...
* TCP_NODELAY set
* Immediate connect fail for XXX.XXX.XXX.46: Cannot assign requested address
* Trying XXXX:XXXX:XXXX:XXXX::XXXX...
* TCP_NODELAY set
* Immediate connect fail for XXXX:XXXX:XXXX:XXXX::XXXX: Network is unreachable
* Closing connection 0
curl: (7) Couldn't connect to server
tcp 0 0 xxx.xxx.xxx.245:49001 xxx.xxx.xxx.xxx:443 ESTABLISHED XXXX
tcp 0 0 xxx.xxx.xxx.116:49010 xxx.xxx.xxx.41:9999 ESTABLISHED 21805/client
tcp 0 0 xxx.xxx.xxx.116:49006 xxx.xxx.xxx.41:9999 ESTABLISHED 21805/client
tcp 0 0 xxx.xxx.xxx.248:49002 xxx.xxx.xxx.41:9999 ESTABLISHED 21805/client
tcp 0 0 xxx.xxx.xxx.116:49008 xxx.xxx.xxx.41:9999 ESTABLISHED 21805/client
tcp 0 0 xxx.xxx.xxx.248:49010 xxx.xxx.xxx.41:9999 ESTABLISHED 21805/client
tcp 0 0 xxx.xxx.xxx.248:49009 xxx.xxx.xxx.41:9999 ESTABLISHED 21805/client
tcp 0 0 xxx.xxx.xxx.248:49006 xxx.xxx.xxx.41:9999 ESTABLISHED 21805/client
tcp 0 0 xxx.xxx.xxx.116:49004 xxx.xxx.xxx.41:9999 ESTABLISHED 21805/client
tcp 0 0 xxx.xxx.xxx.248:49001 xxx.xxx.xxx.41:9999 ESTABLISHED 21805/client
tcp 0 0 xxx.xxx.xxx.248:49008 xxx.xxx.xxx.41:9999 ESTABLISHED 21805/client
tcp 0 0 xxx.xxx.xxx.248:49005 xxx.xxx.xxx.41:9999 ESTABLISHED 21805/client
tcp 0 0 xxx.xxx.xxx.116:49002 xxx.xxx.xxx.41:9999 ESTABLISHED 21805/client
tcp 0 0 xxx.xxx.xxx.248:49003 xxx.xxx.xxx.41:9999 ESTABLISHED 21805/client
tcp 0 0 xxx.xxx.xxx.248:49004 xxx.xxx.xxx.41:9999 ESTABLISHED 21805/client
tcp 0 0 xxx.xxx.xxx.248:49007 xxx.xxx.xxx.41:9999 ESTABLISHED 21805/client
In Linux you can have multiple sockets using the same source address and source port if you set SO_REUSEPORT on your sockets using setsockopt. You need to control the socket creation code for this to work, however.
As you noted you are still restricted in that the 5-tuple must be unique for all TCP sockets on your system.

Tight VNC server and Gucamole

I have a VM in which I installed the VNC server (TightVNC) using the link : https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-18-04
It is installed successfully and I can see the port 5901 running
/etc/tigervnc$ netstat -tulpn
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:5901 0.0.0.0:* LISTEN 16460/Xtigervnc
tcp 0 0 127.0.0.1:5902 0.0.0.0:* LISTEN 16183/Xtigervnc
tcp 0 0 127.0.0.53:53 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:631 0.0.0.0:* LISTEN -
tcp6 0 0 ::1:5901 :::* LISTEN 16460/Xtigervnc
tcp6 0 0 ::1:5902 :::* LISTEN 16183/Xtigervnc
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 ::1:631 :::* LISTEN -
udp 0 0 0.0.0.0:36618 0.0.0.0:* -
udp 29184 0 127.0.0.53:53 0.0.0.0:* -
udp 0 0 0.0.0.0:68 0.0.0.0:* -
udp 0 0 0.0.0.0:631 0.0.0.0:* -
udp 7680 0 0.0.0.0:5353 0.0.0.0:* -
udp6 0 0 :::37372 :::* -
udp6 20736 0 :::5353 :::*
Now from my local machine, I tried to do the port binding to my local from VM (as per the link https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-18-04)
ssh -L 5901:127.0.0.1:5901 -C -N -l test 172.1.1.1
In my local machine, I able to see the port is binded to 5901
/etc/guacamole$ fuser 5901/tcp
5901/tcp: 22049
Now when I try to take the VNC connection using 127.0.0.1:5901, It promopts for VM's password and shows only the blank page.
Could someone help me with this?
Thanks,
Hari
edit your ~/.vnc/xstartup file thus:
#!/bin/sh
startxfce4 &
I had the same problem and this solved it
For reference i got it from here:
https://www.raspberrypi.org/forums/viewtopic.php?t=52557
You can also try killing and restarting your VNC server
kill $(pgrep Xvnc)
vncserver
Are you trying to VNC from the local machine to the local machine? I am assuming just for testing correct?
If you are not getting a rejection, at least it should be talking to the service.

How to solve too many TCP connections on FIN_WAIT_2?

Server and client are connected using port 8000. Clients are aborted unexpectively but the connections are still there. Besides restarting server, any suggestion to release the legacy connections?
$ net stat -an | grep 8000
tcp4 0 0 127.0.0.1.8000 127.0.0.1.58761 CLOSE_WAIT
tcp4 0 0 127.0.0.1.58761 127.0.0.1.8000 FIN_WAIT_2
tcp4 0 0 127.0.0.1.8000 127.0.0.1.58755 CLOSE_WAIT
tcp4 0 0 127.0.0.1.58755 127.0.0.1.8000 FIN_WAIT_2
tcp46 0 0 *.8000 *.* LISTEN

Netstat command output description

In my project i'm checking for the ports availability during server startup. When server is in stop state all ports are showing available(using netstat command-nothing is returning) except the postgres port(5432) on linux. Same port is showing correct status in windows. Following is the netstat output for the 5432 port on linux when the server is not running. I'm wondering can someone please explain what exactly the output mean and why the same it is not showing in windows.
$ netstat -aon | grep "5432"
tcp6 0 0 127.0.0.1:36524 127.0.0.1:5432 TIME_WAIT timewait (24.23/0/0)
tcp6 0 0 127.0.0.1:36518 127.0.0.1:5432 TIME_WAIT timewait (1.85/0/0)
tcp6 0 0 127.0.0.1:36526 127.0.0.1:5432 TIME_WAIT timewait (28.95/0/0)
tcp6 0 0 127.0.0.1:36522 127.0.0.1:5432 TIME_WAIT timewait (21.85/0/0)
tcp6 0 0 127.0.0.1:36523 127.0.0.1:5432 TIME_WAIT timewait (24.18/0/0)
tcp6 0 0 127.0.0.1:36528 127.0.0.1:5432 TIME_WAIT timewait (31.48/0/0)
tcp6 0 0 127.0.0.1:36529 127.0.0.1:5432 TIME_WAIT timewait (31.53/0/0)
tcp6 0 0 127.0.0.1:36527 127.0.0.1:5432 TIME_WAIT timewait (29.00/0/0)
tcp6 0 0 127.0.0.1:36520 127.0.0.1:5432 TIME_WAIT timewait (11.85/0/0)
For all other ports netstat command output is empty when server is not running state. If possible please explain what each column is.
Thanks in advance.
Just run netstat without grep and you will see column names:
Proto | Recv-Q | Send-Q | Local Address | Foreign Address | State | Timer

telnet refused on specific port on AWS instances

I'm tryign to telnet from one linux env (10.205.116.141) to 10.205.117.246 on port 7199 but keep getting a connection refused. I did a chkconfig iptables off on both servers and even make sure iptables if stopped as well.
what else should I be looking at?
[root#ip-10-205-116-141 bin]# telnet 10.205.117.246 7199
Trying 10.205.117.246...
telnet: connect to address 10.205.117.246: Connection refused
trace route seems to be working as well...
[root#ip-10-205-116-141 bin]# traceroute 10.205.117.246 -p 7199
traceroute to 10.205.117.246 (10.205.117.246), 30 hops max, 60 byte packets
1 ip-10-205-117-246.xyz.cxcvs.com (10.205.117.246) 0.416 ms 0.440 ms 0.444 ms
also, I'm on a aws vpc so we don't get public IPs provisioned for use...
checked my security group and it looks like all ports are open as well
EDIT:
here is netstat as well, they look the same on both nodes:
[ec2-user#ip-10-205-116-141 ~]$ netstat -an | grep LISTEN
tcp 0 0 127.0.0.1:46626 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:9160 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:36523 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:9042 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:2738 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 10.205.116.141:7000 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8089 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:4445 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:7199 0.0.0.0:* LISTEN
shouldn't 127.0.0.1:7199 really be 10.205.116.141:7199?
sorry, can't post a sc of the security groups...

Resources