Tag Archives: networking

Netcat – such a powerful ‘cat’!

I was just looking around info about netcat and telnet, trying to understand a bit more. Well… in few words: no point to install telnet if you have netcat! 🙂 Netcat is perfect for scripting, ’cause it’s non-interactive, UDP/TCP capable, can be a listener as well… very powerful tool. Here some example.

How to check if your httpd is up and running:

…and it closes gracefully 😉

How to check port-range ports:

… or a list of ports:

NOTE: If you want to grep or play with the “output” of the command, you need to use 2>&1
For example:

How to check the service that’s running on that port:

(From man) Alternatively, it might be useful to know which server software is running, and which versions. This information is often contained within the greeting banners. In order to retrieve these, it is necessary to first make a connection, and then break the connection when the banner has been retrieved. This can be accomplished by specifying a small timeout with the -w flag, or perhaps by issuing a “QUIT” command to the server:

In some cases, it’s handy to add -q 1 at the end, if nc hangs (I’ve noticed this in some cases) Like this:

Or how to send/receive a file:

On the receiver side:

On the sender side:

or

There are plenty of things that you can do. These are just simple examples… enjoy! 🙂

DNS updated via DHCP: BIND9 and ISC-DHCP on Linux

Linux: Debian stable (currently version 7)

Packages:

Create a key required for DHCP server to update the DNS zones:

This will create /etc/bind/rndc.key, whose contents will look something like this:

BIND configuration

Configuration files:

 

/etc/hosts

 

/etc/bind/named.conf.local

 

/etc/bind/named.conf.options

(just to setup the external forwarders)

 

/etc/bind/db.lab.loc

 

/etc/bind/db.10.0.60

 

DHCP configuration

Here there is just one file that has to be modified: dhcpd.conf

/etc/dhcp/dhcpd.conf

Here we need to enter the key in plain text.

 

Once everything is configured, just restart bind and dhcp:

 

Sources:

https://www.centos.org/docs/4/html/rhel-rg-en-4/s1-bind-zone.html