Computer And Technologies

Computer And Technologies: Networking
Showing posts with label Networking. Show all posts
Showing posts with label Networking. Show all posts

Monday, 10 August 2009

Some Network Linux Commands...

How will you get only TCP protocol status in a network?

Ans:- # netstat -t
O/P:-
root@eOdissa-desktop:/home/amaresh/Documents/Testing# netstat -t
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 eOdissa-desktop.l:59156 www-sf2p-a.facebook:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:59175 www-sf2p-a.facebook:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:57170 px-in-f83.google.co:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:45271 pv-in-f100.google.c:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:41356 a96-17-8-64.deploy.:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:52631 a96-17-8-48.deploy.:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:41932 ord-qs2-n24.panther:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:54438 px-in-f154.google.c:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:54442 px-in-f154.google.c:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:56950 a96-17-69-27.deploy:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:56949 a96-17-69-27.deploy:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:56948 a96-17-69-27.deploy:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:56947 a96-17-69-27.deploy:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:53859 221x247x49x219.ap:34580 ESTABLISHED

How will you get only UDP protocol status in a network ?
Ans:- # netstat -u
O/P:-
root@eOdissa-desktop:/home/amaresh/Documents/Testing# netstat -u
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State

How will you find only listening socket information?
Ans:- #netstat -l
O/P:-
root@eOdissa-desktop:/home/amaresh/Documents/Testing# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.152.128 * 255.255.255.128 U 0 0 0 tap0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
link-local * 255.255.0.0 U 0 0 0 eth0
192.168.0.0 192.168.152.129 255.255.0.0 UG 0 0 0 tap0
172.16.0.0 192.168.152.129 255.240.0.0 UG 0 0 0 tap0
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0

How will you get the class of any IP ?
Ans:- ipcals ( install apt-get install ipcalc in debian linux)

O/P:-
root@eOdissa-desktop:/home/amaresh/Documents/Testing# ipcalc 192.168.1.143
Address: 192.168.1.143 11000000.10101000.00000001. 10001111
Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000
Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111
=>
Network: 192.168.1.0/24 11000000.10101000.00000001. 00000000
HostMin: 192.168.1.1 11000000.10101000.00000001. 00000001
HostMax: 192.168.1.254 11000000.10101000.00000001. 11111110
Broadcast: 192.168.1.255 11000000.10101000.00000001. 11111111
Hosts/Net: 254 Class C, Private Internet

root@eOdissa-desktop:/home/amaresh/Documents/Testing#ipcalc 192.168.0.1 255.255.128.0 255.255.192.0
Address: 192.168.0.1 11000000.10101000.0 0000000.00000001
Netmask: 255.255.128.0 = 17 11111111.11111111.1 0000000.00000000
Wildcard: 0.0.127.255 00000000.00000000.0 1111111.11111111
=>
Network: 192.168.0.0/17 11000000.10101000.0 0000000.00000000
HostMin: 192.168.0.1 11000000.10101000.0 0000000.00000001
HostMax: 192.168.127.254 11000000.10101000.0 1111111.11111110
Broadcast: 192.168.127.255 11000000.10101000.0 1111111.11111111
Hosts/Net: 32766 Class C, Private Internet

Subnets after transition from /17 to /18

Netmask: 255.255.192.0 = 18 11111111.11111111.11 000000.00000000
Wildcard: 0.0.63.255 00000000.00000000.00 111111.11111111

1.
Network: 192.168.0.0/18 11000000.10101000.00 000000.00000000
HostMin: 192.168.0.1 11000000.10101000.00 000000.00000001
HostMax: 192.168.63.254 11000000.10101000.00 111111.11111110
Broadcast: 192.168.63.255 11000000.10101000.00 111111.11111111
Hosts/Net: 16382 Class C, Private Internet

2.
Network: 192.168.64.0/18 11000000.10101000.01 000000.00000000
HostMin: 192.168.64.1 11000000.10101000.01 000000.00000001
HostMax: 192.168.127.254 11000000.10101000.01 111111.11111110
Broadcast: 192.168.127.255 11000000.10101000.01 111111.11111111
Hosts/Net: 16382 Class C, Private Internet


Subnets: 2
Hosts: 32764

How will you monitor your LAN IP?
Ans:- iptraf (use apt-get install iptraf in debian linux)

How will you get your bandwidth usages of your interface by host ?
Ans:- iftop

Wednesday, 6 May 2009

Configuring TCP/IP on Solaris - Overview of the Booting Processes

