Bash for Networking

Netcat, lsof, TCP/IP Links: great udacity course

6 flashcards · Programming Languages · by lakesare

  1. What is netcat used for?

    The nc is used for just about anything under the sun involving TCP or UDP. It can: open TCP connections, send UDP packets, listen on arbitrary TCP and UDP ports, do port scanning Netcat is a lower-level tool than CURL, netcat doesn't know anything about HTTP. All netcat is doing is connecting to a port, and sending a string.

  2. netcat VS telnet?

    netcat is better: separates error messages onto standard error instead of sending them to standard output

  3. Starting from what port can netcat listen to? netcat -l .....PORT_NUMBER.....

    netcat -l 1024 sudo netcat -l 0 Ports under 1024 are reserved for the superuser. That's why when you try to start up an HTTP server (on port 80) you have to do it with sudo.

  4. What does lsof command do?

    ls open files In Unix everything is a file: pipes are files, IP sockets are files, unix sockets are files, directories are files, devices are files, inodes are files...

  5. What will happen if you run: printf 'HTTP/1.1 302 Moved\r\nLocation: https://www.eff.org/' | nc -l 2345

    Now go to localhost:2345, and we'll be redirected.

  6. host VS dig?

    host www.memcode.com => human-readable host ip information www.memcode.com is an alias for memcode.herokuapp.com. memcode.herokuapp.com is an alias for us-east-1-a.route.herokuapp.com. us-east-1-a.route.herokuapp.com has address 23.23.155.247 us-east-1-a.route.herokuapp.com has address 23.23.207.27 dig www.memcode.com => more strict, easily parsable by scripts information ; <<>> DiG 9.8.3-P1 <<>> www.memcode.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERR…