LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 09-01-2022, 12:28 PM   #1
stoorky
Member
 
Registered: Sep 2015
Posts: 63

Rep: Reputation: Disabled
iptables rule to forward mdns requests (virtual machine)


I have :
  • A virtualization host, with :
    LAN : 192.168.137.1
    Wi-Fi : DHCP
  • A virtual machine (virtualbox), connected through a bridge with the host (192.168.137.6)
    The host acts as a gateway, I set up a masquerade iptables rule :
    Code:
    IPT=/sbin/iptables
    $IPT -t nat -A POSTROUTING -o wlp2s0 -j MASQUERADE
  • And a wireless printer/scanner
From the host, I can print and scan without problem. The printer is discovered through mdns :
Code:
$ mdns-scan 
+ HP OfficeJet Pro 8710 [8B5B51]._printer._tcp.local
+ HP OfficeJet Pro 8710 [8B5B51]._pdl-datastream._tcp.local
(...)
From the guest, the wireless printer isn't discovered through mdns, although I can ping it :
Code:
$ mdns-scan 
Browsing ... \           
[ nothing is discovered ]

$ ping 192.168.0.186
PING 192.168.0.186 (192.168.0.186) 56(84) bytes of data.
64 bytes from 192.168.0.186: icmp_seq=1 ttl=254 time=49.4 ms
64 bytes from 192.168.0.186: icmp_seq=2 ttl=254 time=4.72 ms
64 bytes from 192.168.0.186: icmp_seq=3 ttl=254 time=14.7 ms
(...)
Is there an additional IP rule to set up on the host to forward mdns requests ?

Last edited by stoorky; 09-01-2022 at 12:36 PM.
 
Old 09-01-2022, 01:21 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,784

Rep: Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937
mDNS as far as I know does not cross subnets. Typically home subnets on 192.168.x.x are /24(255.255.255.0) and therefore 192.168.137.1 and 192.168.0.186 are not on the same network.

When you create a new guest VirtualBox configures the network for NAT which uses a virtual router between the host and guest. How is your guest configured?

One solution would be to use a local DNS.

I am not a networking expert but if you have a bridge then why the need for a NAT firewall rule.

Last edited by michaelk; 09-01-2022 at 02:02 PM.
 
1 members found this post helpful.
Old 09-01-2022, 03:31 PM   #3
stoorky
Member
 
Registered: Sep 2015
Posts: 63

Original Poster
Rep: Reputation: Disabled
> How is your guest configured?
> Why the need for a NAT firewall rule.
Well, it's kind of a travel setup. I get my internet from a mobile GSM/Wi-Fi box (like that on : https://www.tp-link.com/uk/home-networking/mifi/m7200/). My host is a laptop, and is also connected to a small LAN, with a NAS. I need to access the NAS from the guest.

So, the guest is connected to the host in bridge mode : host, guest and NAS are on the same LAN.

And with this setup SNAT masquerading on the host is required so the guest can access the internet, through the host's WLAN

Anyway, everything works just fine, I have this setup for a few years now. But I just deployed a wireless printer/scanner, and I can not discover it from within the guest.

> mDNS as far as I know does not cross subnets.
OK, but if I can ping the wireless printer from within the guest, then I should be able to print on it, one way or another, no ?
The problem is that even though I can ping the printer, it's not detected through mDNS

I suspect there is an iptables rule on the host that could forward the guest's mDNS requests on the WLAN,but I cannot work out how

Last edited by stoorky; 09-01-2022 at 09:58 PM.
 
Old 09-01-2022, 09:49 PM   #4
stoorky
Member
 
Registered: Sep 2015
Posts: 63

Original Poster
Rep: Reputation: Disabled
@michaelk : +1 for "mDNS as far as I know does not cross subnets", it made me google "mDN subnet crossing linux", which gave some pointers to the right direction

I found an easy workaround : I just added a second NIC to the guest, bridged with the host's WLAN, and done !

Note however that it seems that mDNS subnet crossing can be done, by configuring Avahi in a reflector mode. There's also that project : https://github.com/geekman/mdns-repeater/. I didn't test any of it though, my workaround is good enough for now.

Last edited by stoorky; 09-01-2022 at 09:52 PM.
 
  


Reply



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
iptables NAT prerouting rule does not forward the traffic? postcd Linux - Networking 13 04-18-2020 06:32 AM
iptables rule for accept SSH connection from a specific IP and forward other IPs. hack3rcon Linux - Security 23 11-21-2017 06:14 PM
iptables: rule with RETURN target just after a rule with ACCEPT target Nerox Linux - Networking 6 09-04-2011 03:33 PM
Apache, forward requests to a vmware virtual machine Hube Linux - Software 2 09-02-2004 09:58 AM

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

All times are GMT -5. The time now is 03:25 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