sudo apt-get remove vim-commonsudo apt-get updatesudo apt-get upgradesudo apt-get install vim


有關(guān)VM配置連接主機(jī)網(wǎng)絡(luò),主要參考了以" />

国产成人精品无码青草_亚洲国产美女精品久久久久∴_欧美人与鲁交大毛片免费_国产果冻豆传媒麻婆精东

15158846557 在線咨詢 在線咨詢
15158846557 在線咨詢
所在位置: 首頁 > 營銷資訊 > 網(wǎng)站運(yùn)營 > Ubuntu虛擬機(jī)網(wǎng)絡(luò)配置

Ubuntu虛擬機(jī)網(wǎng)絡(luò)配置

時(shí)間:2023-06-28 18:27:01 | 來源:網(wǎng)站運(yùn)營

時(shí)間:2023-06-28 18:27:01 來源:網(wǎng)站運(yùn)營

Ubuntu虛擬機(jī)網(wǎng)絡(luò)配置:先學(xué)習(xí)vim 和 Ubuntu命令的一些基礎(chǔ)知識(shí)。

sudo apt-get remove vim-commonsudo apt-get updatesudo apt-get upgradesudo apt-get install vim



首先虛擬機(jī)的網(wǎng)絡(luò)鏈接模式選為NAT模式

查看宿主機(jī)下dhcp,net服務(wù)是否正常啟動(dòng)




查看vmware為虛擬機(jī)統(tǒng)一提供的網(wǎng)關(guān),這樣我們?cè)诤罄m(xù)配置虛擬機(jī)ip時(shí),保證ip和網(wǎng)關(guān)在同一網(wǎng)段下:
點(diǎn)擊編輯–虛擬機(jī)網(wǎng)絡(luò)編輯器:




若想要修改這個(gè)配置,需要以管理員身份點(diǎn)擊下面的更改設(shè)置:

接著進(jìn)行后續(xù)操作,選中VMnet8 ,點(diǎn)擊NAT設(shè)置:

此時(shí)我知道我的網(wǎng)關(guān)為192.168.52.2。

在linux虛擬機(jī)中打開eth0對(duì)應(yīng)網(wǎng)絡(luò)接口配置文件,修改配置:

cd /etcsudo mkdir sysconfigcd sysconfigsudo mkdir network-scriptscd network-scriptssudo vi ./ifcfg-eth0配置信息如下:

ONBOOT=yesNM_CONTROLLED=yesBOOTPROTO=staticIPADDR=192.168.52.12NETMASK=255.255.255.0GATEWAY=192.168.52.2將其中ONBOOT設(shè)置為yes,BOOTPROTO設(shè)置為static,由于網(wǎng)關(guān)為192.168.52.2,所以這臺(tái)虛擬機(jī)的ip可以設(shè)置為192.168.52.*,在此,我們?cè)O(shè)置為
192.168.52.12,子網(wǎng)掩碼NETMASK=255.255.255.0,網(wǎng)關(guān)就是之前我們查看的網(wǎng)關(guān)地址:GATEWAY=192.168.52.2;

在此,我們要對(duì)這個(gè)接口配置文件做個(gè)介紹:
文件 /etc/sysconfig/network-scripts/ifcfg-eth0在/etc/sysconfig/network-script在這個(gè)目錄下面,存放的是網(wǎng)絡(luò)接口(網(wǎng)卡)的腳本文件(控制文件),ifcfg-eth0是默認(rèn)的第一個(gè)網(wǎng)絡(luò)接口,如果機(jī)器中有多網(wǎng)絡(luò)接口,那么名字就將依此類推ifcfg-eth1,ifcfg-eth2,ifcfg-eth3……(這里面的文件是相當(dāng)重要的,涉及到網(wǎng)絡(luò)能否正常工作)。

設(shè)置完接口文件保存后,我們要重啟網(wǎng)絡(luò)服務(wù),使配置文件生效

service network restart此時(shí)可以通過ping網(wǎng)關(guān)來測(cè)試是否配置成功

ping 192.168.52.2為了連接外網(wǎng),我們還要配置dns服務(wù)

cd ./networklssudo vim interfaces在里面寫入

nameserver 114.114.114.114保存后,執(zhí)行以下命令

