Friday, August 12, 2016

redhat network Commands

copied it from linuxCmdNetwork.docx in laptop

===============Networking===============================
ifconfig -a
ifconfig eth1 up    --->  to activate eth1
ifconfig eth1 down    ---> to de activate the eth1
ifup bond1  ---->  to activate a bond
service network restart   ---->  to restart network service
service network status    ----->   status of the network devices
system-config-network  ---> command to configure the Ethernet

list the network  devices
lspci
lspci -tv
lspci |grep net
systool -c net
systool -c net -v |grep -v "00 00 00"|grep -v "0x000"
systool -c net -d eth6  -v |grep -v "00 00 00"|grep -v "0x000"

To see  speed of  a Interface
systool -c net -d eth6  -v |grep -v "00 00 00"|grep -v "0x000" |egrep "Class |speed"
systool -c net  -v |grep -v "00 00 00"|grep -v "0x000" |egrep "Class|speed"
grep -H .  /sys/class/net/*/speed
grep -H .  /sys/class/net/*/mtu

To  see  the   interface  and   network  slot  info
/opt/dell/srvadmin/bin/omreport  chassis  nics

2) to see  onboard  network ports using dmidecode
Use below command to see the BUS Address for Ethernet ports
dmidecode -t baseboard |egrep -i "Desig|Bus|type|status"
dmidecode -t baseboard |grep -B1 -A3 Ethernet |egrep -i "Desig|Bus|type|status"
Then use below command to see eth# in  each BUS
systool -c net
lspci -tv |grep net

3)To see PCI slot network ports using dmidecode
Use below command to see BUSAddress for PCI slots
            dmidecode -t slot |egrep "Desig|Bus|Current|Type"
Then use below command to see eth# in  each BUS
systool -c net
lspci -tv |grep net


To  assign ipaddress on  interface
ifconfig eth1  xx.xx.xx.xx  netmask  255.xxx.xxx.x  up
service network restart

$ cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
IPADDR=167.143.186.235
NETMASK=255.255.254.0
GATEWAY=167.143.186.1
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
# Added OPTS for RHEL6 (glh)
        BONDING_OPTS="miimon=100 mode=active-backup"

Set static route  via bond1  ip address
$ cat /etc/sysconfig/network-scripts/route-bond1
162.100.228.0/24  via   170.13.151.1  dev  bond1
130.29.230.0/24  via  170.13.151.1 dev bond1

Netstat command
netstat  -rn      >>  to see routing table       
route  -e      >>      to see routing table        
netstat  -in      >>  network statistics summary
netstat  -an     >>  this will list all ports and their status
cat  /proc/net/dev  >>  to see packet send/receive summary through diff interfaces

to See  ports Listening Status
            grep 9080  /etc/services
            glrpc           9080/tcp                # Groove GLRPC
            netstat -anp  |grep 9080
            netstat -an | grep 1002
            netstat -lpn  ==>  to list listening ports
            netstat -lpn  |grep 1002
            netstat  -tulpn  ==> tcp,udp  listening ports

     lsof -i tcp:1002
     lsof -i udp:1002
     lsof -i  :1002
     lsof  -i |grep  glrpc
     lsof |grep glrpc

 http://www.binarytides.com/linux-ss-command/    ss command  usage 
List all connections The simplest command is to list out all connections. $  ss  | less



change network interface names permanently in Linux
In /etc/udev/rules.d/70-persistent-net.rules, you can assign  device name to a particular MAC address.
find out the MAC address interface"grep -H . /sys/class/net/*/address"  , and then define the interface name to that MAC address in the following format.
# interface with MAC address "00:0c:29:43:28:11" will be assigned "eth0"                                                                            
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:43:28:11", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

To see if an interface  have connection 
ethtool eth2
Settings for eth1:
        Supports Wake-on: g
        Wake-on: d
        Link detected: yes 
mii-tool -v
eth0: negotiated, link ok


To enable Jumbo frames in Linux
To set temporary
# ifconfig eth0 mtu 9000
To Make changes permanent:-Edit the network configuration file for eth0 interface - /etc/sysconfig/network-scripts/ifcfg-eth0 (CentOS / RHEL / Fedora Linux):
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Append the following configuration directive, which specifies the size of the frame in bytes:
MTU 9000
 Restart the Interface eth0:
 /etc/init.d/network restart   or service network restart
To confirm the MTU used between two specific devices. use ip command as follows:
# ip route get {IP-address}
# ip route get 192.168.1.1
Do Ping Test
# ping   -s 8192   -I <source interconnect IP address> <destination IP address>
Example:
# ping -s 8192 -I 198.18.0.38 198.18.0.39




To see the bonds and the   related  network adapers
cd /proc/net/bonding
ls
cat bond0 
cd /sys/class/net/
[root@dansrzd180 net]# ls
bond0  bond1  eth0  eth1  eth2  eth3  lo  sit0



