2012年3月4日 星期日

ciLinux 網路設定

可以  reference: http://colinux.wikia.com/wiki/Network

CoLinux的网络配置

昨天的说到配置CoLinux在Windows下面启动另一个分区里面的Linux,但是网络配置只是使用了最简单的slirp模式。
CoLinux的网络配置共有3种:
  • slirp:最简单的模式,CoLinux内可通过Windows系统访问网络,但外部不能直接访问Linux,如果需要访问,需要做端口映射。
  • tuntap:在Windows中虚拟一块网卡,Linux与Windows通过该网卡通讯,Linux不能直接访问外部网络,必须在Windows上配置路由和NAT,或者简单使用Windows的Internet连接共享ICS。
  • pcap-bridge:必须有一块连接网络的网卡才能使用,另外需要安装WinPCap软件。该模式将一块实际网卡模拟出另一块网卡并连接到网络,对外部看来,就好像实际上有两台不同机器一样。
  • ndis-bridge:与pcap-bridge模式一样,不过不使用WinPCap软件接口而是通过Windows的NDIS接口层模拟网卡。
下面是配置方式:
  • slirp模式
slirp模式的配置最简单,在CoLinux的配置里面:
eth0=slirp
就可以了。它的具体参数如下:
ethX=slirp,,
可以用来指定网卡MAC地址,也可以直接留空
用来指定端口映射,格式为tcp|upd:hostport:linuxport[:count],将Windows的tcp或者udp的hostport开始的count个端口映射到Linux系统的linuxport开始的count个端口上,如果要添加多个映射,用逗号分隔。如
eth0=slirp,,tcp:2222:22/tcp:4000:80:3
将Windows的端口2222,4000,4001,4002映射到Linux的端口22,80,81,82上。
  • tuntap模式
这个模式比较麻烦,实际上是虚拟了一块网卡和CoLinux相连,所以,Windows和Linux可以直接连接,但是Linux想要访问外网,则需要配置网关或者ICS。
配置参数:
ethX=tuntap,,
是MAC地址,可以不填
是使用Tuntap网卡名字,也可以不填,这样CoLinux会使用第一块Tuntap网卡。
但是tuntap网卡是可以安装多块的,如果需要指定某块具体的虚拟网卡,则需要指定这个名字。
正常安装CoLinux以后,Windows里面会多出来一块网卡,嗯,名字叫什么忘记了:)
进入Windows网上邻居属性界面,查看网络连接就可以看到这块网卡。在这里可以对网卡改名,比如我改成了“Tap-colinux”,然后在参数里面指定这个名字就可以使用这块虚拟网卡。
如果名字里面有空格,则必须使用双引号"括起来。
  • pcap-bridge和ndis-bridge模式
这两个模式实际上是差不多的,除了pcap需要WinPCap软件支持以外,事实上应该ndis模式会快一点?(猜的,没测试过)
这两个模式是先有的pcap,后来才加上了ndis模式,毕竟不需要额外装个软件还是比较容易接受一点的。
具体配置参数:
ethX=pcap-bridge|ndis-bridge,,,
指定要在哪一块真实网卡上模拟虚拟网卡,这个名字也就是在Windows网上邻居属性界面里,查看网络连接时看到的名字(在那里也可以改名的),这个名字不能省略,否则网络跑不起来的。
而且需要注意的是,这块网卡必须要连通网络,否则的话,这个两个模式都不能用。
最后需要注意的是,在一些无线网卡上,这两个模式无法运作。具体原因好像是网卡只接受发到真实网卡的包,其他包直接不要还是怎么的,总之是不能使。(顺便说一句,我的无线网卡就不行,哭啊)
还是MAC地址,可省略。
指定是否工作在sniffer模式下,如果是promisc模式,则能够收到不是发到这块虚拟网卡的网络包,也就可以使用一些sniffer软件了。而nopromisc模式则正好相反,不能使用sniffer软件。

  • 好了,现在说说我怎么配的吧。
昨天的配置文件里面使用的是slirp模式,并且将2222映射到22端口。
然后我先试了下ndis-bridge模式,可惜的怎么都不行,我的无线网卡恐怕是不能支持这种模式了。
最后还是使用tuntap模式:
eth0=tuntap,,02:00:00:00:00:02
然后,去无线网卡属性里面,“共享”页面,打开ICS,指定对Tap-colinux网卡共享网络,这样就可以了。

  • 最后,再点题外话。
这里没有说在Linux下面怎么设置网络,其实就和普通网卡一样设置就好了。
我没有做什么特别的设置,Debian起来以后,自己认出网卡,然后dhcp获得IP,一切就好了。
slirp模式下CoLinux会负责分配ip的,tuntap模式下,ICS也会分配。
如果使用ndis或者pcap模式,它实际上就相当于是另一台机器上的一块网卡一样,家里的无线?路由器自然会负责给它分配IP的。

=========================================
Choose networking method(s) to install. Currently there are three choices:
  1.  Slirp - The simplest way to use networks in coLinux. 
    • This runs as user application on the Windows host and needs no changes on the host networks. 
    • Slirp is a good choice for dialup networks and WLAN cards.
    • Slirp use all times the current outgoing interface and forwards (NAT) networking from linux to the internet world.  Slirp is a virtual Gateway for all outgoing TCP and UDP connections (no IMCP, no ping).
    • Standard installation works as firewall to your linux.  It means, you can not connect from windows side to your linux.  To allow incomings from host system to linux, must additional configure 'redirections'.
    • Slirp has a DHCP-Server for linux side.  To use slirp, edit your CFG file and set "slirp" as first parameter.  Inside linux use DHCP-Client to get your network configuration.
  2. TAP driver - This method installs a virtual network adapter that is typically a separate network between Linux guest and Windows host.
    • This can then be either shared or bridged with a physical network connection. 
      • Note that this requires Internet Connection Sharing or Bridging (Windows XP or higher) or a 3rd party Internet connection sharing application.
    • The TAP method autmatically chooses the TAP first TAP adapter it finds, if you have multiple TAP WIN32 devices, you can specify the specific adapter by name (for sample "TAP-Colinux").
  3. Bridging - This method allows the Cooperative Linux network interface to directly interoperate with one of your built in networking interfaces.
    • You'll need to edit the configuration file to reflect that type "ndis-bridge" and the 'name' parameter needs to be set to a substring of the network connection name that you will be bridging with (e.g. "Local Area Connection").
    • Bridging does not working with WiFi cards.

沒有留言: