jamie's blog

Using dnsmasq to setup your own dhcp/dns server on your local computer

Tue, 09/04/2012 - 17:04 -- jamie

At this point, you have learned that DHCP is a protocol that allows a server to assign an IP address to a client and DNS is a protocol that takes a domain name and returns an IP address.

Now, we are going to install a program called dnsmasq that provides both a DHCP server and DNS server that will run from your laptop computer.

By installing this server, you will be able to assign, via DHCP, IP addresses to your virtual servers and provide DNS lookup for them.

Begin by installing the dnsmasq package with:

sudo apt-get install dnsmasq

Introduction to Bash programming

Tue, 09/04/2012 - 16:59 -- jamie

Bash is a simple programming language typically used by system administrators to automate tasks.

Try creating a new file with this command:

nano my-script

Type the following into your file:

#!/bin/bash
echo "Hello World!"

Then, save and exit.

Execute your new bash script with:

bash my-script

With a Bash program (aka script) anything you type on the command line can be placed into the script. For example, try creating a bash script with the following contents:

Connecting commands together with the pipe

Tue, 09/04/2012 - 16:58 -- jamie

One of the philosophies that Linux has inherited is the idea that we should create small programs that do one thing well. If we want to do more complex tasks, we can combine multiple programs to do more complex things.

One way that programs are combined on the command line is by using the "pipe" character (aka |).

The pipe character takes the output of the first command and sends it as input to the second command.

Adding virtual bridges

Tue, 09/04/2012 - 16:58 -- jamie

If you have ever used a switch (or a hub) you are familiar with the idea of "bridging" - a process that allows you to connect multiple computers (or more specifically network interfaces) to each other. All data that comes from one interface is shared with the other interfaces.

The same principle applies to virtual bridges, except all the network interfaces are on one computer.

Adding virtual network devices

Tue, 09/04/2012 - 16:57 -- jamie

If you have ever plugged a network cable into a computer, you are familiar with what a physical network interface is like.

Sometimes, it's useful to create "virtual" network interfaces. For example, if you are running multiple virtual servers on a single computer, each virtual server will need a virtual network interface in order to communicate with the network.

You can see a list of all your existing network interfaces with the ip link command:

ip link

Depending on how your computer is configured, you will usually see:

Understanding netmask and CIDR notation

Sun, 08/26/2012 - 20:00 -- jamie

The Internet is made up of many smaller networks, also known as local area networks (LANs) or subnets, that are connected to each other by routers.

When your computer tries to communicate with another computer, it has to make many decisions about where to send the information. One of the first decisions is whether to try to communicate with a computer on the local network, or whether to rely on the router (aka gateway) to forward the information to a computer on a different network.

Configuring network manually using IP commands

Sun, 08/26/2012 - 19:36 -- jamie

Sometimes, it's usefull to congifure your network device directly, without editing a file like /etc/network/interfaces.

You can review the IP addresses currently available with:

ip addr show

You can also see the routes currently available with:

ip route show

You can remove an address using the following command:

ip addr del LINE-YOU-WANT-TO-DELETE

You can remove a route with:

ip route del LINE-YOU-WANT-TO-DELETE

Manually bringing your interfaces up and down

Sun, 08/26/2012 - 19:23 -- jamie

Although your laptop will automatically bring your ethernet and wifi interfaces up and down for you, there are times when you will need to do that manually.

Debian provides two commands for this purpose:

ifup INTERFACE
ifdown INTERFACE

Your ethernet interface is typically referred to as eth0 and your wifi interface is typically referred to as wlan0.

So, to bring down your ethernet interface, you can type:

ifdown eth0

And, to bring it backup, type:

ifup eth0

Using dig to query a DNS server

Sun, 08/26/2012 - 19:07 -- jamie

DNS (Domain Name System) translates from a domain name to an IP address.

This usually happens behind the scenes - if you type a domain name like mayfirst.org into your web browser, your webrowser looks up the domain name, translates it into an IP address, queries the server responding to the IP address and then displays the web page - all the while, the actual IP address is hidden from you.

Sometimes, it's useful to manually do a lookup, particularly when you are debugging a problem that might be the result of a lookup failure.

Pages

Subscribe to RSS - jamie's blog