Solved

Samba startup with multiple interfaces

Posted on 2009-07-11
8
560 Views
Last Modified: 2013-12-06
Experts,

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!

Cheers,

Phil.
0
Comment
Question by:phil8258
8 Comments
 
LVL 20

Expert Comment

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

The software one would be to edit the startup script
/etc/init.d/samba

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.
0
 

Expert Comment

by:gcovato
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
0
 
LVL 2

Expert Comment

by:Hasues
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:

plug_timeout="10"

to /etc/conf.d/net

For reference:
man ifplugd
less /etc/conf.d/net.example
http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=4&chap=6

Haz
0
 

Author Comment

by:phil8258
ID: 25106438
Haz,

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).

Cheers,

Phil.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 2

Expert Comment

by:Hasues
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?

Haz
0
 

Author Comment

by:phil8258
ID: 25118161
Haz,
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.
Cheers,
Phil.
0
 
LVL 2

Accepted Solution

by:
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
}

to

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.

Haz
0
 

Author Closing Comment

by:phil8258
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.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now