MAC OSX dynamips bundle Loopback Port

在09年我总结过在linux上如何建立tap口,并连接dynampis,传送到《Linux Ubuntu dynamips bundle Loopback Port》,现在工作平台转到MAC上了,MAC如何绑定tap口呢?

x-mac:dev yong$ ls /dev/tap*
/dev/tap0	/dev/tap11	/dev/tap14	/dev/tap3	/dev/tap6	/dev/tap9
/dev/tap1	/dev/tap12	/dev/tap15	/dev/tap4	/dev/tap7
/dev/tap10	/dev/tap13	/dev/tap2	/dev/tap5	/dev/tap8


x-mac:dev yong$ sudo ifconfig tap0 netmask
ifconfig: interface tap0 does not exist


    [[router R4]]
    f2/0 = NIO_tap:/dev/tap0


x-mac:dev yong$ sudo ifconfig tap0 netmask
x-mac:dev yong$ ifconfig tap0
tap0: flags=8843<up,broadcast,running,simplex,multicast> mtu 1500
	ether fe:7c:3a:31:48:c2 
	inet netmask 0xffffff00 broadcast
	open (pid 35722)
x-mac:dev yong$ ping
PING ( 56 data bytes
64 bytes from icmp_seq=0 ttl=255 time=0.962 ms
64 bytes from icmp_seq=1 ttl=255 time=2.880 ms
64 bytes from icmp_seq=2 ttl=255 time=2.388 ms
64 bytes from icmp_seq=3 ttl=255 time=0.798 ms
--- ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.798/1.757/2.880/0.896 ms

首先选择Preferences -> 网络 -> 添加,如图所示:
然后通过命令把新建的vmnet和tap0桥接起来,由于MAC版的vmware Fusion没有这方面的GUI(没windows强大),所以只能通过命令行,不过很简单:

x-mac:dev yong$ sudo ifconfig bridge0 create
x-mac:dev yong$ sudo ifconfig bridge0 addm vmnet4
x-mac:dev yong$ sudo ifconfig bridge0 addm tap0
x-mac:dev yong$ sudo ifconfig bridge0 up


x-mac:dev yong$ sudo route -nv add -net
u: inet; u: inet; RTM_ADD: Add Route: len 132, pid: 0, seq 1, errno 0, flags:<up,gateway,static>
locks:  inits: 
sockaddrs: <dst,gateway,netmask> (0) 0 ffff ff
add net gateway
x-mac:dev yong$ netstat -rn | egrep 'Use|10.1.1'
Destination        Gateway            Flags        Refs      Use   Netif Expire
10.1.1/24       UGSc            0        0     en0

2014-8-26 更新:
1. 扩展MAC bridge 命令,上面只说了加member,那么去member和如何去掉bridge呢?

sudo ifconfig bridge0 create
sudo ifconfig bridge0 up
sudo ifconfig bridge0 addm en0 addm en3
sudo ifconfig bridge0 down
sudo ifconfig bridge0 deletem en0 deletem en3
sudo ifconfig bridge0 destroy

2. 但直接连vmnet和dynamics时,报“206-unable to create generic ethernet NIO”

Quote: Why not direct connect via the vmnet? Simple. It doesn’t work on the Mac (unlike Windows and Linux).

That what I thought, I had tested on Windows and Linux, I remember it worked well. I just tested on OSX to at least understand what is wrong… First test was to attach to a vboxnet interface (created by VirtualBox), worked ok. Second test, tried to attach to a vmnet interface and I got exactly the same problem you have described. Third test, started Dynamips manually on port 7200, opened a Telnet connection to it and entered the following command:

Quote: unable to open device ‘vmnet2’ with PCAP

We can see the exact error message from libpcap: vmnet2: No such device exists (BIOCSETIF failed: Device not configured. I did some research and it appears the issue is with VMware fusion itself. Other software using libpcap have the exact same issue as Dynamips. The reason is that VMware Fusion vmnet interfaces have not implemented BPF (what is BPF? =>

The issue exists since 2007 and VMware haven’t done anything about it. So, I think we have a dead end here… at least we know why we cannot use vmnet interfaces directly now 🙂

Quote: The only method that works for me is the [bridge:tap+vmnet] combo. Even if I direct connect via the bridge interface w/ only the vmnet as a member (omitting the tap interface), it will connect but fail to pass traffic between the connected devices.

I actually prefer the decoupled aspect to this type of configuration; it minimizes the dependency between the applications:

2013-12-29 更新:telnet issue for tcp connect
“telnet: connect to address Operation timed out”


x-mac:~ yong$ netstat -p "tcp"
Active Internet connections
Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)    
tcp4       0      0     198-57-242-168.u.http  CLOSE_WAIT 
tcp4       0      0  SYN_SENT   
tcp4       0      0  SYN_SENT 

x-mac:~ yong$ lsof -i -P | grep -i "listen"
TeamViewe   458 yong   12u  IPv4 0x921e2b32d2579349      0t0  TCP localhost:6040 (LISTEN)
RosettaSt   776 yong    3u  IPv4 0x921e2b32d49cb349      0t0  TCP localhost:55568 (LISTEN)
RosettaSt   776 yong    4u  IPv6 0x921e2b32b7397241      0t0  TCP localhost:55568 (LISTEN)


Last login: Sun Dec 29 08:27:19 on ttys003
x-mac:~ yong$ telnet localhost 2001 ; exit

telnet: connect to address Operation timed out
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying fe80::1...
telnet: connect to address fe80::1: Connection refused
telnet: Unable to connect to remote host

重启一台路由器试试,发现能解决……我试验用的路由器还没保存配置,不想重启……看看MAC OSX的路由状况,发现了一些异常:

x-mac:~ yong$ netstat -rn
Routing tables

Destination        Gateway            Flags        Refs      Use   Netif Expire
127                UCS             0        0     lo0          UH             42 14427525     lo0

x-mac:~ yong$ ifconfig lo0
lo0: flags=8049<up,loopback,running,multicast> mtu 16384
        inet6 ::1 prefixlen 128 
        inet netmask 0xff000000 
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
        nd6 options=1


x-mac:~ yong$ sudo ifconfig lo0 down
x-mac:~ yong$ 
x-mac:~ yong$ netstat -rn |grep "127"
x-mac:~ yong$ sudo ifconfig lo0 up
x-mac:~ yong$ netstat -rn |grep "127"          UH             18     4714     lo0          UHS             0        0     lo0


x-mac:~ yong$ lsof -i -P | grep -i "Secure"
SecureCRT 67500 yong   17u  IPv4 0x921e2b32ba287b61      0t0  TCP localhost:59000->localhost:2003 (ESTABLISHED)
SecureCRT 67500 yong   22u  IPv4 0x921e2b32dbabb349      0t0  TCP localhost:59001->localhost:2000 (ESTABLISHED)
SecureCRT 67500 yong   24u  IPv4 0x921e2b32da359b61      0t0  TCP localhost:59175->localhost:2005 (ESTABLISHED)
SecureCRT 67500 yong   28u  IPv4 0x921e2b32ba982349      0t0  TCP localhost:59003->localhost:2002 (ESTABLISHED)
SecureCRT 67500 yong   30u  IPv4 0x921e2b32d4b4fb61      0t0  TCP localhost:59173->localhost:2001 (ESTABLISHED)
SecureCRT 67500 yong   35u  IPv4 0x921e2b32da356b61      0t0  TCP localhost:59171->localhost:2004 (ESTABLISHED)

x-mac:~ yong$ netstat -nv |egrep "" | awk '$4 ~"*"'
tcp4       0      0        ESTABLISHED
tcp4       0      0        ESTABLISHED
tcp4       0      0        ESTABLISHED
tcp4       0      0        ESTABLISHED
tcp4       0      0        ESTABLISHED
tcp4       0      0        ESTABLISHED


Integrate VMware Fusion with GNS3 on your Mac

本文出自 Frank's Blog


本文链接:MAC OSX dynamips bundle Loopback Port
版权声明:本文为原创文章,仅代表个人观点,版权归 Frank Zhao 所有,转载时请注明本文出处及文章链接
你可以留言,或者trackback 从你的网站


blonde teen swallows videos