Showing posts with label Network Configuration. Show all posts
Showing posts with label Network Configuration. Show all posts

Linux ARP And Commands

The (ARP)  stands for Address Resolution Protocol. The ARP work is to define the define the network interfaces connected to an ethernet media segment (hardware addresses) to map an IP address (logical addresses assigned to machines) to a link layer address which it do on demand. The link layer address is the correct term although it is interchangeably  used with  Ethernet addresses, Media Access Control (MAC) addresses.


 ARP is commonly used to translate the protocol addresses to hardware interface addresses. Modifying the ARP cache can change which interfaces handles the specific requests. ARP cache entries may be marked with the following flags:
C (complete), M (permanent), and P (publish)

While arp can create a proxy for a single system, subnet proxies can be handled by the arp kernel module.

 arp [-evn] [-H type] [-i if] -a [hostname]
arp [-v] [-i if] -d hostname [pub]
arp [-v] [-H type] [-i if] -s hostname hw_addr [temp]
arp [-v] [-H type] [-i if] -s hostname hw_addr [netmask nm] pub
arp [-v] [-H type] [-i if] -Ds hostname ifa [netmask nm] pub
arp [-vnD] [-H type] [-i if] -f [filename]

  • -a [hosts] , --display [hosts] It displays the entries for hosts, if none of them are specified, all entries.
  • -d host [pub] , --delete host [pub] Removes the specified host's entry. To delete a proxy entry, add the pub argument and specify the interface associated with the proxy using -i.
  • -D, --use-device Use the hardware address associated with the specified interface. This may be used with -s when creating a proxy entry.
  • -f file, --file file Read the entries from a file and add them.
  • -H type, --hw-type type, -t type Search for type entries when examining the ARP cache. type is usually ether (Ethernet), which is the default, but may be ax25 (AX.25 packet radio), arcnet (ARCnet), pronet (PROnet), or netrom (NET/ROM).
  • -i interface, --device interface Select an interface. If you need to dump the ARP cache, this option will cause the command to display  the entries using that interface. When setting entries, this will cause the interface to be associated with that entry. If you do not use this option when setting an entry, the kernel will guess.
  • -n, --numeric Display host IP addresses instead of their domain names.
  • -s host hardware-address [netmask mask] [pub] , --set host hardware-address [pub] It Adds a permanent entry for host at hardware-address. A hardware-address for type ether hardware is 6 hexadecimal bytes, colon-separated. The pub argument can be used to set the publish flag, creating a proxy entry.
  • -v, --verbose Verbose mode.

    Here are all the possible states for entries in the neighbor table.

    Table 2.1. Active ARP cache entry states
    ARP cache entry statemeaningaction if used
    permanentnever expires; never verifiedreset use counter
    noarpnormal expiration; never verifiedreset use counter
    reachablenormal expirationreset use counter
    stalestill usable; needs verificationreset use counter; change state to delay
    delayschedule ARP request; needs verificationreset use counter
    probesending ARP requestreset use counter
    incompletefirst ARP request sentsend ARP request
    failedno response receivedsend ARP request

 

Initialization Scripts

Network services like the Apache HTTP Server and DHCP(Dynamic Host Configuration Protocol )  along with other programs such as cron ( Enables users to schedule jobs to run automatically at a certain time and date, used in administration, connecting to internet and downloading e-mail) and syslog require a daemon to be running at all times. The daemon performs actions like listening for connections for a service on specific ports, making sure commands are executed at specific times, and capturing data such as log messages sent out by other programs.

Programs that require a daemon to be started have an initialization script in the /etc/rc.d/init.d/ directory. This script can also be used to run a command at boot time such as the readahead_early and readahead_later scripts, which run the readahead utility which loads the programs used at startup into memory before they are needed. It decreases the amount of time it takes to start the system. While booting a Red Hat Enterprise Linux system, the init program is run last in the kernel boot process. This program first executes the /etc/rc.d/rc.sysinit script to perform actions such as loading kernel modules for hardware support, loading the default keymap, and setting the hostname. The /etc/inittab script is run next, which then tells init which runlevel to start. The runlevel defines which services to start at boot time, or which initialization scripts to execute.

