468x60 Ads

Showing posts with label IP. Show all posts
Showing posts with label IP. Show all posts

Monday, January 27, 2014

Creating Persistent Routes in Solaris



Creating Persistent Routes in Solaris

Print the currently active routes:

# netstat -rn

Routing Table: IPv4
  Destination           Gateway           Flags  Ref     Use     Interface
-------------------- -------------------- ----- ----- ---------- ---------
default              172.16.0.254         UG        1 1650937522
10.0.0.0             172.16.0.12          UG        1   10206514
172.16.0.0           172.16.0.3           U         1    9528249 igb0:1
224.0.0.0            172.16.0.3           U         1          0 igb0:1
127.0.0.1            127.0.0.1            UH       19      26626 lo0:1

Add a route persistently:

# route -p add default ip-address

Eg:
# route -p add 192.168.10.0/24 172.16.0.10

-p             Make changes to the network route tables per-
                    sistent across system restarts. The operation
                    is applied  to  the  network  routing  tables
                    first  and, if successful, is then applied to
                    the list  of  saved  routes  used  at  system
                    startup.  In determining whether an operation
                    was successful, a failure to add a route that
                    already  exists  or to delete a route that is
                    not in the routing table is ignored. Particu-
                    lar  care  should be taken when using host or
                    network  names  in  persistent   routes,   as
                    network-based  name  resolution  services are
                    not available at the time routes are added at
                    startup.
          (Reference :Solaris man page)

For routes that are created by using this method, use following command
to display all of the static routes

 #route -p show 

Following examples creates an IPv4 route to the destination 192.168.10.0 and subnet  with the subnet  mask of 255.255.255.0(/24):

# route add 192.168.10.0/24 somegateway
       
# route add 192.168.10.0 -netmask 255.255.255.0 somegateway

# route add 192.168.10.0 somegateway 255.255.255.0

For IPv6, only “/” format is accepting for subnet. The following example creates an IPv6 route to the destination 35dd:: with netmask of 16 one-bits followed by 112 zero-bits.


# route add -inet6 35dd::/16 somegateway




Monday, September 24, 2012

How to Capture Network Packets in Solaris


How to Capture Network Packets in Solaris  

snoop: illegal option -- h

Usage:  snoop
        [ -a ]                  # Listen to packets on audio
        [ -d device ]           # Listen on interface named device
        [ -s snaplen ]          # Truncate packets
        [ -c count ]            # Quit after count packets
        [ -P ]                  # Turn OFF promiscuous mode
        [ -D ]                  # Report dropped packets
        [ -S ]                  # Report packet size
        [ -i file ]             # Read previously captured packets
        [ -o file ]             # Capture packets in file
        [ -n file ]             # Load addr-to-name table from file
        [ -N ]                  # Create addr-to-name table
        [ -t  r|a|d ]           # Time: Relative, Absolute or Delta
        [ -v ]                  # Verbose packet display
        [ -V ]                  # Show all summary lines
        [ -p first[,last] ]     # Select packet(s) to display
        [ -x offset[,length] ]  # Hex dump from offset for length
        [ -C ]                  # Print packet filter code
        [ -q ]                  # Suppress printing packet count
        [ -r ]                  # Do not resolve address to name

        [ filter expression ]

Example:
        snoop -o saved  host fred

        snoop -i saved -tr -v -p19

Show DHCP packets :

Using device igb0 (promiscuous mode)
   50.17.0.1 -> NTU-HQ-GLOBAL DHCP/BOOTP DHCPDISCOVER
NTU-HQ-GLOBAL -> 50.17.0.1    DHCP/BOOTP DHCPOFFER
   50.17.0.1 -> NTU-HQ-GLOBAL DHCP/BOOTP DHCPDISCOVER

Show UDP packets :

Using device igb0 (promiscuous mode)
  172.16.0.1 -> 50.200.0.229 UDP D=1728 S=37628 LEN=32
  172.16.0.1 -> 50.17.0.41   UDP D=1728 S=37628 LEN=32
  172.16.0.1 -> 50.210.0.214 UDP D=1728 S=37628 LEN=32


Verbose packet display:

ETHER:  ----- Ether Header -----
ETHER:
ETHER:  Packet 182 arrived at 15:37:15.74365
ETHER:  Packet size = 66 bytes
ETHER:  Destination = 0:0:5e:0:1:64, U.S. Department of Defense (IANA)
ETHER:  Source      = 0:21:28:d2:88:8c,
ETHER:  Ethertype = 0800 (IP)
^CETHER:
IP:   ----- IP Header -----
IP:
IP:   Version = 4
IP:   Header length = 20 bytes
IP:   Type of service = 0x00
IP:         xxx. .... = 0 (precedence)
IP:         ...0 .... = normal delay
IP:         .... 0... = normal throughput
IP:         .... .0.. = normal reliability
IP:         .... ..0. = not ECN capable transport
IP:         .... ...0 = no ECN congestion experienced
IP:   Total length = 52 bytes
IP:   Identification = 36051
IP:   Flags = 0x4
IP:         .1.. .... = do not fragment
IP:         ..0. .... = last fragment
IP:   Fragment offset = 0 bytes
IP:   Time to live = 255 seconds/hops
IP:   Protocol = 17 (UDP)
IP:   Header checksum = 0000
IP:   Source address = 172.16.0.1, 172.16.0.1
IP:   Destination address = 50.78.0.6, 50.78.0.6
IP:   No options
IP:
UDP:  ----- UDP Header -----
UDP:
UDP:  Source port = 37628
UDP:  Destination port = 1728
UDP:  Length = 32
UDP:  Checksum = DE96
UDP:


