View previous topic :: View next topic |
Author |
Message |
think4urs11 Bodhisattva
Joined: 25 Jun 2003 Posts: 6659 Location: above the cloud
|
Posted: Tue Jan 10, 2006 3:23 pm Post subject: mini [HOWTO] dynamically set WINS server for Samba via DHCP |
|
|
Setting WINS server dynamically by utilizing DHCP server options
Issue:
You have a Samba server configured on your notebook.
This machine travels much between different networks with different WINS server each - thereby acting as wins client. It soon gets annoying to manually reconfigure Samba all the time because it needs a line 'wins server = <ip address of wins server>'.
Solution:
Use dhcp provided values for wins like e.g. Windows clients do too and a client capable of handling the additional option(s).
Prerequisites:
DHCP server which provides option 44, thats netbios-name-servers
- net-fs/samba
- baselayout-1.12.0_pre*
- net-misc/dhcp (only dhclient really needed)
(Unfortunately dhcpcd seems not to be capable to deal with this option...)
create a file
/etc/dhcp/dhclient-exit-hooks wrote: | #!/bin/bash
/usr/bin/sed 's/\(wins server = \)\([0-9][\.0-9]*\)/\1'$new_netbios_name_servers'/' </etc/samba/smb.conf >/tmp/smb.temp
cp /tmp/smb.temp /etc/samba/smb.conf
|
Code: | chmod +x /etc/dhcp/dhclient-exit-hooks |
So smb.conf gets rewritten every time a dhcp lease is given. Any line 'wins server = <ip address>' will be changed (only the addresses) to whatever dhclient gets from the dhcp server.
If the ip address of the wins server changes *during* your machine beeing up you need to inform samba about that...
Code: | /usr/bin/smbcontrol nmbd reload-config |
Cannot be done in dhclient-exit-hooks because of a catch-22
Have fun
*edit*
Many thanks UberLord, found a bad typo in my /etc/dhcp/dhclient-exit-hooks; howto corrected accordingly
*edit* smbcontrol moved out of dhclient-exit-hooks
shouldn't be needed though unless the wins server changes during the machine beeing up _________________ Nothing is secure / Security is always a trade-off with usability / Do not assume anything / Trust no-one, nothing / Paranoia is your friend / Think for yourself
Last edited by think4urs11 on Tue Jan 10, 2006 4:20 pm; edited 4 times in total |
|
Back to top |
|
|
UberLord Retired Dev
Joined: 18 Sep 2003 Posts: 6835 Location: Blighty
|
Posted: Tue Jan 10, 2006 3:35 pm Post subject: |
|
|
Or you could use baselayout-1.12.0_preX and net-misc/dhcp (dhclient) and create this file and chmod +x it
/etc/dhcp/dhclient-exit-hooks
Code: | #!/bin/sh
/usr/bin/sed 's/\(wins server = \)\([0-9][\.0-9]*\)/\1'$new_netbios_name_servers'/' </etc/samba/smb.conf >/tmp/smb.temp
cp /tmp/smb.temp /etc/samba/smb.conf
/usr/bin/smbcontrol nmbd reload-config |
That way your custom modifications are preserved between baselayout upgrades _________________ Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool |
|
Back to top |
|
|
think4urs11 Bodhisattva
Joined: 25 Jun 2003 Posts: 6659 Location: above the cloud
|
Posted: Tue Jan 10, 2006 3:39 pm Post subject: |
|
|
tried that (with baselayout-1.12.0_pre13-r1) but etc/dhcp/dhclient-exit-hooks never got started; i'll give it annother try later today.
*edit* checked and howto corrected _________________ Nothing is secure / Security is always a trade-off with usability / Do not assume anything / Trust no-one, nothing / Paranoia is your friend / Think for yourself |
|
Back to top |
|
|
UberLord Retired Dev
Joined: 18 Sep 2003 Posts: 6835 Location: Blighty
|
|
Back to top |
|
|
Negated Void l33t
Joined: 25 Dec 2002 Posts: 672
|
Posted: Mon Jan 16, 2006 8:31 am Post subject: |
|
|
Do i have to do more than just "emerge dhcp" to get support? I was using dhcpcd before.. |
|
Back to top |
|
|
UberLord Retired Dev
Joined: 18 Sep 2003 Posts: 6835 Location: Blighty
|
|
Back to top |
|
|
Negated Void l33t
Joined: 25 Dec 2002 Posts: 672
|
Posted: Mon Jan 16, 2006 8:54 am Post subject: |
|
|
Mmmkay.
Running dhclient now.
Should this overwrite the "wins server" line in my smb.conf? I'm not seeing that happen when i run the reload line. |
|
Back to top |
|
|
Negated Void l33t
Joined: 25 Dec 2002 Posts: 672
|
Posted: Thu Feb 09, 2006 7:56 am Post subject: |
|
|
.. anyone? I'm really interested in this |
|
Back to top |
|
|
UberLord Retired Dev
Joined: 18 Sep 2003 Posts: 6835 Location: Blighty
|
|
Back to top |
|
|
|