Skip to main content

Command Palette

Search for a command to run...

Technical Support

LINUX - IP ADDRESS

Published
•1 min read•View as Markdown
Technical Support

### **1. Verify Current Networking and Firewall Configuration**

1. **Check IP addresses and network interfaces:**

Run the following command to get a list of network interfaces and their IP addresses.

```bash

ip addr

```

2. **Verify if iptables is installed:**

Check if iptables is available on your system.

```bash

iptables --version

```

3. **Check current iptables rules:**

List all existing rules in the firewall.

```bash

sudo iptables -L

```

---

### **2. Block Specific Ports**

You can block incoming traffic on specific ports using iptables.

1. **Block incoming traffic on port 80 (HTTP):**

  • This will block all HTTP traffic from reaching your server.

    ```bash

    sudo iptables -A INPUT -p tcp --dport 80 -j DROP

    ```

2. **Block incoming traffic on port 443 (HTTPS):**

  • This will block all HTTPS traffic.

    ```bash

    sudo iptables -A INPUT -p tcp --dport 443 -j DROP

    ```

3. **Verify the changes:**

  • List the rules to ensure that the ports are blocked.

    ```bash

    sudo iptables -L

    ```

4. **Test port blocking:**

  • From a different machine, try to access the blocked port using curl or a browser.

  • You should not be able to reach the server on ports 80 or 443.