Display information on host 172.16.0.1 using summary verbose mode:


To enable data captures from the snoop output without losing packets (while writing to the screen)by sending the snoop output to a file (snooper) :


Show broadcast packets:

Using device igb0 (promiscuous mode)
50.17.0.1   -> (broadcast)  ARP C Who is 172.16.0.8, sys13 ?
       

How to traceroute in Solaris 10


traceroute


It will print the route packets take to network host

Usage: traceroute [-adFIlnSvx] [-A address_family] [-c traffic_class]
        [-f first_hop] [-g gateway [-g gateway ...]| -r] [-i iface]
        [-L flow_label] [-m max_hop] [-P pause_sec] [-p port] [-Q max_timeout]
        [-q nqueries] [-s src_addr] [-t tos] [-w wait_time] host [packetlen]
Some output symbol descriptions:
!  the ttl (hop limit) value in the received packet is <= 1.
!H host unreachable.
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 40 byte packets
 1  172.16.0.250 (172.16.0.250)  0.679 ms !H *  0.594 ms !H

!X communication administratively prohibited.
 ICMP (ICMP6) unreachable code N.

!F The associated gateway is broken.
!N network unreachable.
!P protocol unreachable.
!S source route failed. It is likely that the gateway does not support source routing.
!T unreachable for the specified TOS (type-of-service).
!U source host isolated or precedence problem.
!A host unreachable for a reason other than lack of an entry in the routing table.
!B packet too big.
!E destination is not a neighbor.
!R unrecognized next header.

# traceroute  50.200.0.144
traceroute to 50.200.0.144 (50.200.0.144), 30 hops max, 40 byte packets
 1  172.16.0.250 (172.16.0.250)  0.457 ms  0.285 ms  0.320 ms
 2  50.200.0.144 (50.200.0.144)  1.593 ms  1.475 ms  1.549 ms


Thursday, September 6, 2012

Continuous ping in solaris 10



usage: ping host [timeout]
usage: ping -s [-l | U] [adLnRrv] [-A addr_family] [-c traffic_class]
        [-g gateway [-g gateway ...]] [-F flow_label] [-I interval]
        [-i interface] [-P tos] [-p port] [-t ttl] host [data_size] [npackets]


 -s  :  Send one  datagram  per  second  and collect statistics.


Put a Continuous ping:

# ping -s 50.17.0.1
PING 50.17.0.1 (50.17.0.1): 56 data bytes
64 bytes from 50.17.0.1: icmp_seq=0. time=1.22 ms
64 bytes from 50.17.0.1: icmp_seq=1. time=26.5 ms
64 bytes from 50.17.0.1: icmp_seq=2. time=8.13 ms
64 bytes from 50.17.0.1: icmp_seq=3. time=64.1 ms
64 bytes from 50.17.0.1: icmp_seq=4. time=30.7 ms
64 bytes from 50.17.0.1: icmp_seq=5. time=33.9 ms
64 bytes from 50.17.0.1: icmp_seq=6. time=1.03 ms
64 bytes from 50.17.0.1: icmp_seq=7. time=1.14 ms
.
.
.
.
.
64 bytes from 50.17.0.1: icmp_seq=26. time=1.27 ms
64 bytes from 50.17.0.1: icmp_seq=27. time=0.994 ms
^C
----50.17.0.1 PING Statistics----
28 packets transmitted, 28 packets received, 0% packet loss
round-trip (ms)  min/avg/max/stddev = 0.989/19.27/64.1/18.9



Put a Continuous ping with specific data size :


# ping  -s 50.17.0.1 200
PING 50.17.0.1: 200 data bytes
208 bytes from 50.17.0.1: icmp_seq=0. time=1.35 ms
208 bytes from 50.17.0.1: icmp_seq=1. time=27.1 ms
208 bytes from 50.17.0.1: icmp_seq=2. time=22.1 ms
^C
----50.17.0.1 PING Statistics----
3 packets transmitted, 3 packets received, 0% packet loss
round-trip (ms)  min/avg/max/stddev = 1.35/16.9/27.1/14.


Sunday, August 12, 2012

How to change IP and HOST-NAME on a Solaris 10


How to change IP and HOST-NAME on a Solaris 10


In Solaris 10, you must edit the /etc/hosts and the  /etc/inet/ipnodes file (a symbolic link to /etc/inet/hosts file) with VI editor to do necessary changers an entry for IP address and/or hostname.
How to show the hostname of your system:

# hostname
NTU-HQ-EMS
#

How to show the IP details of your network interfaces:

# ifconfig -a
lo0:1: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
igb0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 172.16.0.1 netmask ffffff00 broadcast 172.16.0.255
#

You can change Red (IP) and green(Host name) colour one as your require...

# cat etc/hosts
#
# Internet host table
#
::1     localhost
127.0.0.1       localhost
172.16.0.1      NTU-HQ-EMS      loghost
#


# cat /etc/inet/ipnodes
#
# Internet host table
#
::1     localhost
127.0.0.1       localhost
172.16.0.1      NTU-HQ-EMS      loghost
#

Once done, restart the Network service using following command:

# svcadm restart network/physical
Or reboot the server for the changes to take effect.

Check your physical network is up and running:
# svcs |grep -i physical
online         Feb_08   svc:/network/physical:default
#

Note:
The /etc/inet/ipnodes file stores both IPv4 and IPv6 addresses.
If you need to change addresses, you must add IPv4 addresses to both the hosts and ipnodes files. You add only IPv6 addresses to the ipnodes file.
Also, ensure that the /etc/netmasks file with the network ID and the netmask.