I have recetly learned that telnet is no more in OpenWrt
so i need to check if web interface is awalible but using somthing else but telnet
i have limited space right now on my router (400Kb)
is there any other way to check avaliblity of IP:PORT ?
netstat (local ports) ?
nc (netcat) ?
nmap ?
but how ? i need it in my script
the host wich i check is in Internet so there is no connections
can you show me an example how to check remote host ?
like i have remote hos 1.2.3.4:8888
what exactly do you need to check ?
pinging 8.8.8.8 will fail just as much is telnet a remote IP:PORT if internet is down ...
Internet is not down on my side
all works
and i want to check remote web host if it is avalible
or pop3 or any
so you're not really checking if internet is down, but if a remote site is, over internet ?
yes , as i know people use telnet for cheking remote host with port
but there is no more telenet in OpenWrt so i am looking for another way to check
wget or curl ?
if it times out/fails, the connection isn't working (doesn't obviously say why, and where, though).
or perhaps the remote host isn't using http/https ?
root@my:~# wget https://1.1.1.1:53
Downloading 'https://1.1.1.1:53'
Connecting to 1.1.1.1:53
(null) 0 - stalled -
Connection reset prematurely
root@my:~# wget https://83.169.210.130:8081
Downloading 'https://83.169.210.130:8081'
well it works yeah .
Thanks a lot i will try now
but if there are some more ways i awould appritiate to consider
i tried this example
nc -zv 192.168.1.15 22
but it says
nc: bad address '-zv'
i guees wget shoud work
works for me
root@OpenWrt:~# nc -zv 192.168.10.254 8989
192.168.10.254 [192.168.10.254] 8989 open
root@my:~# nc -zv 192.168.222.1:80
nc: bad address '-zv'
root@my:~# nc -zv 192.168.222.1:22
nc: bad address '-zv'
root@my:~# nc -zv 192.168.222.1 22
BusyBox v1.33.2 (2022-04-16 12:59:34 UTC) multi-call binary.
Usage: nc [IPADDR PORT]
Open a pipe to IP:PORT
root@my:~# nc -zv 192.168.222.1 80
BusyBox v1.33.2 (2022-04-16 12:59:34 UTC) multi-call binary.
Usage: nc [IPADDR PORT]
Open a pipe to IP:PORT
root@my:~#
strange i use OpenWrt maybe it has other options
My mistake.
I installed full netcat too, it "replaced" nc, I thought If I'd run nc I'd still get the busybox version, and netcat to get the full version.
i have install netcat full version it is tyni pokage
Thanks a lot it works with keys !
netcat -vzt -w 2 ya.ru 801
2 seconds time out !!
and for now my qwestion is how do i get answer from the command
there can be different answers
root@my:~# netcat -vzt -w 2 192.168.222.1 80
my.lan [192.168.222.1] 80 (www) open
root@my:~# netcat -vzt -w 2 192.168.222.1 81
my.lan [192.168.222.1] 81: Connection refused
root@my:~# netcat -vzt -w 2 192.168.222.2 81
192.168.222.2 [192.168.222.2] 81: Operation timed out
so how do i get these open connction refused in a variadle?
how to grep or awk these outputs id doesnt work for some reason
root@my:~# netcat -vzt -w 2 192.168.222.1 80 | grep -o "time"
my.lan [192.168.222.1] 80 (www) open
root@my:~#
:upside_down_face:
well it works like this
netcat -zv -w 2 192.168.222.1 80 2>&1 | awk -F " " '{print $5}'
Check the exit code:
~# netcat -z -w 2 ya.ru 80
~# echo $?
0
~# netcat -z -w 2 ya.ru 801
~# echo $?
1
ive tried
test=$('netcat -z -w 2 ya.ru 80')
echo "$test"
but nothing in that variable
or
tes=$(netcat -z -w 2 ya.ru 80)
echo "$tes"
or
tes=$(netcat -z -w 2 ya.ru 801 $?>&1)
echo "$tes"
I'm not sure if you are all set or are looking for more help but here is some help.
The comand output and command exit code are different things. If just testing for open ports with netcat is what you want then modify your approach like this:
netcat -z -w 2 ya.ru 80
test=$?
echo "$test"
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.