Computer Networking — Command line networking

In this lab we try out a bunch of stuff. You will need to follow alone with the instructor.

Where are you?

Here are some commands that tell you a little about your computer.

[…]$ hostname
[…]$ hostname -f
[…]$ ip addr
[…]$ ip addr | grep inet
[…]$ ip addr | grep link
[…]$ ip route
[…]$ netstat -a | more

A simple server and client

Let’s make a connection. You’ll need two computers with two windows on each computer. One computer is the server and the other is the client. One window is for the connecting and the other is for monitoring.

We will use the program nc. On some systems this program is called ncat or netcat.

Server computer – Connecting window

Start the server

[…]$ nc -kl 10373

Server computer – Monitoring window

The server should be listening for connections.

[…]$ netstat -a | grep 10373

Client computer – Connecting window

Connect to the server

[…]$ nc 10373
type something here

Client & Server computers – Monitoring window

The server and client should be connected.

[…]$ netstat -a | grep 10373

All windows

Type CTL-C to shut down all the programs.

Connecting to a web server

You can use nc to talk to the web server. You have to speak HTTP to download HTML. You will need to type these commands very carefully. The blank lines make a difference.

Using HTTP version 1.0

You need a blank line after the GET.

[…]$ nc 80

Using HTTP version 1.1

You need a blank line after the Host.

[…]$ nc 80
GET / HTTP/1.1

Being a web server

Pretend like you are a web server and use nc to finish the refresh.