ubuntu下使用xinetd知识
ubuntu下使用xinetd知识
ubuntu下使用xinetd知识
【知识点】
标准http响应文件内容
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Length: 0
Date: Wed, 27 Feb 2013 02:34:36 GMT
www.2cto.com
ubuntu下安装(系统级工具,一般不自定义安装)
apt-get install xinetd
【创建个服务脚本】
/root/shell/httpok.sh
#!/bin/sh
/bin/echo -e "HTTP/1.1 200 OK\r\n"
/bin/echo -e "Content-Type: Content-Type: text/plain\r\n"
/bin/echo -e "\r\n"
/bin/echo -e "hello xinetd\r\n"
/bin/echo -e "\r\n"
修改脚本权限(给user可执行权限)
chmod 755 /etc/xinetd.d/httpok
【创建xinetd服务】
vi /etc/xinetd.d/httpok
service my_httpok
{
flags = REUSE
socket_type = stream
#port = 9201
wait = no
user = root
server = /root/shell/httpok.sh
#log_on_failure += USERID
disable = no
#only_from = 192.168.5.0/24
#recommended to put the IPs that need to connect exclusively (security purposes)
}
www.2cto.com
【修改端口,方法有2种】
1.默认依赖/etc/services,此时/etc/xinetd.d/httpok这个文件配置的port无效,所以不需要配置
vi /etc/services
my_httpok 9201/tcp
2.解除依赖/etc/services
此时/etc/xinetd.d/httpok这个文件配置里需要加上
type = UNLISTED
port = 9201
【重启服务,测试端口访问】
service xinetd restart
curl http://127.0.0.1:9201/
评论暂时关闭