> For the complete documentation index, see [llms.txt](https://cheats.philkeeble.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cheats.philkeeble.com/linux/networking.md).

# Networking

## Routing

```
# Check Routes
sudo route

# Add route with route
sudo route add -net 192.168.222.0 netmask 255.255.255.0 gw 10.175.34.1 tap0

# Remove route with route
sudo route del -net 192.168.222.0 netmask 255.255.255.0 gw 10.175.34.1 tap0

# Add route with ip
sudo ip route add 192.168.222.0/24 via 10.175.34.1

# Remove route with ip
sudo ip route del 192.168.222.0/24 via 10.175.34.1
```

## Arp Spoofing

```
sudo apt-get install dsniff
sudo arpspoof

echo 1 > /proc/sys/net/ipv4/ip_forward
arpspoof -i <INTERFACE> -t <TARGETSERVER> -r <TARGETCLIENT>
```

## Port Scanning

### Nmap

```
# Full port scan
nmap -sS -p- -A <host> -T5 -oN outputfilename

# Ping sweep
nmap -sn <host>

# Host discovery, no ping
nmap -n -sn -PS22,135,443,445 <host>

# DNS discovery
sudo nmap -sS -sU -p53 -n <host>
```

### Hping / Hping3

```
```

## DNS

```
nslookup
> server <IP>
> set q=NS (Or any other type, MX, A etc)
> <DNSName, eg google.com)

# Dig 
dig @<serverIP> <DNSname> -t AXFR +nocookie

# Host
host -t axfr <DNSName> <SERVERIP>
```