Lastly, the /etc/rc.d/rc.local script is executed. Commands can be added to this file for custom initialization. The initialization scripts enables user to start, stop, and restart services after the system has booted. These actions are performed with the service command as the root user. Each script has its own list of actions. Common actions defined include start, stop, conrestart (which stops and starts the service only if it is already running), and status.

To perform an action, use the following syntax:

service

For example, the following starts the OpenSSH service:  

service sshd start


Printer Configuration

Configuring a printer is not covered by installation or setup agent. Red Hat Enterprise Linux uses the Common UNIX Printing System, also known as CUPS. CUPS uses the Internet Printing Protocol (IPP) to allow local printing and print sharing. The /etc/cups/ directory stores the configuration files for printing. These files can be easily managed with the Printer Configuration Tool in Red Hat Enterprise Linux.

NOTE
To start the Printer Configuration Tool, go to the System menu on the top panel and select Administration, Printing or execute the command system-config-printer. It will prompt for the root password. If no printers are available for the system, only the Server Settings view is available for selection. If local printers are configured, a Local Printers menu is available.

CUPS is the default printing system used by Red Hat Enterprise Linux, and one of its many advantages is that it uses IPP to broadcast shared printers on the network so that other systems can browse for them, select one as the default printer, and print to it without any further configuration. If any printers are broadcast on your network, they will appear in a Remote Printers menu. Figure shows a system with both local and remote printers. If a list isn’t already expanded, click on the triangle icon to the left of it.



The log files for the CUPS printing system are located in the /var/log/cups/ directory. Refer to this directory for access and error logs.

Starting and Stopping the Network

If An Ethernet device is found during installation, the network is configured to start automatically at boot time unless uncheck the Activate on boot option for the device. To disable it use the chkconfig network off command. To enable it use the chkconfig network on command.

The /etc/hosts and /etc/resolv.conf are referenced each time they are used, so modifications to them take place immediately. If the hostname is modified in /etc/sysconfig/network, the change does not occur until the next reboot. To immediately change the hostname, execute the command hostname as the root user.

If you modify network settings in /etc/sysconfig/network-scripts/, the changes do not take place dynamically ,until the network is restarted or the individual device is shut down and brought back up. To restart the entire network (the loopback device and all network devices), use the command service network restart as root. To shut an individual device down and bring it back up, as root, execute the command ifdown and then ifup , where is the name of the device such as eth0.

To stop all the network devices, use the service network stop command as root. To start the network, use the command service network start as root.

Post-Installation Configuration

This post is in response to my earlier post of network configuration.

The /etc/hosts file lists IP addresses and hostnames that should resolve to the IPaddresses as shown. The first one listed, 127.0.0.1, is referred to as the loopback interface and should never be removed. If some hostnames are not  resolved by the DNS servers, list them with their IP addresses after the loopback device. For example, if your network consists only of a handful of systems, it might be easier to list them in the /etc/hosts file on each local system than set up a DNS server on the local network for name resolution.

CAUTION
Always be careful when listing hostnames that can be resolved by the DNS servers and those that are not under your control. If the IP address of the hostname changes, you will not be able to connect to the host because any IP addresses listed in /etc/hosts have precedence over any IP addresses resolved through the DNS servers.

 /etc/hosts File
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
192.168.0.1 metropolis
192.168.0.2 louis
182.168.0.3 clark

A typical /etc/resolv.conf is shown below. Each nameserver line represents a
DNS server, and the search line specifies domain names to try if only the first part of a hostname is used. For example, if just the name infinity is used as a hostname, infinity.example.com and then infinity.example.org will be tried if the /etc/resolv.conf file in Listing 2.4 is on the system.

 /etc/resolv.conf File