The Boot Process

The following information is provided for your reference. It is a brief overview of the network booting processes to help you better visualize what is happening during configuration.

Note - The names of startup scripts might change from one release to another.

  1. You start the operating system on a host.
  2. The kernel runs /sbin/init, as part of the booting process.
  3. /sbin/init runs the /etc/rcS.d/S30rootusr.sh. startup script.
  4. The script runs a number of system startup tasks, including establishing the minimum host and network configurations for diskless and dataless operations. /etc/rcS.d/S30rootusr.sh also mounts the /usr file system.
    1. If the local database files contain the required configuration information (host name and IP address), the script uses it.
    2. If the information is not available in local host configuration files, /etc/rcS.d/S30rootusr.sh uses RARP to acquire the host's IP address.
  5. If the local files contain domain name, host name, and default router address, the machine uses them. If the configuration information is not in local files, then the system uses the Bootparams protocol to acquire the host name, domain name, and default router address. Note that the required information must be available on a network configuration server that is located on the same network as the host. This is necessary because no internetwork communications exist at this point.
  6. After /etc/rcS/S30rootusr.sh completes its tasks and several other boot procedures have executed, /etc/rc2.d/S69inet runs. This script executes startup tasks that must be completed before the name services (NIS, NIS+, or DNS) can start. These tasks include configuring the IP routing and setting the domain name.
  7. At completion of the S69inet tasks, /etc/rc2.d/S71rpc runs. This script starts the NIS, NIS+, or DNS name service.
  8. After /etc/rc2.d/S71 runs, /etc/rc2.d/S72inetsvc runs. This script starts up services that depend on the presence of the name services. S72inetsvc also starts the daemon inetd, which manages user services such as telnet.

Configuring TCP/IP on Solaris - Configuring Standard TCP/IP Services

TCP/IP Services

Services such as telnet, ftp, and rlogin are started by the inetd daemon, which runs automatically at boot time. Like the name service ordering specified in nsswitch.conf, you can configure TCP/IP services in the file /etc/inetd.conf by using the inetd -t flag.

For example, you can use inetd to log the IP addresses of all incoming TCP connections (remote logins and telnet). To turn the logging on, kill the running inetd and type:

  # /usr/sbin/inetd -t -s
The t switch turns on TCP connection-tracing in inetd. Refer to the inetd(1M) and inetd.conf(4) man pages.

Configuring TCP/IP on Solaris - Network Configuration Procedures

Introduction

Network software installation takes place along with the installation of the operating system software. At that time, certain IP configuration parameters must be stored in appropriate files so they can be read at boot time.

The procedure is simply a matter of creating or editing the network- configuration files. How configuration information is made available to a machine's kernel depends on whether these files are stored locally (local files mode) or acquired from the network configuration server (network client mode). Parameters supplied during network configuration are:

  • IP address of each network interface on every machine
  • Host names of each machine on the network. You can type the host name in a local file or a name service database.
  • NIS, NIS+, or DNS domain name in which the machine resides, if applicable
  • Default router addresses. You supply this only if you have a simple network topology with only one router attached to each network, or your routers don’t run routing protocols such as the Router Discovery Server Protocol (RDISC) or the Router Information Protocol (RIP). (See Chapter 5 for more information about these protocols.)
  • Subnet mask (required only for networks with subnets)
This section contains complete information on creating and editing local configuration files.

How to Configure a Host for Local Files Mode

Use this procedure for configuring TCP/IP on a machine that run in local files mode.

  1. Become superuser and change to the /etc directory.
  2. Type the host name of the machine in the file /etc/nodename. For example, if the name of the host is tenere, type tenere in the file.
  3. Create a file named /etc/hostname.interface for each network interface. (The Solaris installation program automatically creates this file for the primary network interface.)
  4. Type either the interface IP address or the interface name in each /etc/hostname.interface file. For example, create a file named hostname.ie1, and type either the IP address of the host's interface or the host's name.
  5. Edit the /etc/inet/hosts file to add:
    • IP addresses that you have assigned to any additional network interfaces in the local machine, along with the corresponding host name for each interface. The Solaris installation program will already have created entries for the primary network interface and loopback address.
    • IP address or addresses of the file server, if the /usr file system is NFS mounted.
  6. Type the host's fully qualified domain name in the /etc/defaultdomain file. For example, suppose host tenere was part of the domain deserts.worldwide.com. Therefore, you would type: deserts.worldwide.com in /etc/defaultdomain.
  7. Type the router's name in /etc/defaultrouter.
  8. Type the name of the default router and its IP addresses in /etc/inet/hosts. Additional routing options are available. You can apply these options to a local files mode configuration.
  9. If your network is subnetted, type the network number and the netmask in the file /etc/inet/netmasks. If you have set up a NIS or NIS+ server, you can type netmask information in the appropriate database on the server as long as server and clients are on the same network.
  10. Reboot each machine on the network.

