XINETD TCP echo service
程序员文章站
2022-07-15 15:11:21
...
https://goyalankit.com/blog/xinetd
XINETD - Extended Internet Daemon
April 16, 2017
I was recently looking into ways to provide ssh access inside linux network namespaces and came across xinetd. So I decided to dig more into it. Noting it down here so that I can refer it back.
XINETD
It’s basically a daemon that listens for network requests and services them by spawning more processes.
The master configuration for xinetd lives in /etc/xinetd.conf. Each service managed by xinetd has a configuration file in /etc/xinetd.d/.
Each network service is listed in /etc/services that xinetd could potentially manage.
Let’s look at an example from one of the services in /etc/xinetd.d/ to see how it works:
An echo service
This was a default service that was present on my RHEL6 box. There were lots of settings in this file which were basically commented out. Most of them are self explanatory, so I have omitted them for brevity.
$ sudo cat /etc/xinetd.d/echo-stream
# This is the configuration for the tcp/stream echo service.
service echo
{
# This is for quick on or off of the service
disable = yes
# The next attributes are mandatory for all services
id = echo-stream
type = INTERNAL
wait = no
socket_type = stream
# protocol = socket type is usually enough
}
echo service simply provides an echo service (duh). But what port does it listen to? The port can be checked in /etc/services file, search for echo in file, and on my machine it had an entry that looked like this:
$ sudo cat /etc/services | grep echo
echo 7/tcp
If you try to connect to this port; the connection will fail since the disabled flag is set to yes in the above configuration file.
$ telnet 172.22.210.126 7
Trying 172.22.210.126...
telnet: connect to address 172.22.210.126: Connection refused
telnet: Unable to connect to remote host
Let’s enable the service by setting disable = no in /etc/xinetd.d/echo-stream. In addition, you’d need to restart the xinetd service.
$ sudo service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
Now again, let’s try to connect to service.
$ telnet 172.22.210.126 7
Trying 172.22.210.126...
Connected to angoyal-ld2.linkedin.biz.
Escape character is '^]'.
hola <---- I said hola to Server.
hola ----> Server said hola back.
^]
telnet> q
Connection closed.
Sweet.
You can use xinetd to run your own network service and have full control. I have some ideas which I’ll document if they work.
So long.
XINETD - Extended Internet Daemon
April 16, 2017
I was recently looking into ways to provide ssh access inside linux network namespaces and came across xinetd. So I decided to dig more into it. Noting it down here so that I can refer it back.
XINETD
It’s basically a daemon that listens for network requests and services them by spawning more processes.
The master configuration for xinetd lives in /etc/xinetd.conf. Each service managed by xinetd has a configuration file in /etc/xinetd.d/.
Each network service is listed in /etc/services that xinetd could potentially manage.
Let’s look at an example from one of the services in /etc/xinetd.d/ to see how it works:
An echo service
This was a default service that was present on my RHEL6 box. There were lots of settings in this file which were basically commented out. Most of them are self explanatory, so I have omitted them for brevity.
$ sudo cat /etc/xinetd.d/echo-stream
# This is the configuration for the tcp/stream echo service.
service echo
{
# This is for quick on or off of the service
disable = yes
# The next attributes are mandatory for all services
id = echo-stream
type = INTERNAL
wait = no
socket_type = stream
# protocol = socket type is usually enough
}
echo service simply provides an echo service (duh). But what port does it listen to? The port can be checked in /etc/services file, search for echo in file, and on my machine it had an entry that looked like this:
$ sudo cat /etc/services | grep echo
echo 7/tcp
If you try to connect to this port; the connection will fail since the disabled flag is set to yes in the above configuration file.
$ telnet 172.22.210.126 7
Trying 172.22.210.126...
telnet: connect to address 172.22.210.126: Connection refused
telnet: Unable to connect to remote host
Let’s enable the service by setting disable = no in /etc/xinetd.d/echo-stream. In addition, you’d need to restart the xinetd service.
$ sudo service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
Now again, let’s try to connect to service.
$ telnet 172.22.210.126 7
Trying 172.22.210.126...
Connected to angoyal-ld2.linkedin.biz.
Escape character is '^]'.
hola <---- I said hola to Server.
hola ----> Server said hola back.
^]
telnet> q
Connection closed.
Sweet.
You can use xinetd to run your own network service and have full control. I have some ideas which I’ll document if they work.
So long.
上一篇: 架构师技术图谱,助你早日成为架构师
下一篇: 配置Django的Celery异步