Linux內(nèi)網(wǎng)機(jī)器部署代理訪問外網(wǎng),yum安裝gcc

一般出于安全考慮批狱,服務(wù)器組都是只有一臺(tái)服務(wù)器能訪問外網(wǎng)裸准,其他都是以內(nèi)網(wǎng)的形式連接。
如果我們要給內(nèi)網(wǎng)的機(jī)器安裝東西這時(shí)候由于無法訪問到外網(wǎng)而導(dǎo)致失敗赔硫。這時(shí)候我們就需要把能訪問外網(wǎng)的機(jī)器部署成代理服務(wù)器狼速。
本文參考

一 安裝部署squid

  1. yum install squid
  2. cd /etc/squid/
  3. 備份文件 cp squid.conf squid.conf_bak 備份文件
  4. 修改 把http_access deny all修改為http_access allow all
#
# Recommended minimum configuration:
#

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8     # RFC1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7       # RFC 4193 local private network range
acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines

acl SSL_ports port 443
acl Safe_ports port 80          # http
acl Safe_ports port 21          # ftp
acl Safe_ports port 443         # https
acl Safe_ports port 70          # gopher
acl Safe_ports port 210         # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280         # http-mgmt
acl Safe_ports port 488         # gss-http
acl Safe_ports port 591         # filemaker
acl Safe_ports port 777         # multiling http
acl CONNECT method CONNECT

#
# Recommended minimum Access Permission configuration:
#
# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost

# And finally deny all other access to this proxy
#這里把 http_access deny all  修改為 http_access allow all
http_access allow all 

# Squid normally listens to port 3128
http_port 3128

# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /var/spool/squid 100 16 256

# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

#
# Add any of your own refresh_pattern entries above these.
#
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
refresh_pattern .               0       20%     4320
  1. 啟動(dòng)squid
squid -k parse
squid -z
service squid start
  1. 查看squid服務(wù)
netstat -tupln | grep squid
  1. 查看本機(jī)地址
    ifconfig
enp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.3  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::b26e:bfff:fe3a:cf79  prefixlen 64  scopeid 0x20<link>
        ether b0:6e:bf:3a:cf:79  txqueuelen 1000  (Ethernet)
        RX packets 488347862  bytes 124793189132 (116.2 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 582737341  bytes 76537064191 (71.2 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xfa200000-fa27ffff  

本地內(nèi)網(wǎng)地址是 192.168.100.3

二 配置內(nèi)網(wǎng)機(jī)器

  1. 配置臨時(shí)代理地址(重新登錄失效)
export http_proxy="http://192.168.100.3:3128"
  1. 配置yum代理地址
vi /etc/yum.conf

增加 proxy=http://192.168.100.3:3128

[main]
#配置yum的代理地址。
proxy=http://192.168.100.3:3128
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release


#  This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
#  It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

下面我們就能愉快的安裝各種軟件啦卦停。向胡。。

yum install gcc
yum install cmake
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末惊完,一起剝皮案震驚了整個(gè)濱河市僵芹,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌小槐,老刑警劉巖拇派,帶你破解...
    沈念sama閱讀 218,036評(píng)論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異凿跳,居然都是意外死亡件豌,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,046評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門控嗜,熙熙樓的掌柜王于貴愁眉苦臉地迎上來茧彤,“玉大人,你說我怎么就攤上這事疆栏≡啵” “怎么了?”我有些...
    開封第一講書人閱讀 164,411評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵壁顶,是天一觀的道長珠洗。 經(jīng)常有香客問我,道長若专,這世上最難降的妖魔是什么许蓖? 我笑而不...
    開封第一講書人閱讀 58,622評(píng)論 1 293
  • 正文 為了忘掉前任,我火速辦了婚禮调衰,結(jié)果婚禮上膊爪,老公的妹妹穿的比我還像新娘。我一直安慰自己窖式,他們只是感情好蚁飒,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,661評(píng)論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著萝喘,像睡著了一般淮逻。 火紅的嫁衣襯著肌膚如雪琼懊。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,521評(píng)論 1 304
  • 那天爬早,我揣著相機(jī)與錄音哼丈,去河邊找鬼。 笑死筛严,一個(gè)胖子當(dāng)著我的面吹牛醉旦,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播桨啃,決...
    沈念sama閱讀 40,288評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼车胡,長吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來了照瘾?” 一聲冷哼從身側(cè)響起匈棘,我...
    開封第一講書人閱讀 39,200評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎析命,沒想到半個(gè)月后主卫,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,644評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡鹃愤,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,837評(píng)論 3 336
  • 正文 我和宋清朗相戀三年簇搅,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片软吐。...
    茶點(diǎn)故事閱讀 39,953評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡瘩将,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出关噪,到底是詐尸還是另有隱情鸟蟹,我是刑警寧澤,帶...
    沈念sama閱讀 35,673評(píng)論 5 346
  • 正文 年R本政府宣布使兔,位于F島的核電站,受9級(jí)特大地震影響藤韵,放射性物質(zhì)發(fā)生泄漏虐沥。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,281評(píng)論 3 329
  • 文/蒙蒙 一泽艘、第九天 我趴在偏房一處隱蔽的房頂上張望欲险。 院中可真熱鬧,春花似錦匹涮、人聲如沸天试。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,889評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽喜每。三九已至务唐,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間带兜,已是汗流浹背枫笛。 一陣腳步聲響...
    開封第一講書人閱讀 33,011評(píng)論 1 269
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留刚照,地道東北人刑巧。 一個(gè)月前我還...
    沈念sama閱讀 48,119評(píng)論 3 370
  • 正文 我出身青樓,卻偏偏與公主長得像无畔,于是被迫代替她去往敵國和親啊楚。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,901評(píng)論 2 355