#!/bin/bash # NIC config for enable XDP socket. # Check for ifconfig (deprecated) # (use iproute2 tools if ifconfig not present). IPCONFIG=$(which ifconfig) if [[ $IPCONFIG ]] ; then # Find availabe net interfaces (with ifconfig) availableNetif=`$IPCONFIG -s | sed 1d | awk "(\\$1 != \"lo\") { printf \\$1 \" \"}"` else echo " " echo " ifconfig (from net-tools) is not installed" echo "Install it to properly configure network devices" exit 1 fi # Check if root previlige if [ `id -u` -ne 0 ]; then echo "Please run this program as root." exit 1 fi # sudo ethtool -G enp1s0f0 rx 4096 tx 4096 # sudo ifconfig enp1s0f0 mtu 3000 txqueuelen 20000 up # sudo ethtool -L enp1s0f0 combined 1 setXDPConfig() { ETHTOOL=$(which ethtool) if [[ $ETHTOOL ]] ; then if [ -x $ETHTOOL ] ; then $ETHTOOL -G $netif_name rx 4096 tx 4096 $IPCONFIG $netif_name mtu 3000 txqueuelen 20000 up $ETHTOOL -L $netif_name combined 1 fi else echo "*** Unable to adjust NIC driver settings ***" echo "*** ethtool utility not found ***" fi } # Check the net interface number. if [ $# -eq 0 ] ; then echo "Usage : $0 " echo " e.g. $0 eth0" echo " Available net if names : $availableNetif" exit 1 else netif_name=$1 present=`echo $availableNetif | grep $netif_name` if [ "$present" == "" ] ; then echo "Error: net if $1 : Not Present" echo " Available net if names : $availableNetif" exit 1 fi fi setXDPConfig echo "Run completed!" exit 0