8/25/2014

Configure Network Bonding in Ubuntu Server

Overview


Network bonding is the aggregation or combination of multiple lan cards into a single bonded interface to provide high availability and redundancy. Network bonding is  also known as NIC teaming.

In this article we will discuss how to configure network bonding in Ubuntu 14.04 LTS Server. In my scenario I have two Lan Cards : eth0 & eth1 and will create a bond interface bond0 with active-passive or active-backup mode.

Step:1 Install bonding Kernel module using below command


root@mail:~#  apt-get install ifenslave-2.6

Step:2 Load the kernel module.


Edit the file /etc/modules and add the bonding module at the end .

root@mail:~# vi /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.
lp
rtc
bonding

Save & exit the file

Now load the module using modprobe command as shown below :

# sudo modprobe bonding

Step:3 Edit interface config file.


# sudo vi /etc/network/interfaces

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

#eth0 is manually configured, and slave to the bondo interface

auto eth0
iface eth0 inet manual
bond-master bond0
bond-primary eth0

#manually configured eth1 and second interface used in bonding(bond0)

auto eth1
iface eth1 inet manual
bond-master bond0

# bond0 is the bonding NIC and can be used like any other normal NIC.

# bond0 is configured using static network information.
auto bond0
iface bond0 inet static
address 192.168.1.151
gateway 192.168.1.1
netmask 255.255.255.0
dns-nameservers 4.2.2.2
bond-mode active-backup
bond-miimon 100
bond-slaves none

Step:4 Restart the networking service & see the bond interface status


root@mail:~# service networking restart

Verify the bond interface using below command :

# ip add

ip-add
We can also use ifconfig command to see the bond interface.

Now check the bond interface status using below command :

# cat /proc/net/bonding/bond0

verify-bond-interface

Note : To do the testing we can down one interface and access the server and see the bond status.

8/21/2014

How to set up a Samba file server to use with Windows clients

According to the Samba project web site, Samba is an open source/free software suite that provides seamless file and print services to SMB/CIFS clients. Unlike other implementations of the SMB/CIFS networking protocol (such as LM Server for HP-UX, LAN Server for OS/2, or VisionFS), Samba (along with its source code) is freely available (at no cost to the end user), and allows for interoperability between Linux/Unix servers and Windows/Unix/Linux clients.
For these reasons, Samba is the preferred solution for a file server in networks where different operating systems (other than Linux) coexist - the most common setup being the case of multiple Microsoft Windows clients accessing a Linux server where Samba is installed, which is the situation we are going to deal with in this article.
Please note that on the other hand, if our network consists of only Unix-based clients (such as Linux, AIX, or Solaris, to name a few examples), we can consider using NFS (although Samba is still an option in this case), which has greater reported speeds.

Installing Samba in Debian and CentOS

Before we proceed with the installation, we can use our operating system's package management system to look for information about Samba:
On Debian:
# aptitude show samba
On CentOS:
# yum info samba
In the following screenshot we can see the output of 'aptitude show samba' ('yum info samba' yields similar results):
Now let's install Samba (the screenshot below corresponds to the installation on a Debian 7 [Wheezy] server):
On Debian:
# aptitude install samba
On CentOS:
# yum install samba

Adding Users to Samba

For versions earlier than 4.x, a local Unix account is required for adding users to Samba:
# adduser
Next, we need to add the user to Samba using the smbpasswd command with the '-a' option, which specifies that the username following should be added to the local smbpasswd file. We will be prompted to enter a password (which does not necessarily have to be the same as the password of the local Unix account):
# smbpassword -a
Finally, we will give access to user xmodulo to a directory within our system that will be used as a Samba share for him (and other users as well, if needed). This is done by opening the /etc/samba/smb.conf file with a text editor (such as Vim), navigating to the end of the file, and creating a section (enclose name between square brackets) with a descriptive name, such as [xmodulo]:
1
2
3
4
5
6
7
8
9
# SAMBA SHARE
[xmodulo]
path = /home/xmodulo
available = yes
valid users = xmodulo
read only = no
browseable = yes
public = yes
writeable = yes
We must now restart Samba and -just in case- check the smb.conf file for syntax errors with the testparm command:
# service samba restart
# testparm
If there are any errors, they will be reported when testparm ends.

Mapping the Samba Share as a Network Drive on a Windows 7 PC

Right click on Computer, and select "Map network drive":
Type the IP address of the machine where Samba is installed, followed by the name of the share (this is the name that is enclosed between single brackets in the smb.conf file), and make sure that the "Connect using different credentials" checkbox is checked:
Enter the username and password that were set with 'smbpasswd -a' earlier:
Go to Computer and check if the network drive has been added correctly:
As a test, let's create a pdf file from the man page of Samba, and save it in the /home/xmodulo directory:
Next, we can verify that the file is accessible from Windows:
And we can open it using our default pdf reader:
Finally, let's see if we can save a file from Windows in our newly mapped network drive. We will open the change.log file that lists the features of Notepad++:
and try to save it in Z:\ as a plain text file (.txt extension); then let's see if the file is visible in Linux:

Enabling quotas

As a first step, we need to verify whether the current kernel has been compiled with quota support:
# cat /boot/config-$(uname -r) | grep -i config_quota
Each file system has up to five types of quota limits that can be enforced on it: user soft limit, user hard limit, group soft limit, group hard limit, and grace time.
We will now enable quotas for the /home file system by adding the usrquota and grpquota mount options to the existingdefaults option in the line that corresponds to the /home filesystem in the /etc/fstab file, and we will remount the file system in order to apply the changes:
Next, we need to create two files that will serve as the databases for user and group quotas: aquota.user andaquota.group, respectively, in /home. Then, we will generate the table of current disk usage per file system with quotas enabled:
# quotacheck -cug /home
# quotacheck -avugm
Even though we have enabled quotas for the /home file system, we have not yet set any limits for any user or group. Check for quota information for existing user/group:
# quota -u
# quota -g
Finally, the last couple of steps consist of assigning the quotas per user and / or group with the quotatool command (note that this task can also be performed by using edquota, but quotatool is more straightforward and less error-prone).
To set the soft limits to 4 MB and the hard limit to 5 MB for the user called xmodulo, and 10 MB / 15 MB for the xmodulogroup:
# quotatool -u xmodulo -bq 4M -l '5 Mb' /home
# quotatool -g xmodulo -bq 10M -l '15 Mb' /home
And we can see the results in Windows 7 (3.98 MB free of 4.00 MB):