Setting Up a Network Configuration Server

If you plan to configure certain hosts as network clients, you must configure at least one machine on your network as a network configuration server. (Refer to “Network Configuration Servers” on page 45 for an introduction.) Setting up a network configuration server involves:
  1. Turning on the network configuration daemons:
    - in.tftpd
    - in.rarpd
    - rpc.bootparamd
  2. Editing and maintaining the network configuration files on the configuration server.

How to Set Up a Network Configuration Server

  1. Become superuser and change to the root directory of the prospective network configuration server.
  2. Turn on the in.tftpd daemon by creating the directory /tftpboot:

    # mkdir /tftpboot

    This configures the machine as a TFTP, bootparams, and RARP server.

  3. Create a symbolic link to the directory.

    # ln -s /tftpboot/. /tftpboot/tftpboot

  4. Enable the tftp line in intetd.conf. Check that the /etc/inetd.conf entry reads:

    tftp dgram udp wait root /usr/sbin/in.tftpd in.tftpd -s /tftpboot

    This prevents inettftpd() from retrieving any file other than one located in /tftpboot.

  5. Edit the hosts database, and add the host names and IP addresses for every client on the network.
  6. Edit the ethers database, and create entries for every host on the network to run in network client mode.
  7. Edit the bootparams database. Use the wildcard entry or create an entry for every host that run in network client mode.
  8. Reboot the server.

Configuring Network Clients

Network clients receive their configuration information from network configuration servers. Therefore, before you configure a host as a network client you must ensure that at least one network configuration server is set up for the network.

How to Configure Hosts for Network Client Mode

Do the following on each host to be configured in network client mode:
  1. Become superuser.
  2. Check the directory for the existence of an /etc/nodename file. If one exists, delete it.

    Eliminating /etc/nodename causes the system to use the hostconfig program to obtain the host name, domain name, and router addresses from the network configuration server.

  3. Create the file /etc/hostname.interface, if it does not exist. Make sure that the file is empty. An empty /etc/hostname.interface file causes the system to acquire the IP address from the network configuration server.
  4. Ensure that the /etc/inet/hosts file contains only the host name and IP address of the loopback network interface. The file should not contain the IP address and host name for the local machine (primary network interface). EXCEPTION: For a diskless client (a machine with an NFS-mounted root file system), type the name and IP address of the server that provides the client's root file system (usually, but not always, the network configuration server).
  5. Check for the existence of an /etc/defaultdomain file. If one exists, delete it.

    The hostconfig program sets the domain name automatically. If you want to override the domain name set by hostconfig, type the substitute domain name in the file /etc/defaultdomain.

  6. Ensure that the search paths in the client's /etc/nsswitch.conf reflects the name service requirements for your network.

How to Specify a Router for the Network Client

  1. If you have only one router on the network and you want the network configuration server to specify its name automatically, ensure that the network client does not have a /etc/defaultrouter file.
  2. To override the name of the default router provided by the network configuration server:
    • Create /etc/defaultrouter on the network client.
    • Type the host name and IP address of the machine you have designated as the default router.
    • Add the host name and IP address of the designated default router to the network client's /etc/inet/hosts.
  3. If you have multiple routers on the network, create /etc/defaultrouter on the network client, but leave it empty.

Creating /etc/defaultrouter and leaving it empty causes one of the two dynamic routing protocols to run: ICMP Router Discovery protocol (RDISC), or Routing Information Protocol (RIP). The system first runs the program in.rdisc, which looks for routers that are running the router discovery protocol. If it finds one such router, in.rdisc continues to run and keeps track of the routers that are running the RDISC protocol.

If the system discovers that routers are not responding to the RDISC protocol, it uses RIP and runs the daemon in.routed to keep track of them.

After Installing a Network Client

After you have finished editing the files on each network client machine, do the following on the network configuration server.

  1. Add entries for the hosts in the ethers and hosts databases.
  2. Add entries for the hosts to the bootparams database. To simplify matters, you can type a wild card in the bootparams database in place of individual entries for each host.
  3. Reboot the server.