5.1 Using Network Configuration Tools: Unit V:Networking and TCP/IP

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

BSC[CS] TY, LINUX ADMINISTRATION

Unit V:Networking and TCP/IP


5.1 Using Network Configuration Tools
We can configure the networking devices either by using command line tools or
by the graphical configuration tools. To configure a network client host using the
command line, we can use a combination of commands or edit specific files
under the /etc/sysconfig directory.

To configure the hardware through a graphical interface we can use the Red Hat’s
graphical tool called redhat-config-network / system- config-network or the
console-based netconfig (netcfg) command.
BSC[CS] TY, LINUX ADMINISTRATION

Command line network interface configuration:

• We can configure a network interface from the command line using the basic
Linux networking utilities. We can configure the network client hosts with the
command line by using commands to change the current settings or by editing a
number of system files. Two commands, ifconfig & route, are used for network
configuration. The netstat command displays information about the network
connections.

/sbin/ifconfig command

• ifconfig command is used to configure network interface. We can use it to

address, netmask or broadcast address.

-to-point connection.

• The basic structure of this command is as follows:

/sbin/ifconfig [network device] options

• If no argument is given, ifconfig displays the status of active interfaces.

# /sbin/ifconfig

The output is easily understood, the above command will display the current status
of the system regarding the network, for example the IP address, subnet mask etc.
The ifconfig command can be used to display information about or control a specific
interface. For example to deactivate the first Ethernet device on a host, use the
ifconfig command like this -

# ifconfig eth0 down


BSC[CS] TY, LINUX ADMINISTRATION

Linux ifconfig

The command ifconfig stands for interface configurator. This command enables us
to initialize an interface, assign IP address, enable or disable an interface. It display
route and network interface.

You can view IP address, MAC address and MTU (Maximum Transmission Unit)
with ifconfig command.

A newer version of ifconfig is ip command. ifconfig command works for all the
versions.
Syntax:

# ifconfig
BSC[CS] TY, LINUX ADMINISTRATION

Get details of specific interface


To find IP address of all three differently, use command

1. ifconfig eth0
2. ifconfig lo
3. ifconfig wlan0

/sbin/route command
• The second command used to configure the network is the route command.
route is used to build the routing tables(in memory) implemented for routing
packets as well as displaying the routing information. It is used after ifconfig has
initialized the interface. route is normally used to set up static routes to other
networks via the gateway or to other hosts. The command configuration is like
this:
/sbin/route [options] [commands] [parameters]
• To display the routing table, use the route command with no options. The
display will look similar to this:
# /sbin/route

The route command displays and manipulate IP routing table for your system.
A router is a device which is basically used to determine the best way to
routepackets to a destination.

Syntax:

1. route
BSC[CS] TY, LINUX ADMINISTRATION

 In the first column, Destination is the IP address of receiving host. The


default entryis the default gateway for this machine.

 The Gateway column lists the gateway that the packets must go through to
reach their destination.

 An asterisk (*) means that packets go directly to the host. Genmask is the
netmask.

 The Flags column can have several possible entries. In this example, U
verifies that the route is enabled & G specifies that Destination requires the
use of a gateway.
 The Metric column displays the distance to the Destination. Some daemons
use this to figure the easiest route to the Destination.

 The Ref column is used by some UNIX flavors to convey the references to the
route. It is not used by LINUX.

 The Use column indicates the number of times this entry has been looked up.
Finally, the Iface column is the name of the interface for the corresponding
entry.

 Using the –n option to the route command will give the same information
Displaying numerical IP address

This command displays output in full numerical form.

Syntax:

# route -n
BSC[CS] TY, LINUX ADMINISTRATION

Linux ping command:


Linux ping command stands for (Packet Internet Groper). It checks connectivity
between two nodes to see if a server is available. It sends ICMP
ECHO_REQUEST packets to network hosts and displays the data on the remote
server's response. It checks if a remote host is up, or that network interfaces can
be reached. Further, it is used to check if a network connection is available
between two devices. It is also handy tool for checking your network connection
and verifying network issues.

Ping command keeps executing and sends the packet until you interrupt.

To stop the execution, press "CTRL+C" keys.

