Docker
1 基础知识
一款可以使用MikroTik RouterOS MAC-Telnet协议连接MikroTik路由的telnet客户端软件。
2 最佳实践
2.1 部署Docker环境
本章使用如下Docker环境部署,参阅本章建议你先搭建以下Docker集群环境并熟悉,
2.2 创建新镜像
2.2.1 创建镜像项目文件夹
mkdir ~/imageProject-MAC-Telnet
2.2.2 创建Dockerfile
vim ~/imageProject-MAC-Telnet/Dockerfile
加入如下配置,
FROM centos:centos7 MAINTAINER will@cmdschool.org RUN echo https://github.com/haakonnessjoen/MAC-Telnet # Update OS RUN rm -rf /etc/yum.repos.d/* RUN curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo RUN yum update -y RUN yum -y install wget automake autoconf gcc make # Download fiels WORKDIR /root/ RUN wget https://codeload.github.com/haakonnessjoen/MAC-Telnet/tar.gz/refs/tags/v0.4.4 -O MAC-Telnet-0.4.4.tar.gz RUN tar xf MAC-Telnet-0.4.4.tar.gz RUN ls -la # Deploy MaC Telnet WORKDIR /root/MAC-Telnet-0.4.4/ RUN yum -y install gettext-devel RUN mkdir m4 RUN ./autogen.sh RUN ./configure RUN make RUN make install # Config Start Scripts CMD ["/usr/sbin/init"]
需要注意的是,
– “FROM”指令声明基于“centos:centos7”镜像打包
– “RUN”指令声明容器环境执行的命令
– “EXPOSE ”指令声明容器使用的端口
– “WORKDIR”指令声明切换容器内部的某个目录
– “CMD”指令声明启动容器执行的启动服务命令
2.2.3 执行打包操作
cd ~/imageProject-MAC-Telnet docker build -t build/mac-telnet:0.4.4 .
以上“.”指当前目录为编译目录,编译程序会自动加载“Dockerfile”文件定义,可见如下显示,
[...] Removing intermediate container 7057550931db ---> 40b64baa8b44 Successfully built 40b64baa8b44 Successfully tagged build/mac-telnet:0.4.4
完成后,可使用如下命令查看镜像,
docker images
可见如下显示,
REPOSITORY TAG IMAGE ID CREATED SIZE build/mac-telnet 0.4.4 40b64baa8b44 About a minute ago 812MB [...]
2.2.4 测试软件运行
docker run -it --rm --net=host --name mac-telnet build/mac-telnet:0.4.4 /bin/bash
然后,可通过以下命令测试安装,
mactelnet -h
可见如下显示,
MAC-Telnet 0.4.4 Usage: mactelnet [-h] [-n] [-a ] [-A] [-t ] [-u ] [-p ] [-U ] | -l [-B] [-t ] Parameters: MAC MAC-Address of the RouterOS/mactelnetd device. Use mndp to discover it. identity The identity/name of your destination device. Uses MNDP protocol to find it. -l List/Search for routers nearby (MNDP). You may use -t to set timeout. -B Batch mode. Use computer readable output (CSV), for use with -l. -n Do not use broadcast packets. Less insecure but requires root privileges. -a Use specified path instead of the default: ~/.mactelnet for autologin config file. -A Disable autologin feature. -t Amount of seconds to wait for a response on each interface. -u Specify username on command line. -p Specify password on command line. -U Drop privileges to this user. Used in conjunction with -n for security. -q Quiet mode. -h This help.
测试完成后可使用如下命令退出容器虚拟机,
exit
另外,也可以这样用,
docker run -it --rm --net=host build/mac-telnet:0.4.4 macping 80:2a:a8:cc:8f:2d docker run -it --rm --net=host build/mac-telnet:0.4.4 mactelnet 80:2a:a8:cc:8f:2d docker run -it --rm --net=host build/mac-telnet:0.4.4 mndp 80:2a:a8:cc:8f:2d docker run -it --rm --net=host build/mac-telnet:0.4.4 mactelnetd 80:2a:a8:cc:8f:2d
参阅文档
=================
https://github.com/haakonnessjoen/MAC-Telnet
没有评论