Mac telnet 安装

众所周知, MacOS 中的 Terminal 是没有内置 telnet 工具的,这无疑给网络问题分析造成了困扰,毕竟 telnet 命令是检查网络及端口是否打通的最便捷的方式。

1
2
3
Hzzs-MacBook-Pro:~ hzz$ telnet 127.0.0.1 8080
-bash: telnet: command not found
Hzzs-MacBook-Pro:~ hzz$

网上找了很多资料,大都是介绍在 新建远程连接 处进行 telnet 连接:

新建远程连接

但一条命令就能解决的事情,实在不想在界面进行折腾。

也曾尝试用 brew install telnetbrew 安装)来进行安装,但结果是找不到此软件包:

1
2
3
4
5
6
7
8
9
10
11
12
13
Hzzs-MacBook-Pro:~ hzz$ brew install telnet
Updating Homebrew...
Error: No available formula with the name "telnet"
==> Searching for a previously deleted formula...
Warning: homebrew/core is shallow clone. To get complete history run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
Error: No formulae found in taps.
Hzzs-MacBook-Pro:~ hzz$

Google 了半天后,终于发现,其实 telnet 的源码包并不叫 telnet ,而是叫 inetutils 。之前使用 Linux 时, telnet 都是自带的,所以没太注意。

brew search inetutils 后,发现存在这个包,遂使用 brew install inetutils 进行下载安装:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Hzzs-MacBook-Pro:~ hzz$ brew install inetutils
Updating Homebrew...
==> Installing dependencies for inetutils: libidn
==> Installing inetutils dependency: libidn
==> Downloading https://ftp.gnu.org/gnu/libidn/libidn-1.33.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/libidn/1.33 --disable-csharp --with-lispdir=/usr/local/Cellar/libidn/1.33/share/emacs/site-lisp/libidn
==> make install
==> Caveats
Emacs Lisp files have been installed to:
/usr/local/share/emacs/site-lisp/libidn
==> Summary
🍺 /usr/local/Cellar/libidn/1.33: 72 files, 1.3MB, built in 5 minutes 27 seconds
==> Installing inetutils
==> Downloading https://ftp.gnu.org/gnu/inetutils/inetutils-1.9.4.tar.xz
######################################################################## 100.0%
==> ./configure --disable-silent-rules --prefix=/usr/local/Cellar/inetutils/1.9.4 --with-idn --program-prefix=g
==> make install
🍺 /usr/local/Cellar/inetutils/1.9.4: 107 files, 2.6MB, built in 3 minutes 32 seconds
Hzzs-MacBook-Pro:~ hzz$

安装完成后,就可以愉快得使用 telnet 命令了:

1
2
3
4
5
6
7
8
9
Hzzs-MacBook-Pro:~ hzz$ telnet -V
telnet (GNU inetutils) 1.9.4
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by many authors.
Hzzs-MacBook-Pro:~ hzz$