Tuesday, February 6, 2024

FreeBSD: Setting up Internet access via a proxy

Before making the settings, find out which shell is used in your Freebsd OS using the
echo "$SHELL" command.

To configure a proxy in the csh command shell (in earlier versions of the OS), follow these steps:

1. Edit the file "/.cshrc" or "/home/%username%/.cshrc" (where %username% is the user name) using the "ee" utility, adding the following lines:

setenv HTTP_PROXY login:pass@server:port
setenv FTP_PROXY login:pass@server:port
setenv http_proxy login:pass@server:port
setenv ftp_proxy login:pass@server:port

login - username for authorization on the proxy;
pass - password for authorization on the proxy;
server - FQDN or IP of the proxy server;
port - proxy server port.

If there is no authentication, the login and password can be omitted.

2. Next, add the lines to the file "/etc/make.conf":

FETCH_ENV=HTTP_PROXY=http://login:pass@server:port FETCH_ENV=FTP_PROXY=http://login:pass@server:port FETCH_ENV=http_proxy=http://login:pass@server:port FETCH_ENV=ftp_proxy=http://login:pass@server:port

If the file is missing, create it.

_______________________________________________________________________________


To configure a proxy in the sh command shell (latest OS versions):

Add the following lines to the end of the "/etc/profile" file:

export HTTP_PROXY=http://login:pass@server:port
export FTP_PROXY=http://login:pass@server:port
export http_proxy=http://login:pass@server:port
export ftp_proxy=http://login:pass@server:port


login - username for authorization on the proxy;
pass - password for authorization on the proxy;
server - FQDN or IP of the proxy server;
port - proxy server port.

If there is no authentication, the login and password can be omitted.

_______________________________________________________________________________


To apply the settings, restart the server or run: "service netif restart"
Then:
- with static IP: "service routing restart";
- with dynamic IP: "service dhclient restart em0" (where "em0" is your network interface, you can find out by running "ifconfig". This command is necessary if the IP address is distributed by a DHCP server).



No comments:

Post a Comment