Networking
Configuration
ifconfig
ip addr
ip addr show
ifconfig
ifconfig -a
ifdown enp0s3
ifup enp0s3
ifconfig enp0s3 192.168.0.150/24 # Not Permanent
Add Secondary IP
Link
ifconfig eth0:1 172.31.81.196 netmask 255.255.240.0 up # Not Permanent
Remove Secondary Ip
ip addr del 172.31.81.196/20 dev eth0:1 # Not Permanent
Network-Manager
sudo apt install network-manager
sudo service network-manager restart
nmcli
nmcli connection # Connection information
# Add Static Route
sudo nmcli connection add con-name STATIC ipv4.addresses 192.168.58.1/24 ifname eth0 type ethernet
nmcli connection show STATIC
sudo nmcli connection modify STATIC +ipv4.routes "172.16.0.0/16 192.168.58.254" ipv4.dns 172.16.58.254
Routes
route
route -n
route add default gw 192.168.0.254
Dns
cat /etc/hosts
cat /etc/nsswitch.conf # show how priority to will resolve dns
cat /etc/resolv.conf
cat /etc/dhcp/dhclient.conf
sudo service networking restart
File
cat /etc/network/interfaces
IP Tables
sudo iptables -t nat -L | grep 100.66.20.131
sudo iptables -t nat -L | grep nginx-service
Troubleshooting
Netstat
$ sudo netstat -nl -p tcp | grep 8123
$ sudo netstat -nl -p tcp | head
Get open ports
nmap localhost
netstat -at
SS
ss -an | grep -i listen
sudo ss -ntlp # To get process
Who listen on Port
Test Remote Connection to port
nc -v 10.240.100.18 2049
netcat -l 12345 # To listen a Port
Get Ports than services are listen
MTR
DNS
host google.com
dig google.com
TCP Dump
sudo tcpdump -v -l -i any 'host 100.65.17.226'
tcpdump -n port 6443
tcpdump port 443 and '(tcp-syn|tcp-ack)!=0'
VPN
Permanent VPN Connection
Article