Skip to content

Webinar-Building Linux Servers-DCHP, DNS, and DS

You will need the following:

  • Debian Server virtual machine. (command line only)
  • Linux client virtual machine. (Any client will do. Though not necessary, this can be command line only as well, which can save you time and resources.)
  • Fedora Server virtual machine. (command line only)
  • (Optional) Fedora Workstation virtual machine.

Debian Server Install in VirtualBox

This video demonstrates how to:

  • Locate and download the Debian .iso image.
  • Setup a virtual machine in VirtualBox.
  • Create a NAT network in VirtualBox.
  • Install Debian 10 as a server (command line only and no GUI).
  • Update the operating system and install programs.
  • Configure the hostname, static IP address, and DNS server address.
  • Configure port forwarding in VirtualBox.
  • SSH into the new virtual machine.

Duration: 54 minutes.

In the video I am using a Windows 10 computer with VirtualBox version 6.1 installed.

See below for links and step-by-steps. Enjoy!

  • Debian can be downloaded from this link
  • VirtualBox can be downloaded from this link
  • VirtualBox virtual networking documentation: link

I chose VirtualBox for this tutorial because it is free and it runs on most operating systems. But you are free to use another virtualization platform if you wish (VMware Workstation, ESXi, KVM, Xen, Proxmox, and so on). If you are using another platform, then I assume you know what you are doing. On this webpage I focus mostly on VirtualBox. (However, during my webinars, KVM is my go to tool. Check it out here if you haven't already!)

Note

If you use VMware workstation, put your initial virtual machine in "My Computer" and not "Shared". Reason being, you can't clone VMs in the Shared section, which you will need to do later.

Question

Do you like written procedures in addition to video instruction? Well, here you go. Once you get the virtual machine created in VirtualBox, and start the installation of Debian, follow the next procedure.

Step-by-step Debian installation instructions:

  1. To get used to working with the keyboard only, select the second option "Install" instead of "Graphic install".
  2. Name the server debserver, the domain is example.com
  3. Write down or memorize your root password
  4. Create a user account named user
  5. For the partitioning method select "Guided – use entire disk"
  6. For the partitioning scheme select "All files in one partition"
  7. Finish, and write the changes to disk
  8. Select "No" for scanning another disc
  9. If you are unsure, use the deb.debian.org mirror
  10. Most of you will not use an HTTP proxy
  11. Important! Software selection:

    • Deselect "Debian desktop environment" and "print server"
    • Select "SSH server"
  12. Install the GRUB boot loader to the main device.

  13. Reboot, login as root and check for Internet connectivity.

Example: ping example.com

Now...

configure Debian as shown in the video following the additional steps below.

  • Update Debian

    First check for any updates to the OS and apps:

    apt update

    Then, if any are available, and you are comfortable installing them, issue this comand:

    apt upgrade

  • Install packages

    In the following command we are installing vim as our default text editor, curl to be able to transfer data via HTTP and other protocols, and git so that we can access and download Github repositories.

    apt install vim curl git

  • Modify the hostname

    We want our hostname to be:

    debserver.example.com

    Modify this in /etc/hostname. I use vim during the video, but if you wish, you can use nano which is built in to Debian. Examples:

    vim /etc/hostname

    nano /etc/hostname

    Which editor you use doesn't matter to me, as long as you get the job done. However, if you want to follow along with what I am doing, I suggest using vim. You could also type the following command to change the hostname:

    hostnamectl set-hostname debserver.example.com

  • Set a static IP address

    Not all servers use a static IP, but many do. You will have to configure the IP address manually. Do this in /etc/network/interfaces. Change dhcp to static and add the following information:

    address 10.0.2.4/24
    gateway 10.0.2.1

    Your actual IP address can be different. The one I am using above is 10.0.2.4 and will be the address I use during the webinar. The one I used in the video is 10.0.2.16/24. It doesn't make much of a difference what you use, as long as you know and remember what it is.

Note

It is okay to use the current IP address that was assigned by the DHCP server. To find out what this is type ip a. To find out the current gateway address, type ip route show. (I may use other IP addresses during live webinars.)

This portion of your interfaces configuration file should now look something like this:

# The primary network interface
allow-hotplug enp1s0
iface enp1s0 inet static
    address 10.0.2.4/24
    gateway 10.0.2.1
  • Modify the DNS server IP address

    Do this in /etc/resolv.conf

    Remove any content that is there and add the following:

    nameserver 10.0.2.1

Warning

Using the nameserver 10.0.2.1 makes use of VirtualBox's built in DNS forwarding capability, which is often slower than just using your LAN's DNS address. Be ready for slower pings and other responses from Internet hosts. If it is too slow, or simply doesn't work, use the DNS server IP on your LAN (the one used by your SOHO router, or other device).

  • Reboot the system

  • Check your work

    Use ip a to verify your IP address. Use ip route show to verify your default gateway. Verify the DNS configuration here: /etc/resolv.conf. Finally, ping a website domain to verify Internet connectivity. For example, ping example.com. You should get successful results similar to the following:

PING example.com (93.184.216.34) 56(84) bytes of data.
64 bytes from 93.184.216.34 (93.184.216.34): icmp_seq=1 ttl=58 time=12.7 ms
64 bytes from 93.184.216.34 (93.184.216.34): icmp_seq=2 ttl=58 time=15.9 ms
  • Setup SSH capability

    This is shown in the previous video and the step-by-step procedure here.

That's it!

Your Debian server should now be set up. Go ahead and clone it to make debclient. Or, you can use any Linux client you wish with a desktop environment. I'll be using a Debian and/or Fedora client with desktop environment.

Now all you need is a Fedora Server (and optionally a Fedora Workstation). See this for a video on how to install Fedora Server.

Creating a NAT Network in VirtualBox

You can create a NAT network in VirtualBox from the graphical user interface (GUI), as shown in the previous video, or from the command line interface (CLI).

Option 1: (GUI)

  1. Go to File > Preferences > Network.

  2. Click the + sign to the right. A new NAT Network will be created. You can use the default 10.0.2.0/24 IP network if you wish, and the task is complete. If you wish to use a different IP network, then continue to the following optional steps.

  3. Double-click the new NAT Network.

  4. In the Network CIDR field, change the IP scheme to whatever you wish. For example, to use something different than 10.0.2.0, enter in 192.168.15.0/24.

  5. Press OK for all open windows.

Afterward, in the VirtualBox VM settings, go to Network, then in the "Attached to:" drop down menu select the NAT network that you just created.

Option 2: (CLI)

In Windows you need to navigate to the following path and run the command below.

C:\Program Files\Oracle\Virtualbox

Note

If you have issues using Powershell, use the Command Prompt instead.

In Mac and Linux you can run the command from any directory:

VBoxManage natnetwork add --netname natnet1 --network "192.168.15.0/24" --enable --dhcp on

Adjust the name of the NAT Network and the IP scheme as you see fit. The name of the NAT Network in the example is “natnet1” and the IP scheme is 192.168.15.0/24

Afterward, in the VirtualBox VM settings, go to Network, then in the "Attached to:" drop down menu select the NAT network that you just created.

How to setup SSH capability into a VirtualBox guest on a NAT Network.

Guests on a VirtualBox NAT network can access external systems and the Internet. However, by default, the host computer cannot access the guests. At times, you might want to connect from your host computer to a VirtualBox guest with SSH in the command line. To allow this, add a port forwarding rule in VirtualBox by following the steps below.

  1. Go to File > Preferences > Network, and then double-click the appropriate NAT Network.

  2. In the NAT Network window click Port Forwarding.

  3. Click the + sign to add a new rule, similar to the figure below. The Guest IP address will vary depending on your VM’s IP and your particular NAT Network setup. For example, it could be a different IP address on the 10.0.2.0 network, or on a different NAT network altogether if you created a separate one.

  4. Connect to the guest with SSH using a command similar to the following:

    ssh -p 2222 user@127.0.0.1

    Note

    The port number portion (-p 2222) can go before or after 'user@127.0.01'.

    Be ready to supply the password of the user account on the guest computer.

The connection on the IP address 127.0.0.1 and port 2222 will redirect to the IP address of the guest (in the video it’s 10.0.2.16) and port 22. That should begin an SSH session.
For every other VM that you want to connect to, simply create a new rule and increase the port number by one. For example, 2223, 2224, and so on.

Sidebar

You will need to have an SSH client in order to connect to your virtual machines. For most of you, SSH will be installed by default. If not, check the following:

Windows 10: Go to Settings > Apps. Then click the Optional features link. From here you can add the feature: OpenSSH Client. In some cases you might have to enable the OpenSSH service. Go to Run > services.msc, and then locate, enable and start the service there. You can also install OpenSSH with Chocolatey. (Install Chocolatey from this link. Then, type choco install openssh.)

Linux: You can install OpenSSH on any Linux client. For example, for Debian, type apt install openssh-client. For Fedora, use dnf. In some cases you might just need to enable and start the service as it may already be installed. To enable it type systemctl enable sshd. To start it, type systemctl start sshd.

But again, most client operating systems today will have SSH installed. If that is not the case, and the above options do not work, you can also consider other SSH client solutions: Putty, Kitty, Terminus, and so on.


Fedora Server Install

For this video I am installing Fedora Server 32 to VirtualBox that is running on a Debian 10 computer. Here I show how to download and install VirtualBox to Linux, create a virtual machine, configure a NAT network, and of course, install Fedora Server to the virtual machine. I also briefly show how to configure SSH capability in VirtualBox. (My apologies, there is a little bit of video glitchiness a couple of times during the video.)

Duration: 32 minutes

Essentially, the steps are as follows:

  1. Download the .iso image from here.

  2. Create a new VM and point it to the downloaded media.

    (2 MB RAM, 1 CPU, and 12 GB of drive space should be enough. I use more in the video, but that is not mandatory.)

  3. Start the installation. Choose the first option on the startup screen.

  4. Choose your language.

  5. Installation Summary screen:

  6. Select “Installation Destination” and just click done.

  7. Change the time zone to fit your location.

  8. Check the network settings and change the name of the system to fed-ipa.example.com.

  9. Set a root password.

  10. Create a user account named user.

  11. Begin Installation. Let it go for several minutes.

  12. When finished, reboot.

  13. Login as root

After you have logged in, check and configure the following:

Hostname: this should be:

fed-ipa.example.com

You can change this in /etc/hostname

IP address: configure a static IP address. You can use the same address that was assigned bythe DHCP server if you wish. Modify the IP configuration with nmcli. For example:

nmcli con mod enp0s3 ipv4.address 10.0.2.5/24 ipv4.gateway 10.0.2.1 ipv4.dns 10.0.2.1 ipv4.method manual

Note

In this example our network adapter name is enp0s3 but yours may be different. The IP address is 10.0.2.5, but again, yours may differ. There are several other ways to accomplish this configuration, but the above is a nice one-liner.

After you run the above command you will have to down and up the network adapter. For example:

nmcli con down enp0s3

and

nmcli con up enp0s3

Then, type nmcli to verify the configuration. Check the IP address and the DNS server within the nmcli results. You can check the gateway address with the command:

ip route show

SSH capability: make sure you can SSH into the Fedora Server virtual machine. In VirtualBox the port forwarding trick I show in the video is one option. The step-by-step written procedure for that is here.

Success

That's it. Your Fedora Server should now be set up and ready to use during the webinar. Enjoy!


GRUB Modification of Console Resolution and Font Changes with dpkg-reconfigure

When working with servers that have no GUI and are command line only (or console only) the resolution is usually not configured optimally by default. Also, the font is often small and hard to read. This video shows you how to change the resolution and font of the Debian console by working with GRUB and dpkg-reconfigure respectively. I also briefly describe how it works in Fedora Server.

Modifying the console resolution in Debian

  • First, we enter the GRUB area of Linux by pressing C when Debian Linux is first booting.

  • Then, run the command set pager=1 so that we can view results one page at a time.

  • Next, run the vbeinfo command to see the resolutions that our system can handle. Consider the best resolution for your setup. In the video I use 1280x720.

  • Enter the command normal to return to normal boot.

  • Open the /etc/default/grub file. To modify the resolution change this line:

    GRUB_CMDLINE_LINUX_DEFAULT="quiet"

    to this:

    GRUB_CMDLINE_LINUX_DEFAULT="nomodeset"

    and add this line:

    GRUB_GFXPAYLOAD_LINUX=1280x720

  • Update the GRUB bootloader. Run the following command:

    update-grub

    Make sure that it takes effect. You may have to run it twice.

  • Reboot the system with the reboot command.

Note

You can also modify the splash screen in the grub file with the following command: GRUB_GFXMODE=1280x720

Modifying the font type and size in Debian

  • Change the font type and size by running:

    dpkg-reconfigure console-setup

    In the video I selected TerminusBold and 11x22. Try some different settings and see what works best for you.

It's all about getting the right resolution and font for your configuration. That will vary depending on the type of system you are working on.

Fedora Server console resolution and font modifications

  • Although there are different ways of doing this, the method shown for modifying the resolution in Debian will work in Fedora as well. The only difference is the update command. Instead of update-grub type

    grub2-mkconfig

  • Font modification is slightly different on Fedora Server. First, install the console-setup package if it is not already:

    dnf install console-setup

    Then, access the console-setup file:

    vim /etc/default/console-setup

    Add or modify the following to your liking. For example: the TerminusBold font with an 11x22 font size.

FONTFACE=TerminusBold
FONTSIZE="11x22"

Note

You will notice that all of the changes in this lab do not affect the initial Linux bootup screen (or splash screen). That can also be modified in GRUB, but is a bit more complicated. If you are interested in a step-by-step for that, there are multiple solutions on the Internet. For example, look at the Debian User Forums here for solutions. Personally, I'm not overly concerned with that because that portion of the bootup phase is very quick.


Fedora Workstation Install

In this video I install Fedora 32 Workstation using KVM as my virtualization platform. This operating system is optional for the webinar, but during the webinar, I will be showing how to connect it as a client to a FreeIPA domain. Feel free to install it if you want to follow along. I start by showing how to create a virtual machine in KVM (Virtual Machine manager) during the first portion of the video. If you wish to skip right to the Fedora Workstation installation, move ahead to 7 minutes and 30 seconds. After the installation I check the networking settings, install vim, change the hostname, and make a few other basic configurations.

Duration: 19:40

You can download Fedora Workstation at this link. You have a couple different options there so make sure to download the correct image for your platform.

You can use whatever virtualization platform you want. For a tutorial on how to use VirtualBox, see the first video from this documentation page. Again, I'm using KVM, but that is for speed. I don't expect you to know or use KVM during the webinar. (But it is awesome, just so you know...)


How to shut off DHCP in the Virtualization Platform (VirtualBox, VMware Workstation, and KVM)

In the webinar we set up a Linux-based DHCP server. If you have a DHCP server already running (and you most likely do) then there can be a conflict. So the pre-existing DHCP server should be temporarily shut off. If you are running a virtualization platform using NAT, then the program has a built-in DHCP server. This video shows how to disable that DHCP server in VirtualBox, VMware Workstation, and KVM. If you are working in bridged mode, then you would need to disable the DHCP server on your LAN.

Warning

Important! Do not attempt to disable a DHCP server in a work or production environment. You will most likely be tracked down and roasted alive.

Duration: 10:30

The video starts with VirtualBox.

VMware Workstation is at 2:15.

KVM is at 4:45.

VirtualBox

Shut down any running virtual machines.

Go to File > Preferences > Network.

Double-click your NAT Network.

Deselect the checkbox for "Network Options: Supports DHCP

Click OK for both Windows.

Close and restart VirtualBox.

VMware Workstation

Shut down any running virtual machines.

Go to Edit > Virtual Network Editor.

Click Change Settings. Be ready to supply an administrator password.

Click the NAT network at the top.

Deselect the checkbox that says: "Use local DHCP service to distribute IP addresses to VMs.

Click Apply and OK.

KVM

Here you have two options: modify the KVM network with virsh, or modify the configuration file directly. As root, do one of the following:

  • Option 1: Type:
virsh net-edit default

Default is the name of the first KVM network that is made automatically for you. Replace "default" with the name of your network if you created another one.

  • Option 2: Type:
vim /etc/libvirt/qemu/networks/default.xml

Note

I prefer to make a backup of the file in case any modifications have unforeseen errors. Do this by typing:

cp default.xml default-backup.xml

For either of these, you need to remove the DHCP section:

    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254'/>
    </dhcp>

Then, restart the Virtual Machine Manager.

Note

Newer versions of the Virtual Machine Manager may have a simple checkbox to disable DHCP instead of having to modify default.xml, or using the command virsh net-edit default.

Note

I don't support VMware Fusion, but click here for an article that might help you with Fusion DHCP and Fusion networking in general. Another good link that might help is here.

That's all folks! I'll see you on the Internet!