Wednesday, May 14, 2014

How to test a TCP or UDP port in linux

from http://superuser.com/questions/621870/test-if-a-port-on-a-remote-system-is-reachable-without-telnet

is this localhost's SSH running?
$ cat < /dev/tcp/localhost/22
SSH-2.0-OpenSSH_6.2p2 Debian-6
YEP

is port 8080 on 192.168.30.5 open?
$ cat < /dev/tcp/192.168.30.5/8080
-bash: connect: Connection refused
-bash: /dev/tcp/192.168.30.30/8080: Connection refused
NOPE

IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!

Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
...
Offending RSA key in /Users/coty/.ssh/known_hosts:13


If you know that the server key you're connecting to is the correct key - that is, it's changed because you're connecting to a server that shares an IP address with a server on a different network or VPN, or you've reinstalled or rekeyed the server in question - here's the quick sed command to "forget" the old key:

coty@jupiter:~$ sed -i".bak" '13d' ~/.ssh/known_hosts

Cisco IOS error: Static entry in use, cannot remove

This is a Cisco 2951 ISR running 15.0(1r)M16 (c2900-universalk9-mz.SPA.154-1.T.bin)

If a NAT entry is in use, you'll get an error:
router(config)# no ip nat inside source static tcp 192.168.30.5 80 interface GigabitEthernet0/1 12345
%Static entry in use, cannot remove

Clear the NAT translations first:
router(config)# do clear ip nat translation *

Then try again:
router(config)# ip nat inside source static tcp 192.168.30.5 80 interface GigabitEthernet0/1 12345
router(config)#

update apt-get's slow us.archive.ubuntu.com server setting

sudo sed -i 's`http://us.archive.ubuntu.com/ubuntu/`http://us-east-1.ec2.archive.ubuntu.com/ubuntu/`g' /etc/apt/sources.list