Wise people learn when they can; fools learn when they must - Arthur Wellesley

Wednesday, 22 February 2017

RHEL-6 (4) KNOW YOUR SYSTEM-P4 (NETWORK)


RHEL-6 (4)
               KNOW YOUR SYSTEM-P4

NETWORK:


What is IP/Subnet & gateway of my system?
What is MAC address of my particular Ethernet port?
How to know about the existing routes in system?
How can i make a interface up and down?
How to ping with particular no of counts?
How to trace the route/path of a particular IP?
What are the meanings of different O/P's from traceroute?
How to dump the TCP packets?
What is ARP?
How to add Static ARP Entry on my system?
How to add Static ARP Entries Permanently on my system?
How to delete a Static ARP Entry from my system?
How to print systems routing table?
How to add the route for Host / Network?
How to remove the route?
What are the important files and their descriptions in my system?


IP/Subnet/Gateway/Routes/Interface

[root@rhel6-client1 /]# ifconfig –a

[root@rhel6-client1 /]# ifconfig eth3
eth3      Link encap:Ethernet  HWaddr 00:0C:29:80:4E:54
          inet addr:192.168.110.135  Bcast:192.168.110.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe80:4e54/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:10648 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7062 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:795216 (776.5 KiB)  TX bytes:4482794 (4.2 MiB)

[root@rhel6-client1 /]# cat /etc/sysconfig/network-scripts/ifcfg-eth3
DEVICE=eth3
TYPE=Ethernet
UUID=aff36e84-11b8-4d37-8243-79ba0798839f
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
HWADDR=00:0C:29:80:4E:54 çMAC address of eth3
IPADDR=192.168.110.135  çIP of eth3
PREFIX=24 ç Subnet
GATEWAY=192.168.234.2 ç Gateway
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth3"

BOOTPROTO=<protocol>
where <protocol> is one of the following:

none — No boot-time protocol should be used.
bootp — The BOOTP protocol should be used.
dhcp — The DHCP protocol should be used.

BROADCAST=<address>
where <address> is the broadcast address. This directive is deprecated, as the value is calculated automatically with ifcalc.

DEVICE=<name>
where <name> is the name of the physical device (except for dynamically-allocated PPP devices where it is the logical name).

DHCP_HOSTNAME
Use this option only if the DHCP server requires the client to specify a hostname before receiving an IP address.

DNS{1,2}=<address>
where <address> is a name server address to be placed in /etc/resolv.conf if the PEERDNS directive is set to yes.

ETHTOOL_OPTS=<options>
where <options> are any device-specific options supported by ethtool. For example, if you wanted to force 100Mb, full duplex:

ETHTOOL_OPTS="autoneg off speed 100 duplex full"
Instead of a custom initscript, use ETHTOOL_OPTS to set the interface speed and duplex settings. Custom initscripts run outside of the network init script lead to unpredictable results during a post-boot network service restart.
GATEWAY=<address>
where <address> is the IP address of the network router or gateway device (if any).

HWADDR=<MAC-address>
where <MAC-address> is the hardware address of the Ethernet device in the form AA:BB:CC:DD:EE:FF. This directive is useful for machines with multiple NICs to ensure that the interfaces are assigned the correct device names regardless of the configured load order for each NIC's module. This directive should not be used in conjunction with MACADDR.

IPADDR=<address>
where <address> is the IP address.

MACADDR=<MAC-address>
where <MAC-address> is the hardware address of the Ethernet device in the form AA:BB:CC:DD:EE:FF. This directive is used to assign a MAC address to an interface, overriding the one assigned to the physical NIC. This directive should not be used in conjunction with HWADDR.

MASTER=<bond-interface>
where <bond-interface> is the channel bonding interface to which the Ethernet interface is linked.

This directive is used in conjunction with the SLAVE directive.

Refer to Section 14.2.3, “Channel Bonding Interfaces” for more information about channel bonding interfaces.

NETMASK=<mask>
where <mask> is the netmask value.

NETWORK=<address>
where <address> is the network address. This directive is deprecated, as the value is calculated automatically with ifcalc.

ONBOOT=<answer>
where <answer> is one of the following:
yes — This device should be activated at boot-time.
no — This device should not be activated at boot-time.

PEERDNS=<answer>
where <answer> is one of the following:

yes — Modify /etc/resolv.conf if the DNS directive is set. If using DHCP, then yes is the default.
no — Do not modify /etc/resolv.conf.

SLAVE=<bond-interface>
where <bond-interface> is one of the following:

yes — This device is controlled by the channel bonding interface specified in the MASTER directive.
no — This device is not controlled by the channel bonding interface specified in the MASTER directive.
This directive is used in conjunction with the MASTER directive.

Refer to Section 14.2.3, “Channel Bonding Interfaces” for more about channel bonding interfaces.

SRCADDR=<address>
where <address> is the specified source IP address for outgoing packets.

USERCTL=<answer>
where <answer> is one of the following:

yes — Non-root users are allowed to control this device.
no — Non-root users are not allowed to control this device.

To list all the existing routes in system or server.

