Documente Academic
Documente Profesional
Documente Cultură
This tool sends ARP (Address Resolution Protocol) packets on local network to collect the
addresses. If there is multiple MAC addresses claiming the same IP address, then there is
conflict.
Q. I run quite large network with different subnets. I’d like to know how can I find out duplicate IP address under
Linux / UNIX?
A. You can use arpping command. The arping utility performs an action similar to ping command, but at the Ethernet
layer. You can send ARP REQUEST to a neighbor host / computers.
Received 3 response(s)
Where,
-I eth0 : Specify network interface i.e. name of network device where to send ARP REQUEST packets. This
option is required.
-c 3 : Stop after sending 3 ARP REQUEST packets
/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
Where in the above "ifcfg-eth0" answers to your network interface eth0 . If your
interface is named “ eth1" then the file that you will need to edit is "ifcfg-eth1" .
Let’s start with the first file:
# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=node01.tecmint.com
GATEWAY=192.168.0.1
NETWORKING_IPV6=no
IPV6INIT=no
Next open:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Note: Make sure to open the file corresponding to your network interface. You can find
your network interface name with ifconfig -a command.
In that file make the following changes:
DEVICE="eth0"
BOOTPROTO="static"
DNS1="8.8.8.8"
DNS2="4.4.4.4"
GATEWAY="192.168.0.1"
HOSTNAME="node01.tecmint.com"
HWADDR="00:19:99:A4:46:AB"
IPADDR="192.68.0.100"
NETMASK="255.255.255.0"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="8105c095-799b-4f5a-a445-c6d7c3681f07"
Next edit resolve.conf file by opening it with a text editor such as nano or vi:
# vi /etc/resolv.conf
Once you have made your changes restart the networking with:
# nano /etc/network/interfaces
auto eth0
auto eth0
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 4.4.4.4
dns-nameservers 8.8.8.8
# nano /etc/resolv.conf
The most essential part of networking is assigning IP address, default gateway and DNS server IP
address. An IP address is the unique identity of a computer in network. Without it computer will not
be able to communicate with other computers in network. Before we learn how to assign an IP
address, let’s learn how to view the current IP configuration.
To view the current IP configuration we can use ip addr show command. This command supports
abbreviate form which means we can use ip a s command instead of ip addr show command. Even
more we can use just ip a command. By default this command will list current IP configuration of all
interfaces.
Current State :- First line shows the current state of interface. UP keyword indicates that interface is
currently UP and functioning properly.
MAC Address :- Next line shows the hardware (MAC) address with broadcast address of interface.
IPv4 Address :- This line shows the current IPv4 configuration (IP Address, Subnet Mask, Broadcast
address) on interface.
IPv6 Address :- This line shows the current IPv6 configuration on interface.
Interface Name :- First keyword shows the name of interface. In earlier version NICs were named as
eth (Ethernet), em (embedded) and wlan (wireless lan). NICs were numbered based on the order of
detection during the system boot. For example first discovered Ethernet (eth) would be named and
numbered as eth0. This naming scheme has scalability issue. For example a system which has multiple
NICs and NICs are dynamically removed or added, in this situation this naming scheme will work not
effectively. From RHEL7 default naming convention for NICs is based on firmware, device, topology
and device types. With new naming convention network card names always remain consist. In new
naming convention :-
First two letters represents the type of NIC. For Ethernet interface it always begins with en, for WLAN interfaces
it begins with wl, for loopback adapters it starts with lo and for WWAN it begins with ww.
Next letter represents the location of NIC. For onboard letter o is used, for hot plug slot letter a is used and for
PCI slot letter p is used.
Remaining numeric numbers represents the index, port or ID number.
For example above figure illustrates the name used by NIC is eno16777734. In this name en stands for
Ethernet device, o stands for onboard and 16777734 stands for unique index number. Combinedly
eno16777736 stands for an onboard Ethernet device (with its unique index number).
To view the IP configuration of a specific interface we can use its name as argument with ip addr
show command.
To view only link state, use ip link show command for all interfaces and ip link show
[interface] command for a particular interface.
To view the default gateway IP use ip route show command.
To add new (or additional) temporary IP configuration on NIC we can use ip addr add dev
[inteface] command.
Okay now we know how to view the IP configuration. But have you wonder from where this IP
configuration comes? Let’s figure out the answer.
Every interface has an associated configuration file which stores its relative parameters such IP
address, protocol and configuration values. These configuration settings are automatically applied on
interface while it get activated. RHEL uses a central location for all (NICs) configuration files which
is /etc/sysconfig/network-scripts directory.
Configuration file’s name start with ifcfg and followed by the name of network card. For example
configuration file for eno16777736 Ethernet card will be ifcfg-eno16777736.
Let’s have a look in this file and understand some important configuration settings
BOOTPROTO :- This directive defines how this interface should receive IP configuration. There are
four valid options; dhcp, bootp, none and static.
DEFROUTE :- This directive defines whether to use this interface as default route or not.
DNS1 :- This directive is used to specify the first DNS sever IP address.
ONBOOT :- This directive defines whether to activate this interface at system boot or not.
How to configure IP Address
To configure IP address we have three options; nmtui text tool, nm-connection-editor graphic utility
and nmcli command. We will understand all three options one by one. Let’s start with nmtui text tool.
Select NIC from left pane on which you want to set the IP address and select Edit option from right
pane and press Enter key.
Set the IP address / subnet mask, Gateway IP address and DNS Server IP address.
Select OK and press Enter key to accept the change
When we exit from nmtui utility, it automatically updates the associated configuration files.
For instance in above example we have assigned IP configuration to NIC eno16777736. In this case
nmtui will update the /etc/sysconfig/network-scripts/ifcfg-eno16777736 file. An interface
restart is required to apply the new configuration. We can use ifdown-[NIC] and ifup-
[NIC] commands to restart the interface.
Now let’s do the same task from nm-connection-editor graphical utility. Login from root account and
open terminal. In terminal execute nm-connection-editor command.
From opened window select appropriate NIC and click Edit option
Switch to IPv4 Settings and select Manual option from Method drop down menu. Click Add button
and configure IP addresses in respective fields and click Save button and Close button at main
screen.
Restart the interface and verify the new IP configuration.
nmcli con show:- This command will list the available connections with their associated devices.
A device is the network interface card and connection is the configuration used by device. A device
can have multiple connections.
As above figure shows connection eno16777736 is associated with Ethernet device eno16777736. We
will modify this connection to update the IP configuration.
nmcli con mod eno16777736 ipv4.addresses 192.168.1.100/24 :- This command will set the
new IP address and subnet mask.
nmcli con mod eno16777736 ipv4.gateway 192.168.1.1 :- This command will set the new
default gateway IP address.
nmcli con mod eno16777736 ipv4.dns 192.168.1.1 :- This command will set the new DNS Server
IP address.
As we know new IP configuration applies on start-up. Next two commands will restart the interface.
Key points
nm-connection-editor is available only in X-Window system. It provides less but sufficient features for end
users to manage the network connections. Network administrators rarely use this tool to manage the network
connections.
Usually nmcli command and nmtui tool are used to manage the network connection.
Among these options, nmcli command is the most powerful.
nmcli command is little bit hard to learn but works in every condition.
In exam you can use nmtui text tool instead of nmcli command.
For real life system administration its worth to learn nmcli command as it is available in most situations such as
rescue mode, remote connection, terminal etc.
Where,
sa3tHJ3/KuYvI
Above will display the crypted password (sa3tHJ3/KuYvI) on screen. The Perl crypt() function is a one way
encryption method meaning, once a password has been encrypted, it cannot be decrypted. The password string is
taken from the user and encrypted with the salt and displayed back on screen.
paU5t8Al/qf6M
Sample shell script to add a user
Based upon above discussion here is a sample shell script (Download link):
#!/bin/bash
if [ $? -eq 0 ]; then
exit 1
else
[ $? -eq 0 ] && echo "User has been added to system!" || echo "Failed to
add a user!"
fi
else
exit 2
fi
Close and save the script:
$ ./adduser.sh
Only root may add a user to the system
Run as root:
# ./adduser
Output:
As described by the others, writing to /dev/null eliminates the output of a program. Usually cron sends an
email for every output from the process started with a cronjob. So by writing the output to /dev/null you
prevent being spammed if you have specified your adress in cron.
I use >> /dev/null 2>&1 for silent cronjob, cronjob will do the job but not send report to my email.
As far as I know, don't remove /dev/null, it's useful especially when you running cpanel, can be used for
throw away cronjob report.
/dev/null - standard file that discards all you write to it, but reports that the write operation
succeeded. 1 is stdout and 2 is stderr. 2>&1 redirects stderr to stdout. &1 indicates file descriptor(stdout),
otherwise(if you use just 1) you will redirect stderr to file named 1. [any command] >>/dev/null
2>&1 redirects all stderr to stdout, and writes all of that to /dev/null.
read -p "Please enter the username you wish to create : " username
username=""
fi
done
read -p "Please enter the primary group. If group not exist, it will be created : " group
else
groupadd $group
fi
done
bash="/bin/bash"
fi
homedir="/home/$username"
fi
fi
Sample Result
sudo ./linux_user.sh
Please enter the primary group. If group not exist, it will be created : test
read -p "Please enter the primary group. If group not exist, it will be created : " group
else
groupadd $group
fi
done
#check if no input
bash="/bin/bash"
fi
#check if no input
homedir="/home/$username"
fi
#if input y
fi
Storage Management on Linux are classified into three types:
1. DAS(Direct?attached storage)
2. NAS (Network?attached storage)
3. SAN(Storage?Area?Network)
1. DAS(Direct?attached storage)
Direct?attached storage (DAS) refers to a digital storage system directly connected to a server or
digital computer, while not a storage network in between.
It’s a retronym, principally wont to differentiate non?networked storage from SAN and NAS
A typical DAS system is created of a knowledge device connected on to a laptop through a host bus
adapter (HBA).
Between those 2 points there’s no network device (like hub, switch, or router), and this is often the
most characteristic of DAS.
the most protocols used for DAS connections are ATA, SATA, eSATA SCSI, SAS, and Fibre
Channel.
2. NAS (Network?attached storage)
Network?attached storage (NAS), in distinction to SAN, uses file?based protocols like NFS or
SMB/CIFS wherever it’s clear that the storage is remote, associate degreed computers request some
of an abstract file instead of a disk block.
3. SAN(Storage?Area?Network)
A Storage Area Network (SAN) could be a dedicated network that has access to consolidated, block
level information storage.
SANs are primarily wont to build storage devices, like disk arrays, tape libraries, and optical
jukeboxes, accessible to servers in order that the devices appear as if regionally connected devices
to the package.
A SAN generally has its own network of storage devices that square measure typically not
accessible through the native space network by different devices. the price and quality of SANs
born within the early 2000s to levels permitting wider adoption across each enterprise and tiny to
medium sized business environments.
Features of SAN
# tgtadm --lld iscsi --op new --mode logicalunit --tid 1--lun 1 -b /dev/sdb1
Copy
# fdisk -l
# mkdir /mnt/clientsan
# mount /dev/sdb1 /mnt/clientsan
Copy
Congratulation now you have Installed SAN Storage Server & Configure on CentOS/RHEL 7/6/5
and any difficulties regarding to this use comment section below.