Syntax:

The ping command supports various command-line options. But, the basic syntax
for the ping command is as follows:

ping <option> <destination>


Options:

The ping command supports the following command-line options:

-4: It used to use IPv4 only.

-6: It is used to use IPv6 only.

-a: It is used for the audible ping.

-A: It is used for an adaptive ping.

-b: It is used to ping a broadcast address.

-B: It is used for not changing the source address of probes.

-c count: It is used to stop after sending count ECHO_REQUEST packets.

Examples of the ping Command

Let' see the following examples of the ping command:

o Ping Using DNS


o Ping Using IP address
o Limit the packets
BSC[CS] TY, LINUX ADMINISTRATION

o Check if a remote host is up


o Check IPv4 Connectivity
o Check IPv6 Connectivity
o Add a timestamp before each line
o Specify the Source Interface
o Change Time Interval Between Ping Packets

netstat
netstat(Network Statistics) is the command that is used to display routing table,
connection information, the status of ports, etc. This command works with
Linux Network Subsystem. This command basically displays the content of
/proc/net file defined in the Linux file system.
BSC[CS] TY, LINUX ADMINISTRATION

5.2 Advanced Wireless Networking:


Computer networks that are not connected by cables are called wireless
networks. They generally use radio waves for communication between the
network nodes. They allow devices to be connected to the network while roaming
around within the network coverage.

 Wireless LANs − Connects two or more network devices using wireless


distribution techniques.
 Wireless MANs − Connects two or more wireless LANs spreading over a
metropolitan area.
 Wireless WANs − Connects large areas comprising LANs, MANs and
personal networks.
BSC[CS] TY, LINUX ADMINISTRATION

Advantages of Wireless Networks


 It provides clutter-free desks due to the absence of wires and cables.
 It increases the mobility of network devices connected to the system since the
devices need not be connected to each other.
 Accessing network devices from any location within the network coverage or Wi-
Fi hotspot becomes convenient since laying out cables is not needed.
 Installation and setup of wireless networks are easier.
 New devices can be easily connected to the existing setup since they needn’t be
wired to the present equipment. Also, the number of equipment that can be added
or removed to the system can vary considerably since they are not limited by the
cable capacity. This makes wireless networks very scalable.
 Wireless networks require very limited or no wires. Thus, it reduces the
equipment and setup costs.
Examples of wireless networks

 Mobile phone networks


 Wireless sensor networks
 Satellite communication networks
 Terrestrial microwave networks

 What are the advanced technologies in wireless communication?

Recently, the advances in various wireless communication protocols in


technologies such as 5G, RFID, Wi-Fi-Direct, Li-Fi, LTE, and 6LoWPAN
have greatly boosted the potential capabilities of IoT and made it become more
prevalent than ever, which also accelerate the further integration of IoT with
emerging technologies
Advanced Wireless Networks gives readers a comprehensive integral presentation
of the main issues in 4G wireless networks, showing the wide scope and inter-
relationbetween different elements of the network.
This book adopts a logical approach, beginning each chapter with introductory
material, before proceeding to more advanced topics and tools for system
analysis. Its presentation of theory and practice makes it ideal for readers working
with the technology, or those in the midst of researching the topic.

 Covers mobile, WLAN, sensor, ad hoc, bio-inspired and cognitive networks as


well as discussing cross-layer optimisation, adaptability and reconfigurability
 Includes hot topics such as network management, mobility and hand-offs,
BSC[CS] TY, LINUX ADMINISTRATION

adaptive resource management, QoS, and solutions for achieving energy efficient
wireless networks Discusses security issues, an essential element of working
with wireless networks Supports the advanced university and training courses in
the field and includes an extensive list of references

# iwlist

Iwlist is used to display some additional information from a wireless network


interface that is not displayed by iwconfig(8). The main argument is used to
select a category of information, iwlist displays in detailed form all information
related to this category.

# iwconfig
What is the iwconfig command in Linux?
iwconfig is used to display and change the parameters of the network
interface which are specific to the wireless operation (e.g. interface name,
frequency, SSID). It may also be used to display the wireless statistics.
(extracted from /proc/net/wireless ).