[root@rhel6-server ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.110.0   192.168.110.1   255.255.255.0   UG    0      0        0 eth3
192.168.110.0   *               255.255.255.0   U     0      0        0 eth3
192.168.234.0   *               255.255.255.0   U     0      0        0 eth2
192.168.234.0   *               255.255.255.0   U     1      0        0 eth1
link-local      *               255.255.0.0     U     1004   0        0 eth2
link-local      *               255.255.0.0     U     1005   0        0 eth3
default         192.168.234.2   0.0.0.0         UG    0      0        0 eth1

[root@rhel6-server ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.110.0   192.168.110.1   255.255.255.0   UG    0      0        0 eth3
192.168.110.0   0.0.0.0         255.255.255.0   U     0      0        0 eth3
192.168.234.0   0.0.0.0         255.255.255.0   U     0      0        0 eth2
192.168.234.0   0.0.0.0         255.255.255.0   U     1      0        0 eth1
169.254.0.0     0.0.0.0         255.255.0.0     U     1004   0        0 eth2
169.254.0.0     0.0.0.0         255.255.0.0     U     1005   0        0 eth3
0.0.0.0         192.168.234.2   0.0.0.0         UG    0      0        0 eth1

INTERFACE UP-DOWN:

[root@rhel6-server ~]# ifconfig eth1 down
[root@rhel6-server ~]# ifconfig eth1 up

OR

[root@rhel6-server ~]# ifdown eth1
Device state: 3 (disconnected)

[root@rhel6-server ~]# ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 00:0C:29:80:4E:40
          inet6 addr: fe80::20c:29ff:fe80:4e40/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3125 errors:0 dropped:0 overruns:0 frame:0
          TX packets:43 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:290548 (283.7 KiB)  TX bytes:4754 (4.6 KiB)

[root@rhel6-server ~]# ifup eth1
Active connection state: activated
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/7

[root@rhel6-server ~]# ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 00:0C:29:80:4E:40
          inet addr:192.168.234.146  Bcast:192.168.234.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe80:4e40/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3125 errors:0 dropped:0 overruns:0 frame:0
          TX packets:43 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:290548 (283.7 KiB)  TX bytes:4754 (4.6 KiB)

[root@rhel6-server ~]# ifcfg
Usage: ifcfg DEV [[add|del [ADDR[/LEN]] [PEER] | stop]
       add - add new address
       del - delete address
       stop - completely disable IP

CONNECTIVITY:

[root@rhel6-server ~]# ping 192.168.234.144
PING 192.168.234.144 (192.168.234.144) 56(84) bytes of data.
64 bytes from 192.168.234.144: icmp_seq=1 ttl=64 time=3.79 ms
64 bytes from 192.168.234.144: icmp_seq=2 ttl=64 time=0.666 ms
64 bytes from 192.168.234.144: icmp_seq=3 ttl=64 time=0.559 ms
^C
--- 192.168.234.144 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2148ms
rtt min/avg/max/mdev = 0.559/1.671/3.790/1.499 ms

[root@rhel6-server ~]# ping -c 5 192.168.234.144

PING 192.168.234.144 (192.168.234.144) 56(84) bytes of data.
64 bytes from 192.168.234.144: icmp_seq=1 ttl=64 time=0.917 ms
64 bytes from 192.168.234.144: icmp_seq=2 ttl=64 time=0.826 ms
64 bytes from 192.168.234.144: icmp_seq=3 ttl=64 time=0.664 ms
64 bytes from 192.168.234.144: icmp_seq=4 ttl=64 time=0.789 ms
64 bytes from 192.168.234.144: icmp_seq=5 ttl=64 time=0.576 ms

--- 192.168.234.144 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4006ms
rtt min/avg/max/mdev = 0.576/0.754/0.917/0.123 ms

[root@rhel6-server ~]# traceroute 192.168.234.200
traceroute to 192.168.234.200 (192.168.234.200), 30 hops max, 60 byte packets
1    192.168.234.200 (192.168.234.200)  4.181 ms  2.774 ms  3.017 ms

[root@rhel6-server ~]# tracepath 192.168.234.200
 1:  rhel6-server (192.168.234.146)                         0.384ms pmtu 1500
 1:  192.168.234.200 (192.168.234.200)                      0.901ms reached
 1:  192.168.234.200 (192.168.234.200)                      0.963ms reached
     Resume: pmtu 1500 hops 1 back 64


Traceroute Symbol
Description
***
Expected 5 second response time exceeded. Could be caused by:
* A router on the path not sending back the ICMP "time exceeded" 
   messages
* A router or firewall in the path blocking the ICMP "time exceeded"
   messages
* The target IP address not responding
!H, !N, or !P
Host, network or protocol unreachable
!X or !A
Communication administratively prohibited. A router Access Control List (ACL) or firewall is in the way
!S
Source route failed. Source routing attempts to force traceroute touse a certain path. Failure might be due to a router security setting

[root@rhel6-server ~]# tcpdump -i eth1
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 65535 bytes
04:43:28.670872 IP 192.168.234.1.64548 > 239.255.255.250.ssdp: UDP, length 94
04:43:28.886322 IP 192.168.234.1.64553 > 239.255.255.250.ssdp: UDP, length 119
^C
2 packets captured
2 packets received by filter
0 packets dropped by kernel

[root@rhel6-server ~]# tcpdump -i eth3
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth3, link-type EN10MB (Ethernet), capture size 65535 bytes
04:43:59.006647 IP rhel6-server.ssh > 192.168.110.1.raven-rmp: Flags [P.], seq 2289578414:2289578610, ack 225829094, win 146, length 196
04:43:59.007204 IP 192.168.110.1.raven-rmp > rhel6-server.ssh: Flags [.], ack 196, win 16324, length 0
04:43:59.009094 IP rhel6-server.ssh > 192.168.110.1.raven-rmp: Flags [P.], seq 196:488, ack 1, win 146, length 292
04:43:59.009481 IP 192.168.110.1.raven-rmp > rhel6-server.ssh: Flags [.], ack 488, win 16251, length 0
=================O/P REMOVED======================================
^C
3674 packets captured
3676 packets received by filter
0 packets dropped by kernel

ARP:

Arp is used to translate IP addresses into Ethernet addresses. The arp table is stored in the kernel and manipulated dynamically. Arp entries are cached and will time out and are deleted normally in 20 minutes.

arp –a : Prints the arp table
arp –s <ip_address> <mac_address> [pub] to add an entry in the table
arp –a –d to delete all the entries in the ARP table

[root@rhel6-server ~]# arp -a
? (192.168.110.1) at 00:50:56:c0:00:01 [ether] on eth3

Add an static entry

[root@rhel6-server ~]# arp -s 192.168.234.2 00:0C:29:80:4E:40

Check the status,

[root@rhel6-server ~]# arp -a -n
? (192.168.110.1) at 00:0C:29:80:4E:54 [ether] on eth3
? (192.168.234.2) at 00:0c:29:80:4e:40 [ether] PERM on eth2

Make it permanent,

[root@rhel6-server ~]# vi /etc/ethers
# see man ethers for syntax
00:0C:29:80:4E:40 192.168.234.146
00:0C:29:80:4E:54 192.168.110.135

Delete an static entry,
[root@rhel6-server ~]# arp -d 192.168.110.1

ROUTE:

Print routing table.

[root@rhel6-server ~]# netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.110.0   0.0.0.0         255.255.255.0   U         0 0          0 eth3
192.168.234.0   192.168.234.2   255.255.255.0   UG        0 0          0 eth1
192.168.234.0   0.0.0.0         255.255.255.0   U         0 0          0 eth2
192.168.234.0   0.0.0.0         255.255.255.0   U         0 0          0 eth1
0.0.0.0         192.168.234.2   0.0.0.0         UG        0 0          0 eth1

[root@rhel6-server ~]# netstat –rnf inet
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 rhel6-server:ssh            192.168.110.1:bintec-tapi   ESTABLISHED
tcp        0      0 rhel6-server:ssh            192.168.110.1:simp-all      ESTABLISHED
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags       Type       State         I-Node Path
unix  23     [ ]         DGRAM                    12608  /dev/log
unix  2      [ ]         DGRAM                    8728   @/org/kernel/udev/udevd
unix  2      [ ]         DGRAM                    14214  @/org/freedesktop/hal/udev_event
unix  2      [ ]         DGRAM                    51238
unix  2      [ ]         DGRAM                    49750
unix  2      [ ]         DGRAM                    34933
unix  3      [ ]         STREAM     CONNECTED     25255  @/tmp/dbus-ThzIS4OuAz
=================O/P REMOVED======================================

[root@rhel6-server ~]# netstat –an

With the -an option lists all the TCP ports on which Linux server is listening including all the active network connections to and from server. This can be very helpful in determining whether slowness is due to high traffic volumes:

#route add|delete [-net|-host] <destination> <gateway>

[root@rhel6-server ~]# route add -net 192.168.234.0/24 gw 192.168.234.2 eth1

#route flush - it removes all the routes

#route add -net 0.0.0.0 192.168.234.2 - to add a default route

[root@rhel6-server ~]# route del -net 192.168.234.0/24 gw 192.168.234.2 eth1

IMPORTANT FILES:

/etc/hosts —- names to ip addresses
/etc/networks —- network names to ip addresses
/etc/protocols —– protocol names to protocol numbers
/etc/services —- tcp/udp service names to port numbers

/etc/hosts
The main purpose of this file is to resolve host names that cannot be resolved any other way. It can also be used to resolve host names on small networks with no DNS server. Regardless of the type of network the computer is on, this file should contain a line specifying the IP address of the loopback device (127.0.0.1) as localhost.localdomain.

/etc/resolv.conf
This file specifies the IP addresses of DNS servers and the search domain. Unless configured to do otherwise, the network initialization scripts populate this file.

/etc/sysconfig/network
This file specifies routing and host information for all network interfaces. It is used to contain directives which are to have global effect and not to be interface specific.

/etc/sysconfig/network-scripts/ifcfg-interface-name

For each network interface, there is a corresponding interface configuration script. Each of these files provide information specific to a particular network interface. 

No comments:

Post a Comment