Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
344 views
in Technique[技术] by (71.8m points)

linux - virtualbox vm can not access from outside

I installed a vbox in ubuntu 18.04, and used bridged network by adding parameters:

--bridgeadapter2 eno1 --nicpromisc2 allow-all

Everything goes fine, vm can ping outside, and host can ping vm, but outside can not ping vm: (outside in the same subnet can ping vm, for example: 10.124.214.x can ping vm)

# 10.124.214.116 is vm, 10.124.214.4 is host, 10.124.12.103 is outside IP
# From host to vm
traceroute 10.124.214.116
traceroute to 10.124.214.116 (10.124.214.116), 30 hops max, 60 byte packets
 1  10.124.214.116 (10.124.214.116)  0.232 ms  0.197 ms  0.191 ms
# From vm to outside
ping 10.124.12.103
PING 10.124.12.103 (10.124.12.103) 56(84) bytes of data.
64 bytes from 10.124.12.103: icmp_seq=1 ttl=63 time=1.38 ms

The tricky thing is vbox interface does not like normal linux tun/tap interface, I can see interface in VM, but there is nothing I can operate from host, and there is no bridge on the host.

Is there any API I can trouble shooting vbox?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Cheers code farmer

You are right about bridge. Thing here is that your VM is currently behind NAT created by virtual box (see different subnets you mentioned)

What you can do here is to create new bridge on host machine (good instructions HERE)

Using this setup you will have to change networking setting slightly:

                                     VM Host
                                     +-----------------------------------------------------------------+
                                     |                                       -> VM A (10.124.214.5/24) |
Outside network (10.124.214.0/24) -> | eno1 (no IP) -> br0 (10.124.214.4/24) -> VM B (10.124.214.6/24) |
                                     |                                       -> VM C (10.124.214.7/24) |
                                     +-----------------------------------------------------------------+

Then you can assign your VM to br0. Depends on your outside network setting you might need to set static IP to your VM


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...