LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-24-2013, 01:20 AM   #1
lin_user2004
Member
 
Registered: May 2004
Location: india
Distribution: Gentoo 2006.1
Posts: 59

Rep: Reputation: 15
Bridge Networking: Access VM behind bridge from outside


I am using proxmox(a Debian based distro which adds some scripts for Virtual Machine creation), I have setup a KVM guest with bridge networking.
Here's what the network looks like:
Code:
$ ifconfig vmbr0
vmbr0     Link encap:Ethernet  HWaddr 00:15:c5:ec:ba:27  
          inet addr:192.168.1.142  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::215:c5ff:feec:ba27/64 Scope:Link
 
$ ifconfig tap100i0
tap100i0  Link encap:Ethernet  HWaddr 8e:f5:0c:e8:61:5c  
          inet6 addr: fe80::8cf5:cff:fee8:615c/64 Scope:Link
 
$ ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:15:c5:ec:ba:27  
          inet6 addr: fe80::215:c5ff:feec:ba27/64 Scope:Link
 
$ brctl show
bridge name     bridge id               STP enabled     interfaces
vmbr0           8000.0015c5ecba27       no              eth0
                                                        tap100i0
I can access the services running on the host but not the guest VM. I checked that the networking is setup on guest VM and it's accessible from host too.
Code:
$ ping -q 192.168.1.136
PING 192.168.1.136 (192.168.1.136) 56(84) bytes of data.
--- 192.168.1.136 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3000ms
rtt min/avg/max/mdev = 0.110/0.383/1.179/0.459 ms

$ telnet 192.168.1.136 10022
Trying 192.168.1.136...
Connected to 192.168.1.136.
Escape character is '^]'.
So, I setup firewall rules to forward packets from port 1022 to port 10022 on the VM, the firewall looks as follows:
Code:
$ iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination        
 
Chain FORWARD (policy ACCEPT)
target     prot opt source               destination        
 
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination        
 
$ iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination        
DNAT       tcp  --  anywhere             anywhere             tcp dpt:1022 to:192.168.1.136:10022
 
Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination        
 
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination        

$ cat /proc/sys/net/ipv4/ip_forward
1
But, the packets are not forwarded to the VM
Code:
$ telnet 192.168.1.142 1022
Trying 192.168.1.142...
telnet: Unable to connect to remote host: Connection refused
Also, when I do tcpdump on port 22 which is external ssh port, it shows a lot of activity but when I run it on port 1022, it doesn't show any activity when I initiate ssh connection from my machine.

What am I doing wrong here?
 
Old 07-24-2013, 03:07 AM   #2
gradinaruvasile
Member
 
Registered: Apr 2010
Location: Cluj, Romania
Distribution: Debian Testing
Posts: 731

Rep: Reputation: 158Reputation: 158
I dont use proxmox so my setup may not apply to you.

I use plain Debian with libvirt/virt-manager and i use a bridge too - kvm(qemu) creates and adds to the bridge automatically a tap device for each VM when they start (and removes it afterwards).
Using libvirt/virt-manager is very easy, its like VBox' interface. Also if libvirt is installed on a headless server, you can connect to it via ssh and manage the remote vms exactly as if were on your computer, from virt-manager's interface.

Creating a vm (create the host bridge setup prior) is very easy and self-explanatory, for the network device you just have to specify "use shared device" then enter the host's bridge name.

Virt-manager generates the startup command line options resulting in a huge mess, but this seems to be the relevant part:

Code:
-netdev tap,fd=23,id=hostnet0,vhost=on,vhostfd=24 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:41:d7:a3,bus=pci.0,addr=0xc
ifconfig on host (removed some lines for other tap devices not relevant here):

Code:
br0       Link encap:Ethernet  HWaddr 94:de:80:00:8b:0c  
          inet addr:192.168.100.100  Bcast:192.168.100.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1148160 errors:0 dropped:0 overruns:0 frame:0
          TX packets:581181 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:541838221 (516.7 MiB)  TX bytes:1371155380 (1.2 GiB)