sudo service network-manager restartping www.baidu.com按crtl+c鍵停止ping,然后重啟linux虛擬機(jī)。


下載文件

我是從這個(gè)鏈接下載的clash-linux-amd64-v1.6.0.gz(根據(jù)你的Linux版本選擇合適的版本),將目錄切換到下載的clash-linux-amd64-v1.6.0.gz所在的目錄,執(zhí)行以下命令:

gzip -d clash-linux-amd64-v1.6.0.gz再在文件管理器里選擇解壓得到的文件clash-linux-amd64-v1.6.0,鼠標(biāo)點(diǎn)擊右鍵,選擇重命名,將文件clash-linux-amd64-v1.6.0重命名為clash。

移動(dòng)到/usr/bin/目錄:

mv clash /usr/bin/賦予文件 clash 可執(zhí)行權(quán)限:

sudo chmod +x /usr/bin/clash檢查 clash 是否安裝成功

clash -v返回以下消息說明安裝成功:

Clash v1.6.0 linux amd64 with go1.16.3 Sat May 8 11:30:49 UTC 2021默認(rèn)配置目錄是 ~/.config/clash

配置文件的名稱是 config.yml 或者config.ymal

# port of HTTPport: 7890# port of SOCKS5socks-port: 7891# redir port for Linux and macOS# redir-port: 7892allow-lan: false# Rule / Global/ Direct (default is Rule)mode: Rule# set log level to stdout (default is info)# info / warning / error / debug / silentlog-level: info# A RESTful API for clashexternal-controller: 127.0.0.1:9090# you can put the static web resource (such as clash-dashboard) to a directory, and clash would serve in `${API}/ui`# input is a relative path to the configuration directory or an absolute path# external-ui: folder# Secret for RESTful API (Optional)# secret: ""# dns: # enable: true # set true to enable dns (default is false) # ipv6: false # default is false # listen: 0.0.0.0:53 # enhanced-mode: redir-host # nameserver: # - 114.114.114.114 # - tls://dns.rubyfish.cn:853 # dns over tls # fallback: # concurrent request with nameserver, fallback used when GEOIP country isn't CN # - tcp://1.1.1.1Proxy:# shadowsocks# The types of cipher are consistent with go-shadowsocks2# support AEAD_AES_128_GCM AEAD_AES_192_GCM AEAD_AES_256_GCM AEAD_CHACHA20_POLY1305 AES-128-CTR AES-192-CTR AES-256-CTR AES-128-CFB AES-192-CFB AES-256-CFB CHACHA20-IETF XCHACHA20# In addition to what go-shadowsocks2 supports, it also supports chacha20 rc4-md5 xchacha20-ietf-poly1305- { name: "ss1", type: ss, server: server, port: 443, cipher: AEAD_CHACHA20_POLY1305, password: "password" }# old obfs configuration remove after prerelease- name: "ss2" type: ss server: server port: 443 cipher: AEAD_CHACHA20_POLY1305 password: "password" plugin: obfs plugin-opts: mode: tls # or http # host: bing.com- name: "ss3" type: ss server: server port: 443 cipher: AEAD_CHACHA20_POLY1305 password: "password" plugin: v2ray-plugin plugin-opts: mode: websocket # no QUIC now # tls: true # wss # skip-cert-verify: true # host: bing.com # path: "/" # headers: # custom: value# vmess# cipher support auto/aes-128-gcm/chacha20-poly1305/none- { name: "vmess", type: vmess, server: server, port: 443, uuid: uuid, alterId: 32, cipher: auto }# with tls- { name: "vmess", type: vmess, server: server, port: 443, uuid: uuid, alterId: 32, cipher: auto, tls: true }# with tls and skip-cert-verify- { name: "vmess", type: vmess, server: server, port: 443, uuid: uuid, alterId: 32, cipher: auto, tls: true, skip-cert-verify: true }# with ws-path and ws-headers- { name: "vmess", type: vmess, server: server, port: 443, uuid: uuid, alterId: 32, cipher: auto, network: ws, ws-path: /path, ws-headers: { Host: v2ray.com } }# with ws + tls- { name: "vmess", type: vmess, server: server, port: 443, uuid: uuid, alterId: 32, cipher: auto, network: ws, ws-path: /path, tls: true }# socks5- { name: "socks", type: socks5, server: server, port: 443 }# socks5 with authentication- { name: "socks", type: socks5, server: server, port: 443, username: "username", password: "password" }# with tls- { name: "socks", type: socks5, server: server, port: 443, tls: true }# with tls and skip-cert-verify- { name: "socks", type: socks5, server: server, port: 443, tls: true, skip-cert-verify: true }# http- { name: "http", type: http, server: server, port: 443 }# http with authentication- { name: "http", type: http, server: server, port: 443, username: "username", password: "password" }# with tls (https)- { name: "http", type: http, server: server, port: 443, tls: true }# with tls (https) and skip-cert-verify- { name: "http", type: http, server: server, port: 443, tls: true, skip-cert-verify: true }Proxy Group:# url-test select which proxy will be used by benchmarking speed to a URL.- { name: "auto", type: url-test, proxies: ["ss1", "ss2", "vmess1"], url: "http://www.gstatic.com/generate_204", interval: 300 }# fallback select an available policy by priority. The availability is tested by accessing an URL, just like an auto url-test group.- { name: "fallback-auto", type: fallback, proxies: ["ss1", "ss2", "vmess1"], url: "http://www.gstatic.com/generate_204", interval: 300 }# load-balance: The request of the same eTLD will be dial on the same proxy.- { name: "load-balance", type: load-balance, proxies: ["ss1", "ss2", "vmess1"], url: "http://www.gstatic.com/generate_204", interval: 300 }# select is used for selecting proxy or proxy group# you can use RESTful API to switch proxy, is recommended for use in GUI.- { name: "Proxy", type: select, proxies: ["ss1", "ss2", "vmess1", "auto"] }Rule:- DOMAIN-SUFFIX,google.com,auto- DOMAIN-KEYWORD,google,auto- DOMAIN,google.com,auto- DOMAIN-SUFFIX,ad.com,REJECT- IP-CIDR,127.0.0.0/8,DIRECT- SOURCE-IP-CIDR,192.168.1.201/32,DIRECT- GEOIP,CN,DIRECT# FINAL would remove after prerelease# you also can use `FINAL,Proxy` or `FINAL,,Proxy` now- MATCH,auto