nameserver 192.168.0.254
nameserver 192.168.10.254
search example.com example.org

In the /etc/sysconfig/network-scripts/ directory, each network device has its own
configuration file with the filename ifcfg- such as ifcfg-eth0 for the first Ethernet device.

If the device uses DHCP to retrieve network settings, a typical /etc/sysconfig/networkscripts/ifcfg-eth0 file contains the lines as shown below.

 Ethernet Interface Configuration File for DHCP
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes

If the device is configured for a static IP address, the interface configuration file looks similar to

Ethernet Interface Configuration File for Static IP
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
NETWORK=192.168.1.0
NETMASK=255.255.255.0
IPADDR=192.168.1.15
USERCTL=no


If the ONBOOT option is set to yes, the device is activated at boot time using the network initialization script. Other device names include lo for the local loopback device, pppX for dialup interfaces, and irlanX for infrared devices where X is the device number starting with 0. Refer to the file /usr/share/doc/initscripts-/sysconfig.txt for additional options for
the files in this directory.



RELATED POSTS:-

Network Configuration

If Ethernet card was present during installation, the installation program will allow you to configure the device.But this post deals with modification of  configuration after installation. Even if you don’t need to modify the network settings, you can use this information to verify if the settings are correct.

NOTE:-
Because some servers do not have graphical desktops installed, we have consider the network configuration from the command line by modifying configuration files. If you have a graphical desktop and want to use a graphical application, go to the System menu on the top panel and select Administration, Network.





Network Configuration Files
The following configuration files exist for network configuration:

                File
                Use
. /etc/modprobe.conf fileThis assigns a kernel module to each network device.

. /etc/sysconfig/network fileIt Sets the hostname and check whether the networking is enabled.IPv6 is enabled or disabled.
. /etc/hosts filesLists hosts and their IP addresses for hostnames that can’t be resolved by the DNS servers
. /etc/resolv.conf file
Sets the DNS servers (using their IP addresses)and the search domain. The values of the DNS servers are often tend to be added when the network is activated because the data can be provided by DHCP or a similar service.

. /etc/sysconfig/network-scripts/ directoryContains scripts to start and stop a network device and a specialized configuration file for each device.
. /etc/rc.d/init.d/network fileInitialization script that starts and stops the network.



 CAUTION:-
If the Graphical Network Configuration Tool from the Administration, Network menu item of the System menu has ever been run on the system, an /etc/sysconfig/ networking/ directory will exist. The files in this directory are only used by the graphical tool and are not by any of the network scripts. If changes are made to these files, they will not be applied to the actual network configuration files used.

Some of the network configuration files such as the ifup and ifdown scripts in /etc/ sysconfig/network-scripts/ does not need to be modified in most cases and should not be modified unless absolutely necessary. We are considering the network configuration files that may have to be modified to change the network settings and how to enable the changes.

Case-1 shows an example of a /etc/modprobe.conf file. The first line assigns the e100 kernel module to the eth0 network device. If the network card is supported, the module is automatically configured during installation or by Kudzu the first time the system is booted with the new card.

CASE-1 
/etc/modprobe.conf
alias eth0 e100
alias scsi_hostadapter sata_sil
alias scsi_hostadapter1 ata_piix


The /etc/sysconfig/network file usually contains the content shown in CASE-2. If the NETWORKING option is set to yes, the networking subsystem is enabled but not necessarily started at boot time. The value of the HOSTNAME option is the hostname for the system. If it is not set, the default hostname is localhost. Refer to the file /usr/share/doc/ initscripts-/sysconfig.txt for additional options for this file.

CASE-2 
/etc/sysconfig/network
NETWORKING=yes
HOSTNAME=smallville

 

Managing Shell And its Secrets

Subscribe To Get Update On Mobile

Subscribe
Get updates of latest post on your mobile free