The command iwconfig configures a wireless network interface. You can view
and set basic wi-fi details like SSID and encryption. Please refer man page of
iwconfig for more details.
BSC[CS] TY, LINUX ADMINISTRATION

5.3 DHCP (Dynamic Host Configuration Protocol)


• As the name implies Dynamic Host Configuration Protocol (DHCP) configures
hosts for connections. DHCP allows a network administrator to configure all
TCP/IP parameters for each host as the connection has been established to the
networkafter activation of a NIC.
• DHCP provides persistent storage of network parameters by holding identifying
information for each network client that might connect to the network. The three
most common pairs of identifying information are

– Used by hosts to connect the network at will


hostname – Enables the specified host to connect to the subnet
– Enables a specific client to connect to the
network after setting the hostname.

• DHCP also allocates to client’s temporary or permanent network (IP) addresses.


Once a temporary assignment, known as a lease, has elapsed, the client can
request to have the lease extended, or, if the address is no longer needed, the
client hands-over the address.
• For hosts that will be permanently connected to a network with adequate
addresses available, DHCP allocates infinite leases.

• Configuring DHCP Server:


• The first step to see whether the DHCP is already in service. Use the following
command
# ps ax | grep dhcpd
• If it is running an instance of dhcpd will be displayed. If it is not running we
need to configure the dhcpd. Assuming that it is running, the first step is to try
running dhcpdin the foreground as shown below

# dhcpd –f
• Along with other information, an error message will be displayed as shown
below can’t open /etc/dhcpd.conf: No such file or directory existing
BSC[CS] TY, LINUX ADMINISTRATION

• Notice the error stating it can’t find /etc/dhcpd.conf. After getting this error the
next step is to create the file. The following is a simple example of dhcpd.conf
for aserver
at 192.168.100.1

subnet 192.168.100.0 netmask 255.255.255.0{


range 192.168.100.200 192.168.100.240;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.255;
option routers 192.168.100.1;
option domain-name-servers 19.168.100.1;

option domain-name “cocsit.com”;


option ip-forwarding on;
option netbios-node-type 8;
}
Configuring a Linux based DHCP Client
Setting a Linux client as a DHCP client requires addition or modification of one
line in one file. The file is /etc/sysconfig/network-scripts/ifcfg-eth0. The line is
BOOTPROTO=static
• If that line exists, it specifies that the eth0 interface’s IP address is a static
address, specified by other lines in the file. To make the client a DHCP client,
change the line as follows, or if doesn’t exists, add the following line:
BOOTPROTO=dhcp
• Then restart the client’s network interface with the following
command. # /etc/rc.d/init.d/network restart
• After making this change execute the ifconfig command on the client, we will
see that client’s IP address is now an address from the range specified by the
server’s dhcpd.conf file.
BSC[CS] TY, LINUX ADMINISTRATION

• To switch back to static addressing, change back to BOOTPROTO=static


& restart the Network.

5.4 Setting Up a Telnet Server, Setting Up an SSH Server

Telnet is a remote Login Program. You can Divide Telnet in to Two parts: Telnet-
Server and Telnet-Client. Telnet server is the Machine which allows users to login
to it through remote and the machines which are logged in remotely through telnet
on Telnet Server is known as Telnet Client
Linux telnet Command
In Linux, the telnet command is used to create a remote connection with a system
over a TCP/IP network. It allows us to administrate other systems by the terminal.
We can run a program to conduct administration.

It uses a TELNET protocol. However, this protocol has some security defects, but it
is one of the most used networking protocols due to its simplicity.

telnet hostname/IP address

Configuring common Telnet server settings


installing telnet on Linux is a straight forward process. We can install it by executing
the following commands:

Update the Linux system by executing the below command:

sudo apt update

The above command will prompt for the user password. Type the password and
press ENTER key; it will start a daemon process and take a while to update your
system.

To install the telnet, execute the below command:

$ sudo apt install telnetd -y


BSC[CS] TY, LINUX ADMINISTRATION

The above command will install the required package for the telnet protocol.
Consider the below output:

To verify the installation and whether the service is running or not, execute the below
command:

# systemctl status inetd

Consider the below output:

