telnet www.google.com 80
GET / HTTP/1.1
GET /search?q=telnet HTTP/1.1
host: www.google.com
openssl s_client -connect www.google.com:443
GET /search?q=openssl HTTP/1.1
ifconfig
ping 8.8.8.8
traceroute 8.8.8.8
nslookup google.com
netstat (on OSX: sudo lsof -i -P)
netstat -an | grep LISTEN
netstat -r
hostname
-
Find FQDN (DNS):
cat /etc/hosts
-
Network usage by port, avg:
iftop -B
-
Network usage by exe:
nethogs
-
Find network interface speed:
dmesg | grep -i "is Up"
-
Network ports open by program (OSX):
sudo lsof -i
-
SSH port forward (server to client):
ssh user@host -L 3306:localhost:3306
-
SSH X-11 forwarding setup for CentOS server:
Edit
/etc/ssh/sshd_config
: enable "X11Forwarding"yum install xorg-x11-xauth dbus-x11 liberation-*-fonts gnome-icon-theme
-
SSH X-11 forwarding setup for Ubuntu server:
Edit
/etc/ssh/sshd_config
: enable "X11Forwarding"apt-get install xbase-clients gnome-icon-theme
-
Show all firewall ports open/closed:
sudo iptables -L -v -n --line-numbers
-
Add firewall exception:
- Allow SSH:
iptables -A INPUT -s 0/0 -d 0/0 -p TCP -j ACCEPT --dport ssh
- Allow response to requests:
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
- Allow loopback:
iptables -v -A INPUT -i lo -j ACCEPT
- Allow pinging:
iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT
- Allow http:
iptables -A INPUT -p tcp --dport http -j ACCEPT
- Allow https:
iptables -A INPUT -p tcp --dport https -j ACCEPT
- Change default to DROP:
iptables -P INPUT DROP
- Remove REJECT ALL:
iptables -D INPUT -s 0/0 -d 0/0 -j REJECT --reject-with icmp-host-prohibited
- Save settings:
-
CentOS:
service iptables save
-
Ubuntu:
sudo apt-get install iptables-persistent sudo service iptables-persistent start sudo bash -c "iptables-save > /etc/iptables/rules"
-
- Allow SSH: