Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Is there any alternative to echo daemon to display ip instead of given string?

For ex: my ip =

server ip =

root@my-machine bash$ telnet
Connected to
Escape character is '^]'.
share|improve this question
What would you need this for? This sounds like a case of the XY problem. It might be better to ask a question about what you actually want to achieve using this. –  Thomas Nyman Oct 25 '13 at 8:50
I got my monitoring server, also i got lots of clients behind the NAT all over the world. Of course there are a lot of different network configurations. So I want to know their external ip. (clients can connect to server) –  Mark van-Hauser Oct 25 '13 at 8:52
There are web services, which do this. From a shell you could get the the external IP via for instance wget -O - -q ; echo –  Thomas Nyman Oct 25 '13 at 8:58
unfortunately there is no access to =( –  Mark van-Hauser Oct 25 '13 at 9:04

3 Answers 3

up vote 3 down vote accepted

Here's a small implementation of what you want in Python (run it as <port>:

#!/usr/bin/env python

import socket
import sys

_, port = sys.argv

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(("", int(port)))

while True:
    conn, addr = sock.accept()
    ip, port = addr
    conn.send(ip.encode("ascii") + b"\n")
$ ./ 1234 &
[1] 20315
$ nc localhost 1234
share|improve this answer
Thank you! Already did it with ruby =) –  Mark van-Hauser Oct 25 '13 at 10:53

With socat:

socat tcp-listen:12345,reuseaddr,fork system:'echo "$SOCAT_PEERADDR"'
share|improve this answer

In short, no. The Echo Protocol description in RFC 862 is very simple and unambigious:

TCP Based Echo Service

One echo service is defined as a connection based application on TCP. A server listens for TCP connections on TCP port 7. Once a connection is established any data received is sent back. This continues until the calling user terminates the connection.

UDP Based Echo Service

Another echo service is defined as a datagram based application on UDP. A server listens for UDP datagrams on UDP port 7. When a datagram is received, the data from it is sent back in an answering datagram.

share|improve this answer
Yeah, I know it. So is there a kind of echo service that will provide me with external ip like, but on tcp layer level. –  Mark van-Hauser Oct 25 '13 at 8:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.