配置clash.service服務(wù)

先按如下命令創(chuàng)建clash.service文件:

cd /lib/systemd/systemsudo vim clash.service向clash.service文件中寫入以下內(nèi)容:

[Unit]Description=clashAfter=network-online.targetWants=network-online.target systemd-networkd-wait-online.service[Service]Type=simpleUser=rootGroup=rootDynamicUser=trueExecStart=/usr/bin/clash -d /etc/clash/Restart=alwaysLimitNOFILE=512000[Install]WantedBy=multi-user.target
下載YAML文件并重新命名
得到Clash的訂閱鏈接,并重命名為config.yaml文件。一定要是config名字。

將下載完成的config.yaml文件(如果是config.yal文件,直接重命名為config.yaml就行了)和 Country.mmdb文件復(fù)制到~/.config/clash/

進(jìn)入~/.config/clash并再復(fù)制到/etc/clash(若沒有該文件夾就先mkdir創(chuàng)建一個(gè))中

cd ~/.config/clash/cp config.yaml /etc/clash/cp Country.mmdb /etc/clash/然后通過瀏覽器訪問 http://clash.razord.top 進(jìn)行策略組設(shè)置。

隨后系統(tǒng)設(shè)置,網(wǎng)絡(luò)設(shè)置中添加http代理,IP 127.0.0.1 端口 7890 socks代理,IP 127.0.0.1 端口 7891。

至此重新啟動(dòng)網(wǎng)絡(luò):

service network-manager restart至此重新啟動(dòng)本軟件執(zhí)行:

service clash restart至此虛擬機(jī)網(wǎng)絡(luò)配置成功。

關(guān)鍵詞:配置,網(wǎng)絡(luò),虛擬

74
73
25
news

版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。

為了最佳展示效果,本站不支持IE9及以下版本的瀏覽器,建議您使用谷歌Chrome瀏覽器。 點(diǎn)擊下載Chrome瀏覽器
關(guān)閉