Ubuntu虚拟机通过主机SS上网

来源:互联网 发布:淘宝团购美食 编辑:程序博客网 时间:2024/05/22 02:31

若虚拟机有图形界面,参照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_proxyexport http_proxyexport https_proxyexport no_proxy
  • 配置静态ip(dhcp有可能无法分配到ip)
# vim /etc/network/interfacesauto eth0iface eth0 inet staticaddress 192.168.1.200netmask 255.255.255.0gateway 192.168.1.1
  • 参照CodingStory的博客,把虚拟机网络连接方式改为“桥接模式”,并把默认的“自动桥接”,改为针对某一网卡的桥接。

  • 重启即可

原创粉丝点击