Chinaunix首页 | 论坛 | 博客
  • 博客访问: 370298
  • 博文数量: 66
  • 博客积分: 3201
  • 博客等级: 中校
  • 技术积分: 695
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-04 11:17
文章分类

全部博文(66)

文章存档

2016年(1)

2014年(1)

2012年(1)

2011年(2)

2010年(18)

2009年(42)

2008年(1)

分类: LINUX

2010-08-23 14:05:19

我个人用的要求是:
1.和主机无障碍通信;
2.和internet通信;
3.和主机的一些服务通信,如tor的SOCK V5;
4.固定ip,不要老是换来换去。


一开始一直是用NAT方式,然后DHCP获得IP,一切ok,但是偶尔开启它的虚拟机,它们就会抢IP了,造成我很多虚拟机里的服务要改IP地址,而且每次ssh登录都变,很麻烦。

后来朋友建议用host-only,然后主机开共享连接到internet,这个满足1、2、4,但只支持TCP,UDP服务共享,如tor就不行了。

最后发现其实只要去掉NAT的DHCP,然后让虚拟机用静态IP就好了。方法如下:


1.那个“Use local DHCP...”可以去掉了,不去也不碍事,不过我们虚拟机要设置static ip。
2.在/etc/network/interfaces里写入如下:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#
#dhcp
#auto eth0
#iface eth0 inet dhcp
#allow-hotplug eth0
#
#
#static
auto eth0
iface eth0 inet static
address 192.168.100.3
netmask 255.255.255.0
gateway 192.168.100.2


3.然后给加上DNS,在/etc/resolv.conf
nameserver 192.168.100.2 【192.168.100.2是网关地址】
4.注意以后连接主机是192.168.100.1,而网管是.2.
5.注意连接主机的Xmanager X Passive,用的是
export DISPLAY=192.168.100.1:0.0

6.tsocks配置,用的是192.168.100.2,可以先telnet 192.168.100.2 9050看通不通就好了。

# This is the configuration for libtsocks (transparent socks)
# Lines beginning with # and blank lines are ignored
#
# The basic idea is to specify:
# - Local subnets - Networks that can be accessed directly without
# assistance from a socks server
# - Paths - Paths are basically lists of networks and a socks server
# which can be used to reach these networks
# - Default server - A socks server which should be used to access
# networks for which no path is available
# Much more documentation than provided in these comments can be found in
# the man pages, tsocks(8) and tsocks.conf(8)

# Local networks
# For this example this machine can directly access 192.168.0.0/255.255.255.0
# (192.168.0.*) and 10.0.0.0/255.0.0.0 (10.*)

local = 192.168.0.0/255.255.255.0
local = 10.0.0.0/255.0.0.0
local = 127.0.0.0/255.0.0.0
local = 192.168.100.0/255.255.255.0

# Paths
# For this example this machine needs to access 150.0.0.0/255.255.0.0 as
# well as port 80 on the network 150.1.0.0/255.255.0.0 through
# the socks 5 server at 10.1.7.25 (if this machines hostname was
# "socks.hello.com" we could also specify that, unless --disable-hostnames
# was specified to ./configure).

path {
        reaches = 150.0.0.0/255.255.0.0
        reaches = 150.1.0.0:80/255.255.0.0
        server = 10.1.7.25
        server_type = 5
        default_user = delius
        default_pass = hello
}

# Default server
# For connections that aren't to the local subnets or to 150.0.0.0/255.255.0.0
# the server at 192.168.0.1 should be used (again, hostnames could be used
# too, see note above)

server = 192.168.100.2
# Server type defaults to 4 so we need to specify it as 5 for this one
server_type = 5
# The port defaults to 1080 but I'
ve stated it here for clarity
server_port = 9050


阅读(714) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-08-25 15:28:52

Download More than 1000 free IT eBooks: http://free-ebooks.appspot.com