eth0      Link encap:Ethernet  HWaddr 94:de:80:00:8b:0c  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1161851 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1448975 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:561719982 (535.6 MiB)  TX bytes:1419055299 (1.3 GiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:6593 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6593 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:496252 (484.6 KiB)  TX bytes:496252 (484.6 KiB)

vnet0     Link encap:Ethernet  HWaddr fe:54:00:41:d7:a3  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:894 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2500 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500 
          RX bytes:785441 (767.0 KiB)  TX bytes:315188 (307.8 KiB)
Code:
# brctl show
bridge name	bridge id		STP enabled	interfaces
br0		8000.94de80008b0c	no		eth0
							vnet0
The vm is seen exactly as another computer on the network.
 
Old 07-24-2013, 04:50 AM   #3
routers
Member
 
Registered: Aug 2005
Location: Malaysia - KULMY / CNXTH
Distribution: Slackware, Fedora, FreeBSD, Sun O/S 5.10, CentOS
Posts: 787
Blog Entries: 6

Rep: Reputation: 75
I think you have same problem with me , but i am using centos
i solve it with dhclient

http://www.linuxquestions.org/questi...ue-4175470651/
 
Old 07-24-2013, 05:08 AM   #4
lin_user2004
Member
 
Registered: May 2004
Location: india
Distribution: Gentoo 2006.1
Posts: 59

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by gradinaruvasile View Post
I dont use proxmox so my setup may not apply to you.

I use plain Debian with libvirt/virt-manager and i use a bridge too - kvm(qemu) creates and adds to the bridge automatically a tap device for each VM when they start (and removes it afterwards).
Using libvirt/virt-manager is very easy, its like VBox' interface. Also if libvirt is installed on a headless server, you can connect to it via ssh and manage the remote vms exactly as if were on your computer, from virt-manager's interface.
proxmox shouldn't matter much. It pretty much does the same thing. If I could, I'd have gone your way too.

Quote:
Originally Posted by gradinaruvasile View Post
Creating a vm (create the host bridge setup prior) is very easy and self-explanatory, for the network device you just have to specify "use shared device" then enter the host's bridge name.

Virt-manager generates the startup command line options resulting in a huge mess, but this seems to be the relevant part:

Code:
-netdev tap,fd=23,id=hostnet0,vhost=on,vhostfd=24 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:41:d7:a3,bus=pci.0,addr=0xc
ifconfig on host (removed some lines for other tap devices not relevant here):

Code:
br0       Link encap:Ethernet  HWaddr 94:de:80:00:8b:0c  
          inet addr:192.168.100.100  Bcast:192.168.100.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1148160 errors:0 dropped:0 overruns:0 frame:0
          TX packets:581181 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:541838221 (516.7 MiB)  TX bytes:1371155380 (1.2 GiB)

eth0      Link encap:Ethernet  HWaddr 94:de:80:00:8b:0c  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1161851 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1448975 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:561719982 (535.6 MiB)  TX bytes:1419055299 (1.3 GiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:6593 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6593 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:496252 (484.6 KiB)  TX bytes:496252 (484.6 KiB)

vnet0     Link encap:Ethernet  HWaddr fe:54:00:41:d7:a3  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:894 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2500 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500 
          RX bytes:785441 (767.0 KiB)  TX bytes:315188 (307.8 KiB)
Code:
# brctl show
bridge name	bridge id		STP enabled	interfaces
br0		8000.94de80008b0c	no		eth0
							vnet0
The vm is seen exactly as another computer on the network.
In my case the bridge device is vmbr0 and tap interface is tap100i0. So, I do have the same devices but just different names.
 
Old 07-24-2013, 05:10 AM   #5
lin_user2004
Member
 
Registered: May 2004
Location: india
Distribution: Gentoo 2006.1
Posts: 59

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by routers View Post
I think you have same problem with me , but i am using centos
i solve it with dhclient

http://www.linuxquestions.org/questi...ue-4175470651/
I checked, the VM has executed dhclient to get the IP. I ran it again, just in case but this hasn't resolved the issue.
 
Old 07-24-2013, 05:42 AM   #6
routers
Member
 
Registered: Aug 2005
Location: Malaysia - KULMY / CNXTH
Distribution: Slackware, Fedora, FreeBSD, Sun O/S 5.10, CentOS
Posts: 787
Blog Entries: 6

Rep: Reputation: 75
would you turn off the vm and start it back
in my case not work with reboot
 
Old 07-24-2013, 06:42 AM   #7
gradinaruvasile
Member
 
Registered: Apr 2010
Location: Cluj, Romania
Distribution: Debian Testing
Posts: 731

Rep: Reputation: 158Reputation: 158
Quote:
Originally Posted by lin_user2004 View Post
I checked, the VM has executed dhclient to get the IP. I ran it again, just in case but this hasn't resolved the issue.
Have you tried setting the IP address manually in the guest?
 
Old 07-25-2013, 09:26 AM   #8
lin_user2004
Member
 
Registered: May 2004
Location: india
Distribution: Gentoo 2006.1
Posts: 59

Original Poster
Rep: Reputation: 15
I tried both, rebooting the VM and assigning static IP but both failed.
 
Old 07-25-2013, 01:28 PM   #9
gradinaruvasile
Member
 
Registered: Apr 2010
Location: Cluj, Romania
Distribution: Debian Testing
Posts: 731

Rep: Reputation: 158Reputation: 158
Maybe its a permission issue somewhere.
How do you run the VM? Under which user? Try under root (if not already, that is).
 
Old 07-26-2013, 04:30 AM   #10
lin_user2004
Member
 
Registered: May 2004
Location: india
Distribution: Gentoo 2006.1
Posts: 59

Original Poster
Rep: Reputation: 15
I figured there's a firewall ahead of the machine that I wasn't aware of. I have asked concerned person to open the required ports. I'll also try forwarding the ports I know are already open and update about it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bridge / qemu - bridge is natting multicast traffic eantoranz Linux - Networking 1 12-31-2012 06:46 PM
LXer: RC6 To Be Flipped On For Sandy Bridge, Ivy Bridge LXer Syndicated Linux News 0 12-11-2011 06:12 AM
[SOLVED] Bridge networking on RHEL mcleandl Linux - Networking 2 10-06-2010 06:47 AM
Bridge networking for Xen sparkshankar Linux - Server 1 09-30-2009 03:53 AM
slackware networking through XP bridge zigmund555 Linux - Networking 5 01-31-2004 10:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration