1.使用代理服務器上網
我們想要使用機器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:開機後不需要輸入密碼就可以啟動代理服務器。
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了.