Sanitize Chapter 4

This commit is contained in:
ganome 2024-09-05 17:01:20 -06:00
parent 4bad49171e
commit 3e41580e35
Signed by untrusted user who does not match committer: Ganome
GPG Key ID: 944DE53336D81B83
7 changed files with 120 additions and 346 deletions

View File

@ -10,15 +10,11 @@ Linux uses network interfaces to communicate with networks. Common interfaces in
To list network interfaces:
```
ip link show
```
`ip link show`
or
```
ifconfig -a
```
`ifconfig -a`
## 2. IP Address Configuration
@ -26,15 +22,11 @@ ifconfig -a
- To set an IP address temporarily:
```
sudo ip addr add 192.168.1.100/24 dev eth0
```
`sudo ip addr add 192.168.1.100/24 dev eth0`
- To remove an IP address:
```
sudo ip addr del 192.168.1.100/24 dev eth0
```
`sudo ip addr del 192.168.1.100/24 dev eth0`
### Permanent IP configuration:
@ -71,9 +63,7 @@ Many modern Linux distributions use Network Manager for easier network configura
Set the hostname:
```
sudo hostnamectl set-hostname new-hostname
```
`sudo hostnamectl set-hostname new-hostname`
Update /etc/hosts file to include the new hostname.
@ -92,15 +82,11 @@ Note: This file may be overwritten by DHCP. For permanent changes, configure you
View routing table:
```
ip route show
```
`ip route show`
Add a static route:
```
sudo ip route add 10.0.0.0/24 via 192.168.1.1 dev eth0
```
`sudo ip route add 10.0.0.0/24 via 192.168.1.1 dev eth0`
## 8. Firewall Configuration
@ -108,15 +94,11 @@ Most Linux distributions use iptables or nftables. Ubuntu uses ufw (Uncomplicate
Enable UFW:
```
sudo ufw enable
```
`sudo ufw enable`
Allow incoming SSH:
```
sudo ufw allow ssh
```
`sudo ufw allow ssh`
## 9. Network Diagnostics
@ -129,27 +111,22 @@ sudo ufw allow ssh
Start/stop network service:
```
sudo systemctl start networking
sudo systemctl stop networking
```
`sudo systemctl start networking`
`sudo systemctl stop networking`
Enable/disable network service at boot:
```
sudo systemctl enable networking
sudo systemctl disable networking
```
`sudo systemctl enable networking`
`sudo systemctl disable networking`
## 11. Wireless Network Configuration
Use 'iwconfig' to configure wireless interfaces:
```
sudo iwconfig wlan0 essid "NetworkName" key s:password
```
`sudo iwconfig wlan0 essid "NetworkName" key s:password` #Not advised because it will leave your network password in the bash history!
For WPA networks, use 'wpa_supplicant'.
- `wpa_passphrase [ESSID] > /etc/wpa_supplicant/wpa_supplicanmt-[DEVICENAME].conf`. You will then be prompted to enter the password.
## 12. Network Bonding
@ -167,10 +144,3 @@ iface bond0 inet static
bond-primary eth0
```
- [(1) The Ultimate Guide to Linux Mint Network Configuration.](https://www.fosslinux.com/105545/the-ultimate-guide-to-linux-mint-network-configuration.htm.)
- [(2) How to set up an Internet Connection in Linux Mint?.](https://unix.stackexchange.com/questions/132747/how-to-set-up-an-internet-connection-in-linux-mint.)
- [(3) How to Share Files and Folders on a Linux Mint Network.](https://www.fosslinux.com/103443/how-to-easily-share-files-and-folders-on-a-linux-mint-network.htm.)
- [(4) Linux Mint - Community.](https://community.linuxmint.com/tutorial/view/1966.)
- [(5) Configure Network in Debian / Ubuntu / LinuxMint - ITzGeek.](https://www.itzgeek.com/how-tos/linux/ubuntu-how-tos/configure-network-in-ubuntu-14-04-linux-mint.html.)

View File

@ -23,14 +23,16 @@ Key features:
- IPv6 support
Basic UFW commands:
```
sudo ufw enable # Enable the firewall
sudo ufw disable # Disable the firewall
sudo ufw status # Check firewall status
sudo ufw allow 22 # Allow incoming traffic on port 22 (SSH)
sudo ufw deny 80 # Deny incoming traffic on port 80 (HTTP)
sudo ufw allow from 192.168.1.0/24 # Allow traffic from a specific subnet
```
- `sudo ufw enable` # Enable the firewall
- `sudo ufw disable` # Disable the firewall
- `sudo ufw status` # Check firewall status
`sudo ufw status numbered` # List the current ufw rules and their associated rule number
`sudo ufw delete RULENUM` # Delete the firewall rule by number
- `sudo ufw allow 22` # Allow incoming traffic on port 22 (SSH)
- `sudo ufw deny 80` # Deny incoming traffic on port 80 (HTTP)
- `sudo ufw allow from 192.168.1.0/24` # Allow traffic from a specific subnet
- `sudo ufw allow 32400/tcp` # Open port for Plex Server - ONLY accepting TCP traffic.
Advanced usage:
- Rate limiting: `sudo ufw limit 22/tcp`
@ -46,14 +48,12 @@ Key features:
- Runtime and permanent configuration options
- D-Bus interface for easy integration with other applications
Basic firewalld commands:
```
sudo systemctl start firewalld # Start firewalld
sudo systemctl enable firewalld # Enable firewalld to start on boot
sudo firewall-cmd --state # Check firewalld status
sudo firewall-cmd --zone=public --add-service=http # Allow HTTP traffic in the public zone
sudo firewall-cmd --zone=internal --add-source=192.168.1.0/24 # Add a source to the internal zone
```
- Basic firewalld commands:
- `sudo systemctl start firewalld` # Start firewalld
- `sudo systemctl enable firewalld` # Enable firewalld to start on boot
- `sudo firewall-cmd --state` # Check firewalld status
- `sudo firewall-cmd --zone=public --add-service=http` # Allow HTTP traffic in the public zone
- `sudo firewall-cmd --zone=internal --add-source=192.168.1.0/24` # Add a source to the internal zone
Advanced usage:
- Custom services: `sudo firewall-cmd --new-service=myapp`
@ -66,6 +66,7 @@ Advanced usage:
- Simpler, more straightforward for basic setups
- Ideal for single-host systems or simple network configurations
- Easier to learn for beginners
- Has a GUI (gufw) that can be installed. `sudo apt update && sudo apt install gufw`
### firewalld:
- More flexible and powerful for complex network setups
@ -85,10 +86,8 @@ Advanced usage:
- Test connections with tools like `netcat` or `telnet`
- Temporarily disable the firewall to isolate issues
## 8. Advanced Topics
## 8. Advanced Topics (Coming Soon)
- Stateful vs. stateless firewalls
- Network Address Translation (NAT) configuration
- Setting up DMZ (Demilitarized Zone)
- Integrating with intrusion detection/prevention systems (IDS/IPS)
This guide provides a comprehensive overview of Linux firewalls, focusing on UFW and firewalld. Each tool has its strengths, and the choice between them often depends on the specific requirements of your system and network configuration.

View File

@ -1,37 +0,0 @@
Certainly! Let's explore how to manage firewalls in **Linux Mint** using the terminal. There are a couple of options available:
## 1. **UFW (Uncomplicated Firewall)**:
- UFW is a straightforward and reliable firewall interface with both command-line and graphical tools.
- To install UFW, open the terminal and run:
```
sudo apt install ufw
```
- Verify if UFW is active with:
```
sudo systemctl status ufw
```
- To allow specific ports (e.g., OpenSSH), use:
```
sudo ufw allow 22/tcp
```
- To disable a port, run:
```
sudo ufw deny 22/tcp
```
2. **Gufw (GUI for UFW)**:
- Gufw provides a graphical interface for managing UFW.
- Install it with:
```
sudo apt install gufw
```
- Open it from the menu: "Firewall Configuration."
- For example: In Firewall configuration make sure Port TCP:32400 is open for Plex Server.
Remember, firewalls protect your network by filtering traffic based on predefined rules. Choose the method that suits your preference! 😊🔥
Source: Conversation with Copilot, 7/12/2024
- [(1) How to open a firewall on Linux Mint | FOSS Linux.](https://www.fosslinux.com/50961/open-a-firewall-on-linux-mint.htm.)
- [(2) Linux Mint - Community.](https://community.linuxmint.com/tutorial/view/1899.)
- [(3) LINUX Firewall - GeeksforGeeks.](https://www.geeksforgeeks.org/linux-firewall/.)
- [(4) firewalld-cmd Command in Linux: 24 Examples.](https://linuxhandbook.com/firewalld-cmd/.)

View File

@ -3,215 +3,117 @@
## 1. Basic Network Configuration Check:
- Check IP address and network interface status:
```
ip addr show
```
This command displays all network interfaces, their IP addresses, and status.
- `ip addr show` # This command displays all network interfaces, their IP addresses, and status.
- Verify default gateway:
```
ip route show
```
Ensures your system knows how to route traffic outside the local network.
- `ip route show` # Ensures your system knows how to route traffic outside the local network.
- Check DNS configuration:
```
cat /etc/resolv.conf
```
Displays the DNS servers your system is using.
- `cat /etc/resolv.conf` # Displays the DNS servers your system is using.
## 2. Connectivity Tests:
- Ping test:
```
ping -c 4 8.8.8.8
```
Tests basic connectivity to Google's DNS server (or any other IP).
- `ping -c 4 8.8.8.8` # Tests basic connectivity to Google's DNS server (or any other IP). Only pings 4 times (-c 4)
- Traceroute:
```
traceroute google.com
```
Shows the path packets take to reach a destination.
- `traceroute google.com` # Shows the path packets take to reach a destination.
- DNS resolution test:
```
nslookup google.com
```
or
```
dig google.com
```
These test DNS resolution capabilities.
- `nslookup google.com` # These test DNS resolution capabilities.
- `dig google.com` # These test DNS resolution capabilities.
## 3. Advanced Diagnostic Tools:
- netstat or ss:
```
netstat -tuln
```
or
```
ss -tuln
```
Display active network connections and listening ports.
- `netstat -tulpn` # Display active network connections and listening ports.
- `ss -tulpn` # Display active network connections and listening ports.
- tcpdump:
```
sudo tcpdump -i eth0
```
Captures and displays packet data on a specified interface.
- `sudo tcpdump -i eth0` # eth0 is the Device name. Captures and displays packet data on a specified interface.
- nmap:
```
nmap -p- localhost
```
Scans for open ports on the local machine (or any specified target).
- `nmap -p- localhost` # Scans every port on the local machine (or any specified target).
## 4. Firewall Configuration:
- Check iptables rules:
```
sudo iptables -L -v -n
```
Displays current firewall rules.
- `sudo iptables -L -v -n` # Displays current firewall rules.
- Temporarily disable firewall (for testing):
```
sudo systemctl stop firewalld # for systems using firewalld
```
or
```
sudo ufw disable # for systems using ufw
```
- `sudo systemctl stop firewalld` # Stops firewalld on the current boot - will start at next boot if enabled
- `sudo ufw disable` # Disables firewalld at system boot and stops it immedietely
## 5. Network Service Diagnostics:
- Check service status:
```
systemctl status networking
```
or
```
systemctl status NetworkManager
```
- `systemctl status networking`
- `systemctl status NetworkManager`
- Restart network service:
```
sudo systemctl restart networking
```
or
```
sudo systemctl restart NetworkManager
```
- `sudo systemctl restart networking`
- `sudo systemctl restart NetworkManager`
## 6. Network Interface Configuration:
- Edit network interface configuration:
```
sudo nano /etc/network/interfaces # for Debian-based systems
```
or
```
sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0 # for Red Hat-based systems
```
- `sudo nano /etc/network/interfaces` # for Debian-based systems
- `sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0` # for Red Hat-based systems
- Restart specific network interface:
```
sudo ifdown eth0 && sudo ifup eth0
```
or
```
sudo ip link set eth0 down && sudo ip link set eth0 up
```
- `sudo ifdown eth0 && sudo ifup eth0`
- `sudo ip link set eth0 down && sudo ip link set eth0 up`
## 7. Wireless Network Troubleshooting:
- List available wireless networks:
```
sudo iwlist wlan0 scan
```
- `sudo iwlist wlan0 scan`
- Check wireless interface details:
```
iwconfig
```
- `iwconfig`
- Monitor wireless connection in real-time:
```
watch -n 1 iwconfig
```
- `watch -n 1 iwconfig`
## 8. Advanced Network Analysis:
- Wireshark: GUI-based packet analyzer
Install with:
```
sudo apt-get install wireshark # on Debian-based systems
```
or
```
sudo yum install wireshark # on Red Hat-based systems
```
- `sudo apt-get install wireshark` # on Debian-based systems
- `sudo yum install wireshark` # on Red Hat-based systems
- iftop: Displays bandwidth usage on an interface
```
sudo iftop -i eth0
```
- `sudo iftop -i eth0`
- nethogs: Groups bandwidth by process
```
sudo nethogs eth0
```
- `sudo nethogs eth0`
## 9. Performance Testing:
- iperf: Network performance measurement tool
```
iperf -s # on server
iperf -c server_ip # on client
```
- `iperf -s` # on server
- `iperf -c server_ip` # on client
- speedtest-cli: Command-line interface for testing internet speed
```
speedtest-cli
```
`speedtest-cli`
## 10. Log Analysis:
- System logs:
```
sudo tail -f /var/log/syslog # on Debian-based systems
```
or
```
sudo tail -f /var/log/messages # on Red Hat-based systems
```
or
```
sudo journalctl -b0
```
or
```
sudo dmesg -k
```
- `sudo tail -f /var/log/syslog` # on Debian-based systems
- `sudo tail -f /var/log/messages` # on Red Hat-based systems
- `sudo journalctl -b0`
- `sudo dmesg -k`
- Network-specific logs:
```
sudo tail -f /var/log/daemon.log
```
- `sudo tail -f /var/log/daemon.log`
## 11. Network Configuration Backup and Restore:
- Backup network configuration:
```
sudo tar -czvf network_config_backup.tar.gz /etc/network
```
- `sudo tar -czvf network_config_backup.tar.gz /etc/network` # Create a file called network_config_backup.tar.gz from the /etc/network directory
- Restore network configuration:
```
sudo tar -xzvf network_config_backup.tar.gz -C /
```
- `sudo tar -xzvf network_config_backup.tar.gz -C /`
## 12. Troubleshooting Specific Issues:

View File

@ -1,27 +0,0 @@
## Certainly! To use SSH in **Linux Mint**, follow these steps:
1. **Install OpenSSH Server**:
- Open a terminal by clicking the terminal icon in the taskbar.
- Install the OpenSSH server package with this command (use root privileges): `sudo apt-get install openssh-server -y`.
2. **Check SSH Status**:
- SSH should be configured to start automatically on boot. Confirm this with:
```
systemctl is-enabled ssh
```
- If it's disabled, enable it using: `sudo systemctl enable ssh`.
3. **Test SSH Access**:
- Find your Linux Mint machine's IP address (e.g., `192.168.1.20`) using `ip a`.
- Use PuTTY or any SSH client to connect: `ssh username@192.168.1.20`.
- Enter your password when prompted¹.
Feel free to ask if you need further assistance! 😊🚀
Source: Conversation with Copilot, 7/12/2024
- [(1) How To Enable SSH in Linux Mint - RootUsers.](https://www.rootusers.com/enable-ssh-linux-mint/.)
- [(2) How-to Guide Linux Networking with SSH - Linux Mint Forums.](https://forums.linuxmint.com/viewtopic.php?t=13695.)
- [(3) Linux Mint - Community.]( https://community.linuxmint.com/tutorial/view/83.)
- [(4) How to Install and Enable SSH on Linux Mint 21 LinuxWays.](https://linuxways.net/mint/install-enable-ssh-linux-mint-21/.)
- [(5) Linux Mint - Community.](https://community.linuxmint.com/tutorial/view/244.)
- [(6) en.wikipedia.org.](https://en.wikipedia.org/wiki/Linux_Mint.)

View File

@ -29,7 +29,7 @@ SSH operates on a client-server model. The process typically involves:
## 5. SSH Key Management
- Generating Keys: Use `ssh-keygen` to create key pairs.
- Generating Keys: Use `ssh-keygen -t ed25519 -a 32` to create key pairs. (stored in ~/.ssh/ by default)
- Key Types: RSA, DSA, ECDSA, Ed25519 (Ed25519 is recommended for new deployments).
- Key Size: Larger keys are more secure but slower (e.g., 4096-bit RSA).
- Passphrase: An extra layer of security for private keys.
@ -37,10 +37,10 @@ SSH operates on a client-server model. The process typically involves:
## 6. Common SSH Commands
- `ssh user@hostname`: Basic connection command.
- `scp`: Secure copy files between hosts.
- `sftp`: Secure file transfer protocol.
- `scp user@hostname:/full/source/path ~/destination`: Secure copy files between hosts.
- `sftp user@hostname`: Secure file transfer protocol.
- `ssh-keygen`: Generate SSH key pairs.
- `ssh-copy-id`: Copy public key to a remote host.
- `ssh-copy-id user@hostname`: Copy your public key to a remote host.
## 7. SSH Configuration
@ -48,16 +48,16 @@ SSH operates on a client-server model. The process typically involves:
- Server Configuration: `/etc/ssh/sshd_config`
- Important settings:
- Port (default 22)
- PermitRootLogin
- PasswordAuthentication
- PubkeyAuthentication
- PermitRootLogin : Usually commented out to disable root from using SSH.
- PasswordAuthentication: Set to no if you want to only use RSA keys
- PubkeyAuthentication: Set to yes if you want to use RSA keys for authentication.
## 8. SSH Security Best Practices
- Use key-based authentication instead of passwords.
- Disable root login.
- Use non-standard ports.
- Implement fail2ban or similar intrusion prevention systems.
- Implement fail2ban or similar intrusion prevention systems. (sudo apt install fail2ban).
- Keep software up-to-date.
- Use SSH protocol version 2.
- Limit user access with AllowUsers or AllowGroups.
@ -65,21 +65,21 @@ SSH operates on a client-server model. The process typically involves:
## 9. Advanced SSH Features
- Port Forwarding: Local, Remote, and Dynamic.
- X11 Forwarding: Run graphical applications remotely.
- X11 Forwarding: Run graphical applications remotely. (Virtual Network Connections among others)
- SSH Agent: Manage multiple SSH keys.
- ProxyJump: Easily connect through a jump host.
## 10. Troubleshooting SSH
- Connection Issues: Check network, firewall, and SSH service status.
- Authentication Problems: Verify credentials, key permissions, and server configuration.
- Authentication Problems: Verify credentials, key permissions (`chmod 600 ~/.ssh/id_rsa*`), and server configuration.
- Performance Issues: Consider compression or alternative ciphers.
## 11. SSH Alternatives and Related Protocols
- Telnet: Older, unencrypted protocol (not recommended).
- RDP: Remote Desktop Protocol (mainly for Windows).
- VNC: Virtual Network Computing (graphical desktop sharing).
- Telnet: Older, unencrypted protocol (not recommended - INSECURE).
- RDP: Remote Desktop Protocol - allows a full desktop (mainly for Windows).
- VNC: Virtual Network Computing - allows a full desktop (graphical desktop sharing).
## 12. SSH in Enterprise Environments
@ -87,4 +87,3 @@ SSH operates on a client-server model. The process typically involves:
- Integration with LDAP or Active Directory.
- Auditing and logging considerations.
- Bastion hosts for added security.

View File

@ -8,22 +8,17 @@ VPNs (Virtual Private Networks) provide secure, encrypted connections over publi
OpenVPN is one of the most popular and secure VPN protocols. To set it up:
- 1. Install OpenVPN:
```
sudo apt install openvpn
```
`sudo apt install openvpn`
- 2. Obtain configuration files from your VPN provider.
Varies on each provider
- 3. Connect to the VPN:
```
sudo openvpn --config /path/to/your/config.ovpn
```
`sudo openvpn --config /path/to/your/config.ovpn`
- 4. For automatic connection, create a systemd service:
```
sudo nano /etc/systemd/system/openvpn.service
```
Add the following content:
`sudo nano /etc/systemd/system/openvpn.service`
- Add the following content:
```
[Unit]
Description=OpenVPN connection to YOUR_VPN
@ -38,34 +33,23 @@ WantedBy=multi-user.target
```
Enable and start the service:
```
sudo systemctl enable openvpn.service
sudo systemctl start openvpn.service
```
- `sudo systemctl enable --now openvpn.service` # Starts OpenVPN right "now" and "enable"s it on next boot as well
- `sudo systemctl start openvpn.service` # Just "start"s OpenVPN for the current boot.
### WireGuard:
WireGuard is a newer, faster VPN protocol. To set it up:
- a. Install WireGuard:
```
sudo apt install wireguard
```
- a. Install WireGuard: `sudo apt install wireguard`
- b. Create a configuration file:
```
sudo nano /etc/wireguard/wg0.conf
```
Add your WireGuard configuration details.
- b. Create a configuration file: `sudo nano /etc/wireguard/wg0.conf`
-Add your WireGuard configuration details specific to your vendor.
- c. Start the WireGuard connection:
```
sudo wg-quick up wg0
```
- sudo wg-quick up wg0`
- d. To enable automatic connection on boot:
```
sudo systemctl enable wg-quick@wg0
```
- d. To "enable" automatic connection on boot and right "now":
- `sudo systemctl enable --now wg-quick@wg0`
### Built-in VPN clients:
Many Linux distributions include built-in VPN clients in their network managers, supporting protocols like OpenVPN, L2TP/IPsec, and PPTP.
@ -76,6 +60,7 @@ Proxies route your traffic through an intermediary server. There are several way
### Environment variables:
Set these variables in your shell configuration file (e.g., ~/.bashrc):
```
export http_proxy="http://proxy_server:port"
export https_proxy="http://proxy_server:port"
@ -102,41 +87,29 @@ Many applications have their own proxy settings. For example:
Use proxychains to route terminal commands through a proxy:
#### 1. Install proxychains:
```
sudo apt install proxychains
```
`sudo apt install proxychains`
#### 2. Configure proxychains:
```
sudo nano /etc/proxychains.conf
```
`sudo nano /etc/proxychains.conf`
Add your proxy server details.
#### 3. Use proxychains:
```
proxychains command_to_run
```
`proxychains command_to_run`
### SOCKS proxy with SSH:
Create a SOCKS proxy using SSH:
```
ssh -D 1080 -f -C -q -N username@remote_host
```
Then configure applications to use SOCKS5 proxy at 127.0.0.1:1080.
- `ssh -D 1080 -f -C -q -N username@remote_host`
- Then configure applications to use SOCKS5 proxy at 127.0.0.1:1080.
## 3. Testing and Verification
To verify your VPN or proxy configuration:
- Check your IP address:
```
curl ifconfig.me
```
`curl ifconfig.me`
- DNS leak test:
```
dig +short myip.opendns.com @resolver1.opendns.com
```
`dig +short myip.opendns.com @resolver1.opendns.com`
- WebRTC leak test (in browsers)
@ -155,8 +128,3 @@ dig +short myip.opendns.com @resolver1.opendns.com
- Verify DNS settings
- Ensure correct permissions on configuration files
- Check for conflicting network settings
- [(1) Setting Up a VPN on Linux Mint: A Step-by-Step Guide - FOSS Linux.](https://www.fosslinux.com/102356/how-to-set-up-a-vpn-on-linux-mint.htm.)
- [(2) How to Configure OpenVPN in Linux Mint? IPVanish.](https://support.ipvanish.com/hc/en-us/articles/360001738513-How-to-Configure-OpenVPN-in-Linux-Mint.)
- [(3) How to configure OpenVPN on Linux Mint - FastVPN - Namecheap.](https://www.namecheap.com/support/knowledgebase/article.aspx/10416/2271/how-to-configure-openvpn-on-linux-mint/.)
- [(4) How to Set up an OpenVPN Connection in Linux Mint - Comparitech.](https://www.comparitech.com/blog/vpn-privacy/openvpn-connection-linux-mint/.)