BASH Networking

From Indie IT Wiki
Jump to: navigation, search

Delete ARP Cache

sudo ip -s -s neigh flush all

Thanks -

Ping with Timestamp

ping -i1 -c20000 | while read pong; do echo "$(date '+%Y-%m-%d-%H:%M:%S')    $pong"; done

Speed Ping

alias ping='ping -c3 -n -i 0.2 -W1'
alias pingg='ping'
alias pingp='ping'

Sort IP Addresses

arp | sort -t . -k 3,3n -k 4,4n

Thanks to

Default Route Gateway - Change | Add | Delete

route del default gw eth0
route add default gw eth0

Ping At Specified Intervals

The following example sets a ping once a minute:

ping -i60

Thanks to Ubuntu Forums.

Blink Lights On Network Card

ethtool -p eth0 10

This will blink the lights for 10 seconds. However if you get this message...

Cannot identify NIC: Operation not supported are out of luck because it only works with some chipsets and drivers:-

"-p initiates adapter-specific action intended to enable an operator to easily identify the adapter by sight. Typically this involves blinking one or more LEDs on the specific ethernet port."


Thanks to Redhat, Linux Journal & Linux Toolkit.

Detect Ip Address Conflicts

Install the relevant software, for Debian/Ubuntu:

sudo apt-get install arp-scan

For CentOS, Fedora or Redhat:

sudo yum install arp-scan

Once installed to use:

sudo arp-scan -I eth0 -l

This should return something similar to:

Interface: eth0, datalink type: EN10MB (Ethernet)
Starting arp-scan 1.8.1 with 256 hosts (	1c:c1:de:1c:74:8f	Hewlett Packard	00:1b:a9:8a:52:d2	BROTHER INDUSTRIES, LTD.	f4:ec:38:a8:d0:de	TP-LINK TECHNOLOGIES CO., LTD.	00:1d:fe:df:2c:53	Palm, Inc	00:1d:fe:e9:1a:ca	Palm, Inc

Use Conntrack To Block An Ip Address

conntrack -L -s {IP-ADDRESS}
conntrack -D -s {IP-ADDRESS}