Ubuntu虚拟机通过主机SS上网

版权声明:辛辛苦苦写的,转载时给个链接嘛! https://blog.csdn.net/Bleachswh/article/details/78079412

若虚拟机有图形界面,参照CodingStory的此篇博客。否则,如下:

  • 假设: 主机ip为192.168.1.100,网关192.168.1.1,本地开启的SS端口为1080。
  • 虚拟机中,在全局配置文件/etc/profile中配置代理主机的信息
# vim /etc/profile 
在文件末尾追加如下内容
ftp_proxy="http://192.168.1.100:1080"    
http_proxy="http://192.168.1.100:1080"
https_proxy="http://192.168.1.100:1080"
no_proxy="localhost,127.0.0.1,192.168.1.0/24"
export ftp_proxy
export http_proxy
export https_proxy
export no_proxy
  • 配置静态ip(dhcp有可能无法分配到ip)
# vim /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.1.200
netmask 255.255.255.0
gateway 192.168.1.1
  • 参照CodingStory的博客,把虚拟机网络连接方式改为“桥接模式”,并把默认的“自动桥接”,改为针对某一网卡的桥接。

  • 重启即可

猜你喜欢

转载自blog.csdn.net/Bleachswh/article/details/78079412