Ubuntu區域網路中設定Proxy 伺服器上網和設定靜態IP

來源:互聯網
上載者:User

1.使用Proxy 伺服器上網

我們想要使用機器A通過機器B上網,可以使用如下方法: 1.首先確保機器B可以上網。

2.在機器B上安裝squid軟體,$sudo apt-get install squid,安裝完成後在網上down一個squid設定檔squid.conf,然後覆蓋到/etc/squid/下的同名檔案

3.在機器B器上測試代理程式伺服器,$sudo service squid start 如果看見squid start/running,process 1726(進程號會不同)字樣,再執行sudo service squid stop,看到squid stop/waiting字樣就再執行$sudo service squid start,$sudo service squid restart.如果2次都看到了squid start/running,process 1726字樣就說明基本上OK了。

4.然後在機器A上設定網路代理程式,將原來的代理改為你機器B的ip地址,連接埠號碼改為3128即可。ip地址可用$ifconfig查看。

5.在機器A上開一個網頁,如果打不開那麼就把squid刪了再重裝。$sudo apt-get autoremove squid

PS:開機後不需要輸入密碼就可以啟動Proxy 伺服器。

2.設定靜態IP

Ubuntu的網路設定資訊是儲存在 /etc/network/interfaces 檔案中,使用Vim開啟設定檔,預設是自動擷取IP的配置.如下:

# The primary network interface

auto lo

iface lo inet loopback

下面我們將其設定成靜態IP.

第一步:屏蔽掉自動擷取IP的設定

auto lo將這一行屏蔽掉

iface lo inet loopback將這一行屏蔽掉

修改之後的內容如下:

# The primary network interface

#auto lo

auto eth0

#iface eth0 inet dhcp

第二步:添加靜態IP的資訊

# The primary network interface

iface eth0 inet static

address 45.111.38.58

netmask 255.255.255.0

gateway 45.111.38.254

PS:這裡的address要求不能是已指派給其他人的IP地址。

重啟網路:sudo /etc/init.d/networking restart

以上步驟完成之後只要重新啟用一下網路就OK了.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.