Networking Commands
Network Interfaces and Configuration
- Linux Commands:
ifconfig
- Purpose: Display or configure network interfaces.
ip addr show
or ip a
- Purpose: Display IP addresses and property information for all interfaces.
- Windows Command:
ipconfig
- Purpose: Display all current TCP/IP network configuration values.
Routing and Network Traffic Management
- IPv4 Forwarding:
sysctl -w net.ipv4.ip_forward=1
- Purpose: Enable IPv4 forwarding temporarily.
- Editing
/etc/sysctl.conf
to include net.ipv4.ip_forward=1
- Purpose: Make IPv4 forwarding setting persistent across reboots.
sysctl -p
- Purpose: Reload sysctl settings from
/etc/sysctl.conf
.
Firewall Configuration using iptables
- Viewing Rules:
iptables -L
- Purpose: List all active rules in the default filter table.
iptables -L -t <table>
- Purpose: List rules in a specific table.
- Adding Rules:
iptables -A <Chain> -s <IP> -j <Target>
- Purpose: Append a rule to a chain for packets from a specific IP.
- Deleting Rules:
iptables -D <ChainRule>
- Purpose: Delete a specific rule from a chain.
- Setting Default Policy:
iptables --policy INPUT DROP
- Purpose: Set the default policy for the INPUT chain to DROP.
- Deleting All Rules:
iptables -F
- Purpose: Flush all rules, deleting them.
- Specifying Protocols and Ports:
-p
: Specify protocol (TCP/UDP).
--dport
: Specify destination port.
--sport
: Specify source port.
-s
: Specify source IP address.
-d
: Specify destination IP address.
- Logging:
- Purpose: Log packets that match a rule; viewed with
journalctl
.
Packet Sniffing and Analysis
- tcpdump Usage:
tcpdump -i <interface>
- Purpose: Capture packets on a specific network interface.
tcpdump -l -i <interface>
- Purpose: Listens to the first 10 packets on that interface.
tcpdump -l -i <interface> | grep ICMP
- Purpose: Show only the ping packets generated by ICMP.
tcpdump -n -l -i <interface> <protocol>
- Filtering options provide more specific capture criteria, like protocol, source, and destination.
Service and Protocol Specific Configuration
- SSH, TFTP, FTP Configuration:
- Purpose: Instructions for configuring firewall rules to allow traffic for these services.
- TCP and UDP:
- Purpose: Discussion on handling traffic for these protocols in firewall rules.