linux_network - JasonWayne/personal-wiki GitHub Wiki

Network commands

netcat

# netcat
nc
printf 'HEAD / HTTP/1.1\r\nHost: www.udacity.com\r\n\r\n' | nc www.udacity.com 80
# test ssh connectivity
printf '123' | nc host_ip 22

ip

ip a
ip route show 
ip addr show eth0

ping

ping -c3 8.8.8.8

host

(py3) jason@jason-Ubuntu:~$ host -t aaaa google.com
google.com has IPv6 address 2404:6800:4008:803::200e
(py3) jason@jason-Ubuntu:~$ host -t aaaa baidu.com
baidu.com has no AAAA record
(py3) jason@jason-Ubuntu:~$ host -t mx udacity.com
udacity.com mail is handled by 20 alt2.aspmx.l.google.com.
udacity.com mail is handled by 30 aspmx2.googlemail.com.
udacity.com mail is handled by 30 aspmx3.googlemail.com.
udacity.com mail is handled by 10 aspmx.l.google.com.
udacity.com mail is handled by 20 alt1.aspmx.l.google.com.


tcpdump

tcpdump -n -c5 -i enp3s0 port 22

traceroute

(py3) jason@jason-Ubuntu:~$ traceroute www.udacity.com
traceroute to www.udacity.com (52.42.50.101), 30 hops max, 60 byte packets
 1  192.168.3.1 (192.168.3.1)  0.473 ms  0.677 ms  0.815 ms
 2  192.168.0.1 (192.168.0.1)  3.247 ms  3.935 ms  4.013 ms
 3  192.168.17.1 (192.168.17.1)  4.545 ms  4.631 ms  4.673 ms

 4  * * *
 5  * * *

mtr

mtr www.udacity.com

netcat

# very basic example
# server side
nc -l 2389

# client side
nc localhost 2389

8 Practical Linux Netcat NC Command Example Netcat – a couple of useful examples

iptables

iptables -nvL

iptables -I INPUT -p udp -s 100.64.0.0/10 --dport 123 -j ACCEPT