### Introduction

This reference guide is designed to assist with diagnosing and troubleshooting common networking issues on Debian-based Linux systems, following the relevant layers of the OSI model. It includes detailed commands and explanations for each layer, along with general tips and a troubleshooting scenario.

### Layer 1 (Physical Layer)

#### Verify Physical Connection:

- Ensure the Ethernet cable is properly connected.
- Check for link lights on the Ethernet port as a quick physical connectivity indicator.

### Layer 2 (Data Link Layer)

#### Check Interface Status:

```bash
ip link show
```

Look for the `UP` state to confirm that the interface is active.

#### Ensure the Correct MAC Address:

```bash
ip link show enp6s0
```

This command checks the MAC address and other physical layer properties.

### Layer 3 (Network Layer)

#### Verify IP Address Assignment:

```bash
ip addr show enp6s0
```

This confirms if an IP address is correctly assigned to the interface.

#### Check Routing Table:

```bash
ip route show
```

Ensure there's a valid route to the network or default gateway.

#### Ping Test for Local Network Connectivity:

```bash
ping -c 4 <gateway_ip>
ping -c 4 8.8.8.8
ping -c 4 www.google.com
```

Replace `<gateway_ip>` with your gateway IP address. Also, ping a public IP address (e.g., Google's DNS server 8.8.8.8) and a domain name to test external connectivity.

### Layer 4 (Transport Layer)

#### Testing Port Accessibility:

```bash
nc -zv <destination_ip> <port>
```

Netcat (`nc`) can test TCP port accessibility to a destination IP and port.

### Layer 7 (Application Layer)

#### DNS Resolution Test:

```bash
dig @<dns_server_ip> www.google.com
```

Replace `<dns_server_ip>` with your DNS server IP to test DNS resolution.

#### HTTP Connectivity Test:

```bash
curl -I www.google.com
```

This command checks for HTTP connectivity to a web service. The `-I` flag fetches only the headers. Omit it to retrieve the full webpage content.

### Additional Commands and Tips

- **Renew IP Address:**

```bash
sudo dhclient -r enp6s0 && sudo dhclient enp6s0
```

This releases and renews the DHCP lease for the `enp6s0` interface.

- **Restart and Check Network Manager Status:**

```bash
sudo systemctl restart NetworkManager
sudo systemctl status NetworkManager
```

This restarts the network management service and checks its status.

- **View Network Manager Logs:**

```bash
sudo journalctl -u NetworkManager --since today
```

View today's logs for NetworkManager to identify issues.

- **Use `ethtool` for Diagnosing Physical Link Status and Speed:**

```bash
ethtool enp6s0
```

This tool provides a detailed report on the physical link status.

- **System Logs for Networking Events:**

```bash
dmesg | grep -i enp6s0
```

Check kernel ring buffer messages for the `enp6s0` interface.

### Troubleshooting Scenario: No Internet Connectivity

1. Verify physical connection (Layer 1)
2. Check interface status and IP address assignment (Layer 2 & 3)
3. Ping gateway, public IP, and domain (Layer 3)
4. Check DNS resolution (Layer 7)
5. Restart NetworkManager and check status
6. Review NetworkManager logs for any errors
7. Check system logs for interface-specific messages

### Notes:

- **Consistent Naming Convention:** This guide uses `enp6s0` as an example network interface name. Replace `enp6s0` with your actual interface name as necessary.
- **Permissions:** Some commands may require `sudo` to execute with administrative privileges.

This guide aims to be a comprehensive resource for networking issues on Debian-based Linux systems, following a systematic approach from the physical layer up to the application layer.

---

To enable (bring up) or disable (bring down) a network interface on a Debian-based Linux system, similar to performing a `shut` or `no shut` on a Cisco IOS device, you can use the `ip` command. This command is part of the `iproute2` package, which is installed by default on most Linux distributions.

### To Disable (Bring Down) the Interface:

```bash
sudo ip link set enp6s0 down
```

This command effectively "shuts down" the interface `enp6s0`, making it inactive and unable to send or receive traffic, similar to the `shutdown` command in Cisco IOS.

### To Enable (Bring Up) the Interface:

```bash
sudo ip link set enp6s0 up
```

This command activates the interface `enp6s0`, allowing it to send and receive traffic, akin to the `no shutdown` command in Cisco IOS.

### Verifying the Interface Status:

After enabling or disabling the interface, you may want to verify its status:

```bash
ip addr show enp6s0
```
or
```bash
ip link show enp6s0
```

These commands display the current status of the `enp6s0` interface, including whether it is `UP` (enabled) or `DOWN` (disabled), along with other details like its IP address if it is configured and active.

### Note:

- These commands need to be executed with `sudo` or as the root user, as changing the state of network interfaces requires administrative privileges.
- The changes made using these commands are temporary and will be reverted upon system reboot. To make permanent changes to the network interface state, you would need to configure the interface's startup state in the system's network configuration files or use a network manager's configuration tools.