BASH Networking

From Indie IT Wiki
Revision as of 15:03, 9 September 2024 by Plittlefield (talk | contribs) (→‎Install IPInfo CLI)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Install IPInfo CLI

sudo add-apt-repository ppa:ipinfo/ppa
sudo apt update
sudo apt install ipinfo
ipinfo myip
ipinfo 1.1.1.1
ipinfo www.bbc.co.uk

Add Dummy IP Address Using ip

sudo -i
ip link add dev dummy1 type dummy
ip link set dummy1 up
ip addr add dev dummy1 192.0.2.10/32

View TCP and UDP Ports without Netstat

ss -aut

https://linux-audit.com/alternative-netstat-ss-tool/

Change the MAC Address of a Network Interface

sudo apt-get -y install macchanger

https://vitux.com/how-to-change-spoof-a-mac-address-in-ubuntu/

Delete ARP Cache

sudo ip -s -s neigh flush all

Thanks - https://askubuntu.com/questions/632837

Ping with Timestamp

Linux

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

macOS

ping google.com | while read pong; do echo "$(date):  $pong"; done

Speed Ping

alias ping='ping -c3 -n -i 0.2 -W1'
alias pingg='ping www.google.co.uk'
alias pingp='ping www.paully.co.uk'

Sort IP Addresses

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

Thanks to Cyberciti.biz

Default Route Gateway - Change | Add | Delete

route del default gw 192.168.0.254 eth0
route add default gw 192.168.0.1 eth0

Ping At Specified Intervals

The following example sets a ping once a minute:

ping -i60 127.0.0.1

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

...you 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."

ewrk3
s2io
sky2
tg3
e100
pcnet32
bnx2
skge
e1000
sk98lin
ixgb

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 (http://www.nta-monitor.com/tools/arp-scan/)
192.168.0.1	1c:c1:de:1c:74:8f	Hewlett Packard
192.168.0.21	00:1b:a9:8a:52:d2	BROTHER INDUSTRIES, LTD.
192.168.0.41	f4:ec:38:a8:d0:de	TP-LINK TECHNOLOGIES CO., LTD.
192.168.0.52	00:1d:fe:df:2c:53	Palm, Inc
192.168.0.86	00:1d:fe:e9:1a:ca	Palm, Inc

IPCONFIG

https://www.computerhope.com/unix/uifconfi.htm

Use Conntrack To Block An Ip Address

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