Steps to make BONDS
doc-7944    (how to make bond  RH3)
doc-8108    what are diff modes
how to make bond in RH4
http://kbase.redhat.com/faq/docs/DOC-4284
http://www.cyberciti.biz/tips/linux-bond-or-team-multiple-network-interfaces-nic-into-single-interface.html
http://et.redhat.com/~jmh/docs/Xen_networking.pdf


remember to make backup of files being changed  before editing
step1 :- update   /etc/modprobe.conf   with proper entties as below
vi /etc/modprobe.conf 
alias bond0 bonding
options bonding miimon=100 mode=1 max_bonds=2
install bond0 /sbin/modprobe bonding --ignore-install bonding
alias bond1 bonding
install  bond1 /sbin/modprobe bonding -o bond1

step2:  create fcfg-eth1,fcfg-eth3 and ifcfg-bond1  with simillar entries like below in /etc/sysconfig/network-scripts
[root@dansrzd180 network-scripts]# cat ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
MASTER=bond1
SLAVE=yes
USERCTL=no
HWADDR=00:24:E8:64:62:53

[root@dansrzd180 network-scripts]# cat ifcfg-eth3
DEVICE=eth3
BOOTPROTO=none
ONBOOT=yes
MASTER=bond1
SLAVE=yes
USERCTL=no
HWADDR=00:15:17:BC:C5:BD

[root@dansrzd180 network-scripts]# cat ifcfg-bond1
DEVICE=bond1
IPADDR=10.28.130.40
NETMASK=255.255.255.0
GATEWAY=
ONBOOT=yes
BOOTPROTO=none
USERCTL=no

step3 :-
update  /etc/hosts  file with interconnect ipaddresses
restart the networks and bringup the bond1
modprobe bonding
service network restart
ifup bond1




Kernal Mudule Commands

lsmod |grep bond   
rmmod    modname
modprobe --show-depends bond1
depmod -a   (generate map files )
modprobe - program to add and remove modules from the Linux Kernel
  eg:-  modprobe  bonding  -o bond1
            ifconfig bond1 down  ; modprobe -r bond1

Configuring the Linux6 host for LACP bonding

step1:Linux Kernel Module Configuration

#/etc/modprobe.d/bonding.conf
alias bond0 bonding
options bond0 miimon=100 mode=4 lacp_rate=1

step2:set Linux Network file Configuration
# cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
ONBOOT=yes
BOOTPROTO=none
IPADDR=10.29.194.99
NETMASK=255.255.255.0
GATEWAY=10.29.194.1
BONDING_OPTS="mode=4 miimon=100 lacp_rate=1"
 # cat /etc/sysconfig/network-scripts/ifcfg-eth4
DEVICE="eth4"
BOOTPROTO="none"
HWADDR="00:10:18:F3:B7:1C"
ONBOOT="yes"
MASTER=bond0
SLAVE=yes
# cat cat /etc/sysconfig/network-scripts/ifcfg-eth5
cat: cat: No such file or directory
DEVICE="eth5"
HWADDR="00:10:18:F3:B7:1E"
ONBOOT="yes"
MASTER=bond0
SLAVE=yes

Restart network
service network restart


--------------------------------------------------------------------
Set  the  tcp window size  
Method1
Add to  /etc/sysctl.conf  below values
# TCP buffers
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
# autotune TCP buffers
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
then do
sysctl  -p

Method 2
Command
Description
echo "1" > /proc/sys/net/ipv4/tcp_window_scaling
Activate window scaling according to RFC 1323
echo "1" > /proc/sys/net/ipv4/tcp_timestamps
Activate timestamps according to RFC 1323
echo [wmax] > /proc/sys/net/core/rmem_max
Set maximum size of TCP receive window.
echo [wmax] > /proc/sys/net/core/wmem_max
Set maximum size of TCP transmit window.
echo [wmax] > /proc/sys/net/core/rmem_default
Set default size of TCP receive window.
echo [wmax] > /proc/sys/net/core/wmem_default
Set default size of TCP transmit window.
echo "[wmin] [wstd] [wmax]" > /proc/sys/net/ipv4/tcp_rmem
Set min, default, max receive window. Used by the autotuning function.
echo "[wmin] [wstd] [wmax]" > /proc/sys/net/ipv4/tcp_wmem
Set min, default, max transmit window. Used by the autotuning function.
echo "bmin bdef bmax" > /proc/sys/net/ipv4/tcp_mem
Set maximum total TCP buffer-space allocatable. Used by the autotuning function.
ifconfig eth? txqueuelen 1000
Define length of transmit queue. Replace "?" with actual interface number.

Or 
sysctl -w "net.ipv4.tcp_window_scaling=0"
sysctl -w net.ipv4.tcp_congestion_control=cubic
TO see the kernel parameter value
sysctl  net.ipv4.tcp_window_scaling
To set the pagecache
echo "1 8 10" > /proc/sys/vm/pagecache
or
sysctl -w vm.pagecache="1 8 10"
or
echo "vm.pagecache=1 8 10" >> /etc/sysctl.conf
sysctl -p
-----------------------------------------------------------------------------------------



















No comments:

Post a Comment