0% found this document useful (0 votes)
4 views20 pages

Ch4 Net Config - en

The document provides an overview of network configuration in Linux, detailing commands such as 'hostname' for setting the system's name, 'ifconfig' for managing network interfaces, and 'ping' for testing connectivity. It also covers configuration files, diagnostic tools like 'netstat' and 'traceroute', and commands for managing dynamic IP addresses and routing. Additionally, it includes examples for using FTP and Telnet to connect to servers.

Uploaded by

Hussein assaad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views20 pages

Ch4 Net Config - en

The document provides an overview of network configuration in Linux, detailing commands such as 'hostname' for setting the system's name, 'ifconfig' for managing network interfaces, and 'ping' for testing connectivity. It also covers configuration files, diagnostic tools like 'netstat' and 'traceroute', and commands for managing dynamic IP addresses and routing. Additionally, it includes examples for using FTP and Telnet to connect to servers.

Uploaded by

Hussein assaad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Ch4

Network Configuration Linux

2021-2022 1
hostname

Defined hostname or display name of the current host system. A privileged user can define the hostname with the
hostname argument.

Exemple:
# hostname: give the name of the Linux system
# hostname PC1: to assign the name PC1 to the computer

Syntaxe
Hostname [option] [name of Host]

Options
-d, display the DNS domain name.
-f, Display the fully qualified domain name.
-i, Display the host's IP address (es).

2021-2022 2
Configuration Tools (ifconfig)

• ifconfig - Configure Network Devices


The ifconfig tool is used to check or change the state of network interfaces.
Syntax
$ ifconfig interface parameters

Exemple:
$ ifconfig eth0 192.168.3.45 netmask 255.255.255.0 up
The ip address 192.168.3.45 and the netmask 255.255.255.0 are added to the eth0 interface.

2021-2022 3
Configuration Tools (ifconfig)

If the parameters are not given, the interface and the configuration of this interface are given.
If the interface is not specified, it will list all the information available for the active interfaces

2021-2022 4
Configuration Tools (ifconfig)

• Activating Interfaces
$ ifconfig eth0 up
This command will activate the eth0 interface.
$ ifconfig eth0 down
This will close the eth0 interface.
The interface must be chosen so that the correct interface is enabled or disabled.

2021-2022 5
Configuration Files

• /etc/host.conf: contains information about all hosts.


• /etc/resolv.conf: contains names and IP addresses
• / etc / services: contains a list of network ports and services
corresponding to those ports.

2021-2022 6
Diagnostic Tools (ping)

• ping - Test Network Connections

• Purpose of ping
This program will help determine if a computer is online by sending
an ICMP ECHO_REQUEST. The expected response is in the form of
ICMP ECHO_RESPONSE. In other words, there should be a
response back from the machine that was contacted.

Syntax
$ ping [options] destination

• Example:
$ ping 192.168.4.35

2021-2022 7
Diagnostic Tools (ping)

• ping Options
 -c count number of packets to send
 -s size determines the size of the packets to be sent
 -I Interface which network card to use
 -i interval time interval

2021-2022 8
Diagnostic Tools (ping)

• Count Option

Example:

$ ping -c 100 192.168.4.35

The -c option sets the number of pings to occur before the


command is terminated. In this example, the destination
will be pinged 100 times because the count follows the
option.

• Stopping the ping Command


Turn off the pings using ctrl+c

2021-2022 9
Diagnostic Tools (ping)

• Interface Option
Example:
$ ping -I eth1 192.168.4.35
The -I interface option allows the user to choose which network adapter to use. network interfaces start with eth0 and increase. eth1
is the second network interface.
Interval Option
Example:
$ ping -i .2 192.168.4.35
The -i option allows a time interval change. the default time interval is 1 second. This interval can be reduced to 0.2. After that, root
rights should be used to reduce it further.
The -i option allows a time interval change. the default time interval is 1 second. This interval may be dropped to. 2. After that root
rights must be used to decrease it further.

2021-2022 10
Diagnostic Tools (ping)

• Size Option
Example:

$ ping -s 100 192.168.4.35


ICMP header data contains 8 bytes of data and 56 bytes are
sent by default, so 64 bytes are typically pinged. The
example shows sending 100 bytes and so the added 8
bytes of data will send a total of 108 bytes.

2021-2022 11
Diagnostic Tools (netstat)

netstat - The netstat command can be used to view the network's current status.

Options
 -r display routing table
 -i display interfaces
 -s display statistics
 -t can be used to list all active TCP connections.

Example:
$ netstat -r
This will display the routing table for your computer including: Destination, Gateway, Mask, Flags, and
Interface.

2021-2022 12
Diagnostic Tools (traceroute)

• traceroute - Display Route


This will help you find network routing problems. It will display the routes between two hosts.
The return will show how many hops (routers/gateways you go through). The fewer the hops the
better the connection usually. Each line will list information on a hop

2021-2022 13
The loopback interface
• The loopback interface
–On most Linux distributions, the loopback interface is already configured. You can check
this by doing the following:
# /sbin/ifconfig lo
–If not configured, do the following:
# ifconfig lo 127.0.0.1

–We now enter this interface in the routing table by typing:


# route add 127.0.0.1

in order to test if the loopback is configured correctly:


–ping 127.0.0.1

2021-2022 14
Dynamic IP
• Dhclient requet an IP@ from DHCP server
• dhclient eth0

• Option
• -r : release

2021-2022 15
host

• host - Check IP of Domain


This command allows you to check the IP address of a host.

Example:
$ host abc.com
This will return the following:
abc.com has address 204.202.136.19
abc.com has address 204.202.136.32

2021-2022 16
route
route - Set Routes

Purpose of route
The route tool can be used to view and manipulate the computer's internal routing table.
• When the add or del options are used, route modifies the routing tables.
• Without these options, route displays the current contents of the routing tables.

route add options target


The route add command will add routes, gateways, etc. to the routing table.

route del options target


The route del command will remove routes, gateways, etc from the routing table.

2021-2022 17
route
• route Options
 -net target is a network
 -host target is a single host
 gw gateway
 default this is the location of the default gateway

Example:
$ route add –host 192.168.2.1 gw 192.168.1.1
To reach 192.168.2.1, use 192.168.1.1 as a router

$ route add -net 192.168.1.0 dev eth0


Network 192.168.1.0 is reachable via the eth0 interface

$ route add default gw 192.168.1.1


For all addresses for which specific routes don't exist, use this gateway route del default Delete the default gateway entry

2021-2022 18
ftp
• ftp - file Transfer Protocol
This will allow you to connect to an ftp server to download or upload text or programs. When
you are finished type quit.

Example:
$ ftp 192.168.5.45
This will connect you to the ftp server at the IP address. You will need a username and
password.

$ ftp rpm.com
The same result but using a host name

2021-2022 19
telnet

telnet - Connect to telnet


telnet is a client program to connect to a telnet server. Once it
is opened you will be asked for a username and password.

Example:
$ telnet mysite.com
$ telnet 192.168.4.56
This will allow you to telnet to an IP address. Notice the
example is a private IP address.

2021-2022 20

You might also like