Samba startup with multiple interfaces

Posted on 2009-07-11
Last Modified: 2013-12-06

I'm having a problem where samba will not start up because one on the interfaces is not connected.
The error message is:

* WARNING:   samba is scheduled to start when net.eth1 has started

eth0 is connected to a switch for the local network
eth1 is connected directly to another server

I would like Samba to serve both the network on eth0 AND the other server on eth1.
Obviously my problem comes that it will not serve anything if the other server connected to eth1 is switched off.

I would like samba to start regardless of whether eth0 or eth1 is up or down, and to serve either or both should one or both of these networks come up after samba has started.

I'm sure this must be possible. I've done a bit of google trawling and found there are bugs related to this. I don't think this is a bug, more just a case of I've not switched on a machine.

Help would be much appreciated!


Question by:phil8258
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 20

Expert Comment

ID: 24893487
There is two ways to fix this.  Software or hardware.

The software one would be to edit the startup script

near the top it has something like

depend() {
     need net;

This is the line that makes it stop if the network cards are not up.  Use could swap it for 'use net' or remve it all together.
This is not the best answer as that line was put in there for a reason.  It might make your system unstable if it does start up and neither card is running.
It may also make Samba run too early if it doesn't wait for the network part.

I would go for the other method of fixing this.  Connect the network card to a simple switch and connect that to the other machine.
You may need to swap the existing cable (which is probably a cross over) for a standard bit of ethernet cable and you will need a small switch to connect them.
But it will now always have a connection even if the machine is turned off.

Expert Comment

ID: 24950472
A way to avoid the problem is stop the network card when ever they are not connected.

/etc/init.d/net.ethx stop

In order to avoid the problem during startup, it is better to not autostart the network interfaces during boot

rc-update del net.ethx default

and start them later, manually,  when the cards are physically connected

Expert Comment

ID: 25040461
You need ifplugd on your system.

emerge -av ifplugd

Once added, it should by default added to the network interfaces and monitor for connection and disconnection events, and starting the associated services once the interface comes online.  You might want to add:


to /etc/conf.d/net

For reference:
man ifplugd
less /etc/conf.d/net.example

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)


Author Comment

ID: 25106438

Thanks for your comment. I've installed ifplugd as you suggested with plug_timeout="10".
It sounds like it's getting somewhere closer to what i'm trying to do.

I'm not sure it's doing what I want yet (though it's actually hard to tell if it's running). Unfortunalely, it's not done what i'm after out-the-box, when I start the machine with the eth1 link down, samba and ssh and whatever services that are bound to both eth0 and eth1 don't start up. Is the idea with ifplugd that it should trick these services into starting by "plugging" the disconnected interface until it comes up?

I've checked ifconfig and found that eth1 when disconnected has information showing but no IP (set manually).



Expert Comment

ID: 25117791
Correct Phil, what should be happening is when you start up and the interfaces detect there is no connection, it will warn you that all dependent services are set to start once the interfaces come online.  When you plug in your cable, you should hear the pc speaker beep (if available) and it detects that it has been plugged in, and that it has a connection.  Once the connection is available then the service starts.  Are you saying when you plug the interface in that it is not setting the IP and related on the interface?  Could you post your /etc/conf.d/net and an rc-update -s?


Author Comment

ID: 25118161
It's working as it should. I've played with it a bit more this evening and found that with the eth1 link unplugged ssh and samba don't start, but soon after plugging it in, they do start.
Unfortunately, whilst it certainly does improve the situation, it's not really what I was after. I want something to trick ssh and samba into thinking eth1 is connected (or ignore it) and start the services at boot regardless.
Perhaps the only real solution is a switch.

Accepted Solution

Hasues earned 250 total points
ID: 25118598
Make a virtual interface on something, like say a USB port, or even a fake one of sorts.  Add this interface to smb.conf as an interface it listens on, and do the same for /etc/ssh/sshd_config.  These interfaces would be available during boot and thus the service would be available.  As another option, you could modify the init scripts for both changing their dependencies.  For instance, in /etc/init.d/samba, change:

depend() {
        after slapd
        need net
        use cupsd


depend() {
        use cupsd

Finally, as food for thought, if no interfaces are available, it doesn't really matter what service is available, right?  No connectivity is available to serve it.

One of the above should work for you.


Author Closing Comment

ID: 31602452
Sorry for the delay. Thanks for your suggestions. changing /etc/init.d/samba and sshd to remove the use net dependency was just what I needed. All working nice now. The machine will boot and start both samba and sshd when the machine connected direct to eth1 is powered off, but be fully accessible with those services on eth0 (connected to switch). When the other machine is booted, ifplug restarts samba and sshd is then working on both interfaces. Thanks for your help. Cheers.

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question