How to Disable IPv6 on Ubuntu

IPv6 is the most recent version of the Internet Protocol that provides a larger address space compared to IPv4. However, there may be scenarios where you need to disable IPv6 on an Ubuntu system, for instance, to troubleshoot network issues or if your network infrastructure does not support IPv6. This guide explains how to disable IPv6 on Ubuntu.

Methods to Disable IPv6 on Ubuntu

There are several methods to disable IPv6 on Ubuntu, ranging from temporary changes to permanent system configurations. You can choose the method that best suits your needs.

Method 1: Disable IPv6 Using sysctl (Temporary)

This method temporarily disables IPv6 until the system is rebooted. To disable IPv6 using sysctl, follow these steps:

  1. Open a terminal.
  2. Run the following commands to disable IPv6 on all interfaces:
  3. sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
    sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
    sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1
  4. Verify that IPv6 has been disabled by running:
  5. ip a | grep inet6
  6. If no IPv6 addresses are listed, the change has been successfully applied. However, the change will be lost after a reboot.

Method 2: Disable IPv6 Permanently Using sysctl

To permanently disable IPv6, you need to modify the system’s configuration files. This method ensures that IPv6 remains disabled even after a reboot:

  1. Edit the sysctl.conf file:
  2. sudo nano /etc/sysctl.conf
  3. At the end of the file, add the following lines:
  4. net.ipv6.conf.all.disable_ipv6 = 1
    net.ipv6.conf.default.disable_ipv6 = 1
    net.ipv6.conf.lo.disable_ipv6 = 1
  5. Save the file and exit the editor.
  6. Apply the changes by running:
  7. sudo sysctl -p
  8. Verify IPv6 is disabled by checking for IPv6 addresses again:
  9. ip a | grep inet6
  10. If no IPv6 addresses appear, the changes were successful and IPv6 will remain disabled permanently.

Method 3: Disable IPv6 Using Network Manager

If you’re using a desktop environment like GNOME or KDE, you can disable IPv6 using the Network Manager tool:

  1. Click on the network icon in the system tray and open the Network Settings menu.
  2. Select the network interface for which you want to disable IPv6 (e.g., Wired or Wireless).
  3. Click the gear icon next to the selected interface and go to the IPv6 Settings tab.
  4. Change the Method dropdown to Ignore.
  5. Click Apply to save the settings.

Method 4: Disable IPv6 Permanently via GRUB

For a permanent and system-wide solution, you can disable IPv6 via the GRUB configuration file. This method disables IPv6 at boot time, ensuring that IPv6 is not enabled even after a reboot.

  1. Edit the GRUB configuration file:
  2. sudo nano /etc/default/grub
  3. Locate the line starting with GRUB_CMDLINE_LINUX and add the following entry:
  4. GRUB_CMDLINE_LINUX=”ipv6.disable=1″
  5. Save the file and exit the editor.
  6. Update GRUB to apply the changes:
  7. sudo update-grub
  8. Reboot the system for the changes to take effect:
  9. sudo reboot
  10. After rebooting, verify that IPv6 has been disabled:
  11. ip a | grep inet6
  12. If no IPv6 addresses are listed, the change has been successfully applied, and IPv6 will remain disabled permanently even after system restarts.

Conclusion

Disabling IPv6 on Ubuntu can be useful for troubleshooting or when IPv6 is not supported in your network. You can either disable it temporarily using sysctl, permanently by editing configuration files, or through the Network Manager tool if you’re on a desktop environment. Choose the method that fits your needs and ensure that your system behaves as expected.


How to Change RabbitMQ Port and Set Up a Reverse Proxy with Nginx

RabbitMQ is a powerful message broker that supports various messaging protocols. By default, RabbitMQ listens on port 5672 for AMQP and 15672 for HTTP management UI. However, there are situations where you might want to change these ports or set up a reverse proxy using Nginx for enhanced security or easier access. This guide will walk you through the process.

Changing RabbitMQ Ports

To change the default ports used by RabbitMQ, you need to modify the RabbitMQ configuration file.

Locate the RabbitMQ Configuration File

RabbitMQ configuration can be managed using its configuration file (rabbitmq.conf) or the advanced configuration file (advanced.config). The default location of these files depends on your operating system:

  • Linux: /etc/rabbitmq/rabbitmq.conf
  • Windows: %APPDATA%\RabbitMQ\rabbitmq.conf

If the file doesn’t exist, you may need to create it.

Modify the Configuration File

To change the default ports, add the following entries to rabbitmq.conf:

listeners.tcp.default = 5673
management.listener.port = 15673
    

Here:

  • listeners.tcp.default changes the AMQP port.
  • management.listener.port changes the HTTP management UI port.

Restart RabbitMQ

After saving the configuration file, restart RabbitMQ to apply the changes:

sudo systemctl restart rabbitmq-server
    

Or, if you’re using Windows:

rabbitmq-service stop
rabbitmq-service start
    

Setting Up a Reverse Proxy with Nginx

Reverse proxies improve security, load balancing, and ease of access. With Nginx, you can configure RabbitMQ’s ports to be accessible through standard HTTP or HTTPS ports (80/443).

Install Nginx

Install Nginx if it’s not already installed:

  • On Ubuntu/Debian:
    sudo apt update && sudo apt install nginx
  • On CentOS/RHEL:
    sudo yum install nginx

Configure Nginx for RabbitMQ

Edit or create a new configuration file for RabbitMQ under /etc/nginx/sites-available/ or /etc/nginx/conf.d/.

server {
    listen 80;
    server_name rabbitmq.example.com;

    location / {
        proxy_pass http://127.0.0.1:15672;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

server {
    listen 443 ssl;
    server_name rabbitmq.example.com;

    ssl_certificate /path/to/ssl/certificate.crt;
    ssl_certificate_key /path/to/ssl/private.key;

    location / {
        proxy_pass http://127.0.0.1:15672;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}
    

Enable the Nginx Configuration

For sites-available setups:

sudo ln -s /etc/nginx/sites-available/rabbitmq.conf /etc/nginx/sites-enabled/
    

Test the configuration:

sudo nginx -t
    

Reload Nginx:

sudo systemctl reload nginx
    

Testing Your Setup

To test if everything is set up correctly:

  • For HTTP: http://rabbitmq.example.com
  • For HTTPS: https://rabbitmq.example.com

Verify port changes by using netstat or ss:

sudo netstat -tuln | grep 5673
    

Conclusion

By changing the RabbitMQ ports and setting up a reverse proxy with Nginx, you can better secure and optimize access to RabbitMQ services. This setup is particularly useful in production environments where security and scalability are critical.