How to Set Proxy in Linux: A Step-by-Step Guide

Sohail
Sohail

Table of Contents

Setting up a proxy in Linux allows you to route your network traffic through an intermediary server, enhancing privacy, security, and access control. Whether you’re using a Linux distribution such as Ubuntu or Kali Linux, this article will teach you to set proxy in Linux.

We will cover command-line and graphical methods to cater to user preferences.

How to Set Proxy in Linux

set proxy in linux
how proxy works

Installing Prerequisites

Before we begin, ensure that your system has the necessary tools installed. Open a terminal and enter the following command to install the required package –

sudo apt update
sudo apt install proxychains

Configuring Proxychains

Next, we need to edit the Proxychains configuration file. Execute the following command to open the configuration file in a text editor –

sudo nano /etc/proxychains.conf

Locate the dynamic_chain section within the file and uncomment the line beginning with “dynamic_chain.” Save and exit the file.

Setting Proxy in Applications

To use the proxy for specific applications, you must append the proxychains command to their execution. For example, to run Firefox with the proxy, use the following command –

proxychains firefox

Replace “firefox” with the name of the desired application.

User Setting Up Permanent Proxy

Proxy Configuration File

In Linux, the proxy settings can be stored in a configuration file. Open a terminal and enter the following command to create the configuration file if it doesn’t already exist –

touch ~/.bashrc_proxy

Editing the Configuration File

Use a text editor to open the newly created file –

nano ~/.bashrc_proxy

Add the following lines to the file, replacing “proxy_ip” and “proxy_port” with the appropriate values –

export http_proxy="http://proxy_ip:proxy_port"
export https_proxy="http://proxy_ip:proxy_port"

Save and exit the file.

Applying the Proxy Settings

To apply the proxy settings, execute the following command in the terminal –

source ~/.bashrc_proxy

The proxy settings will take effect immediately.

Proxy with Ubuntu Desktop GUI

Accessing Network Settings

In Ubuntu Desktop, you can set up a proxy through the graphical user interface (GUI). Click on the “Settings” icon in the top-right corner of the screen, then select “Network Settings.”

Proxy Configuration

Within the Network settings, click on the “Proxy” tab. Enable the “Manual” option and enter the proxy server details in the corresponding fields. Ensure to specify the proxy IP address and port number correctly.

Applying the Changes

Once you have entered the proxy information, click “Apply” to save the settings. The system will now use the configured proxy for internet connections.

Terminal Setting Up Proxy

Proxy Environment Variables

You can set up a proxy in the terminal by defining environment variables. Open a terminal and execute the following commands, replacing “proxy_ip” and “proxy_port” with your proxy server details –

export http_proxy="http://proxy_ip:proxy_port"
export https_proxy="http://proxy_ip:proxy_port"

Verifying Proxy Settings

To verify that the proxy settings are applied, you can use the “env” command in the terminal –

env | grep -i proxy

This command will display the environment variables related to the proxy, confirming the configuration.

Conclusion

Configuring a proxy in Linux provides various benefits, including enhanced privacy, security, and control over network connections. In this article, we explored different methods to set up a proxy in Linux.

We covered the command-line approach using Proxychains, permanent proxy settings through configuration files, and graphical methods using the Ubuntu Desktop GUI. By following these step-by-step instructions, you can easily set up a proxy in Linux and protect your privacy online.

Linux TutorialsUncategorized