时间:2023-06-28 18:27:01 | 来源:网站运营
时间:2023-06-28 18:27:01 来源:网站运营
Ubuntu虚拟机网络配置:sudo apt-get remove vim-commonsudo apt-get updatesudo apt-get upgradesudo apt-get install vim
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设置为yes,BOOTPROTO设置为static,由于网关为192.168.52.2,所以这台虚拟机的ip可以设置为192.168.52.*,在此,我们设置为 service network restart
此时可以通过ping网关来测试是否配置成功ping 192.168.52.2
为了连接外网,我们还要配置dns服务cd ./networklssudo vim interfaces
在里面写入nameserver 114.114.114.114
保存后,执行以下命令sudo service network-manager restartping www.baidu.com
按crtl+c键停止ping,然后重启linux虚拟机。gzip -d clash-linux-amd64-v1.6.0.gz
再在文件管理器里选择解压得到的文件clash-linux-amd64-v1.6.0,鼠标点击右键,选择重命名,将文件clash-linux-amd64-v1.6.0重命名为clash。/usr/bin/
目录:mv clash /usr/bin/
赋予文件 clash 可执行权限: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
默认配置目录是 ~/.config/clash
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
服务cd /lib/systemd/systemsudo vim clash.service
向clash.service文件中写入以下内容:[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
文件复制到~/.config/clash/
~/.config/clash
并再复制到/etc/clash
(若没有该文件夹就先mkdir创建一个)中cd ~/.config/clash/cp config.yaml /etc/clash/cp Country.mmdb /etc/clash/
然后通过浏览器访问 http://clash.razord.top 进行策略组设置。service network-manager restart
至此重新启动本软件执行:service clash restart
至此虚拟机网络配置成功。关键词:配置,网络,虚拟