How to connect by telnet command in Linux?

To create a connection between two systems by telnet command is a simple


process, execute the telnet command followed by the hostname.

For example, we are connecting our system with the localhost. Execute the
command as follows:

# telnet localhost
BSC[CS] TY, LINUX ADMINISTRATION

The above command will ask for the user name and password, enter the
credential to proceed. Consider the below output:

After connecting, we can execute the commands as done before. The only difference
is that now the machine is treated as a remote machine.
To exit the telnet command, execute the logout command.
# logout
consider the below output:

Now we have successfully logged out from the remote connection.

Setting Up an SSH Server:


In Linux, ssh is a protocol, which stands for Secure Shell or Secure Socket
Shell. The secure shell is useful for security while connecting to a remote server.
The ssh command uses a ssh protocol, which is a secure protocol, as the data
transfer between the client and the host takes place in encrypted form. It transfers
the input through the client to the host and returns the output transferred by the
host. It executes through TCP/IP port 22.
BSC[CS] TY, LINUX ADMINISTRATION

The encrypted connection is also used to run the commands on a Linux


server, port forwarding, tunnelling, and more.

There are lots of SSH clients that are available for both commercial and free. The
OpenSSH is its most widely used client. It is available for all the most used
platforms such as Windows, Linux, macOS, OpenBSD, and more.

Syntax:
ssh user_name@host(IP/Domain_name)

Components of ssh command

The ssh command consists of three different types of components:

o ssh command: It instructs the machine to create a secure encrypted connection


with the host system.
o User name: User name is the name of the Linux user, which is being accessed
by the host machine.
o Host: A host is a machine that is being accessed by the user, such as a computer
or a router. A domain name or an IP address also refers as Host.

How SSH works?

To establish an SSH connection, we need two primary components; a client and a


host, which can be a server, domain name, IP address, and more. Also, we
require a ssh client to connect with another computer or server. The client uses
the specified host information to establish the connection; if the provided
credential verified, it will establish an encrypted connection.
BSC[CS] TY, LINUX ADMINISTRATION

The server (Host) contains an SSH process that is ready to take a request for the
client connection through a TCP/IP port. Once the client initiates a connection,
the host responds with the necessary information and exchanges the credentials.

If the provided information is verified, the SSH protocol establishes a new


connection for the available environment.

The default SSH protocol version for SSH server and SSH client communication
is version 2.

Install OpenSSH client on Linux (Ubuntu)

The OpenSSH client is a connectivity tool for the systems to connect two
systems with the ssh protocol. It is also called as ssh and can be invoked from the
Linux terminal. This client package contains other SSH utilities like sftp, scp,
and ssh that are installed by default with the ssh command. It performs remote
operations using these ssh utilities.

The OpenSSH client comes preinstalled with most Linux distributions. If any
Linux system does not have the ssh client, we can install it manually by using the
package manager.

To install the OpenSSH client, execute the below command:

$ sudo apt update

The above sudo command will update the package of the Linux system. Consider
the below snap of the output:

After updating the Linux system, execute the below command to install the
OpenSSH client:

$ sudo apt install OpenSSH-client

The above command will install the latest package of the OpenSSH client.
Consider the below output:
BSC[CS] TY, LINUX ADMINISTRATION

As we can see from the above output, a daemon process is running to install the
OpenSSH client. As in our machine, OpenSSH client is already installed, so it
has displayed the message 'openssh-client is already the newest version.

To check the installation status of the server, open the terminal and execute the
below command:

$ ssh localhost

If our machine does not have the server tool kit of the OpenSSH client, then it
will display the output as follows:

In the above case, we have to install the OpenSSH server.

To install the SSH server, execute the below command:

$ sudo apt-get install openssh-server ii

The above command will prompt for the system administrative password, type
the password, and press ENTER key to start the installation process. Next, it will
confirm the installation type 'y' key and press ENTER key. Consider the below
output:
BSC[CS] TY, LINUX ADMINISTRATION

After confirming the installation, a daemon process will begin and install the
OpenSSH server on your machine.

To verify the installation, execute the below command:

$ sudo service ssh status


BSC[CS] TY, LINUX ADMINISTRATION

You might also like