@@ -88,6 +88,7 @@ func (c *Command) readConfig() *Config {
8888 "tag pair, specified as key=value" )
8989 cmdFlags .StringVar (& cmdConfig .Discover , "discover" , "" , "mDNS discovery name" )
9090 cmdFlags .StringVar (& cmdConfig .Interface , "iface" , "" , "interface to bind to" )
91+ cmdFlags .StringVar (& cmdConfig .MDNS .Interface , "mdns-iface" , "" , "interface to use for mDNS" )
9192 cmdFlags .StringVar (& cmdConfig .TagsFile , "tags-file" , "" , "tag persistence file" )
9293 cmdFlags .BoolVar (& cmdConfig .EnableSyslog , "syslog" , false ,
9394 "enable logging to syslog facility" )
@@ -176,6 +177,18 @@ func (c *Command) readConfig() *Config {
176177 return nil
177178 }
178179
180+ if config .MDNS .Interface != "" {
181+ if config .Discover == "" {
182+ c .Ui .Error ("mDNS interface specified without enabling mDNS discovery" )
183+ return nil
184+ }
185+
186+ if _ , err := net .InterfaceByName (config .MDNS .Interface ); err != nil {
187+ c .Ui .Error (fmt .Sprintf ("Invalid mDNS network interface: %s" , err ))
188+ return nil
189+ }
190+ }
191+
179192 // Backward compatibility hack for 'Role'
180193 if config .Role != "" {
181194 c .Ui .Output ("Deprecation warning: 'Role' has been replaced with 'Tags'" )
@@ -432,7 +445,9 @@ func (c *Command) startAgent(config *Config, agent *Agent,
432445 local := agent .Serf ().Memberlist ().LocalNode ()
433446
434447 // Get the bind interface if any
435- iface , _ := config .NetworkInterface ()
448+ iface , _ := config .MDNSNetworkInterface ()
449+
450+ c .logger .Printf ("[INFO] agent: Starting mDNS listener on interface %s" , iface .Name )
436451
437452 _ , err := NewAgentMDNS (agent , logOutput , config .ReplayOnJoin ,
438453 config .NodeName , config .Discover , iface , local .Addr , int (local .Port ))
@@ -734,7 +749,10 @@ Options:
734749 -bind if the interface is known but not the address.
735750 If both are provided, then Serf verifies that the
736751 interface has the bind address that is provided. This
737- flag also sets the multicast device used for -discover.
752+ flag also sets the multicast device used for -discover,
753+ if mdns-iface is not specified.
754+ -mdns-iface Network interface to use for mDNS. If not provided, the
755+ -iface value is used.
738756 -advertise=0.0.0.0 Address to advertise to the other cluster members
739757 -config-file=foo Path to a JSON file to read configuration from.
740758 This can be specified multiple times.
0 commit comments