Univention Bugzilla – Bug 26838
Erweiterte DHCP-Optionen konfigurierbar machen
Last modified: 2017-04-21 10:08:56 CEST
Angefragt an Ticket #2012041821001871: "im Zuge unseres bevorstehenden Windows-Rollouts wollen wir die Clients automatisch mit einer wpad.dat-Datei per DHCP versorgen. Nach Internetrecherchen ist hierzu folgendes in der dhcpd.conf einzutragen: option wpad code 252 = text; subnet X.X.X.0 netmask 255.255.255.0 { … option wpad “http://XXX/wpad.dat ”; … } Die erste Zeile habe ich in der Datei /etc/dhcp/dhcpd.local untergebracht. Die Einträge am jeweiligen Subnetz erfolgt ja über die UMC - dort habe ich allerdings keine passende Richtlinie gefunden, um die Zeile "option wpad “http://XXX/wpad.dat ”;" einzutragen."
Dummerweise verwendet UCS seine eigenen LDAP-Objekte (univentionDhcpSubnet statt dhcpSubnet), in denen "dhcpOption" nicht erlaubt ist, weshalb man "extensibleObject" benutzen muß, um das Attribute zu definieren. Damit funktioniert (an UDM vorbei) folgendes: #!/bin/bash echo 'option wpad code 252 = text;' >>/etc/dhcp/local.conf wpad=http://xen5.knut.univention.de/wpad.dat admin="cn=admin,$(ucr get ldap/base)" service=$(udm dhcp/service list | sed -ne 's/^DN: //p') subnet=$(udm dhcp/subnet list --superordinate "$service" | sed -ne 's/^DN: //;T;p;q') ldapmodify -x -D "$admin" -w "$(</etc/ldap.secret)" <<__LDIF__ dn: $subnet changetype: modify add: objectclass objectclass: extensibleObject - add: dhcpOption dhcpOption: wpad "$wpad" __LDIF__ Getestet werden kann das ganze per busybox auf einer VM: echo '#!/bin/sh' >/tmp/dump.sh echo 'set | grep wpad' >>/tmp/dump.sh chmod +x /tmp/dump.sh udhcpc -f -q -R -i eth0 -O wpad -s /tmp/dump.sh
(In reply to comment #1) > Dummerweise verwendet UCS seine eigenen LDAP-Objekte (univentionDhcpSubnet > statt dhcpSubnet), in denen "dhcpOption" nicht erlaubt ist, weshalb man > "extensibleObject" benutzen muß, Es geht besser: "dhcpOption" kann über die AUXILIARY-Klasse "dhcpOptions" nachgerüstet werden, d.h. extensibleObject ist hier nicht notwendig: ... > ldapmodify -x -D "$admin" -w "$(</etc/ldap.secret)" <<__LDIF__ > dn: $subnet > changetype: modify > add: objectclass objectclass: dhcpOptions > - > add: dhcpOption > dhcpOption: wpad "$wpad" > __LDIF__ ... # Zum testen kann mal schnell kvm benutzen, nur muß man auf die verschiedenen Netze aufpassen und ggf. ein Testnetz für DHCP bauen: udm dhcp/subnet create create \ --superordinate "$service" \ --position "$service" \ --set subnet=192.168.17.0 \ --set subnetmask=255.255.255.0 \ --set broadcastaddress=192.168.17.255 \ --set range="192.168.17.1 192.168.17.253" subnet=$(udm dhcp/subnet list --superordinate "$service"|sed -ne 's/^DN: //;T;p;q') udm dhcp/host create \ --superordinate "$service" \ --position "$service" \ --set host=test \ --set hwaddress='ethernet 00:11:22:33:44:55' \ --set fixedaddress=192.168.17.222 brctl addbr testbr0 ip a a 192.168.17.254/24 dev testbr0 ip l s testbr0 up openvpn --mktun --dev tap brctl addif testbr0 tap0 ip l s tap0 up kvm -m 512 \ -kernel /boot/vmlinuz-2.6.32-ucs63-amd64 \ -initrd /boot/initrd.img-2.6.32-ucs63-amd64 \ -append 'break=mount verbose' \ -netdev tap,ifname=tap0,id=hostnet0,script=no \ -device virtio-net-pci,netdev=hostnet0,id=net0,mac=00:11:22:33:44:55 & ... ip l set eth0 up ...
*** Bug 27146 has been marked as a duplicate of this bug. ***
Bitte noch einmal die letzten Änderungen überprüfen, derzeit startet das UDM-Modul nicht mehr: > >>> import univention.management.console.modules.udm > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File "/usr/lib/pymodules/python2.6/univention/management/console/modules/udm/__init__.py", line 59, in <module> > from .udm_ldap import UDM_Error, UDM_Module, UDM_Settings, check_license, ldap_dn2path, get_module, read_syntax_choices, list_objects, LDAP_Connection, LDAP_ConnectionError, set_credentials, container_modules > File "/usr/lib/pymodules/python2.6/univention/management/console/modules/udm/udm_ldap.py", line 63, in <module> > udm_modules.update() > File "/usr/lib/pymodules/python2.6/univention/admin/modules.py", line 82, in update > os.path.walk(dir, _walk, p) > File "/usr/lib/python2.6/posixpath.py", line 236, in walk > walk(name, func, arg) > File "/usr/lib/python2.6/posixpath.py", line 228, in walk > func(arg, top, names) > File "/usr/lib/pymodules/python2.6/univention/admin/modules.py", line 66, in _walk > m=__import__(mod, globals(), locals(), name) > File "/usr/lib/pymodules/python2.6/univention/admin/handlers/dhcp/server.py", line 75, in <module> > from .__common import add_dhcp_options > ImportError: No module named __common
Es können nun DHCP-Optionen an dhcp/service, dhcp7server und dhcp/subnet Objekten gesetzt werden. Allerdings nur über UDM CLI udm dhcp/service create .... --append option="wpad http://server/proxy.pac" ... Zusätzlich müssen die Optionen über UCR definiert werden: ucr set dhcpd/options/wpad/252=text ChangeLog Eintrag wurde hinzugefügt
*** Bug 27362 has been marked as a duplicate of this bug. ***
OK: ChangeLog: svn13152 OK: UCRV dhcpd/options/ OK: UDM-Module funktionieren noch OK: univention-dhcp_6.0.22-1.509.201205240914 Auspasse muß man allerdings bzgl. der korrekten Syntax; das Beispiel ist comment #5 ist falsch, denn dort fehlt das Quoting und das abschließende Semikolon. Richtig ist folgendes: udm .. option='wpad "http://server/proxy.pac";' Das Setzen funktioniert an Service und Subnet, nicht jedoch am Server (das ist aber OK so, weil sich Einstellungen am Server nur auf diesen selbst beziehen und nicht den von ihm erbrachten Service.) Getestet: qemu-system-x86_64 -m 512 \ -kernel /boot/vmlinuz-2.6.32-ucs64-amd64 \ -initrd /boot/initrd.img-2.6.32-ucs64-amd64 \ -append 'break=mount verbose' \ -netdev tap,ifname=tap0,id=hostnet0,script=no \ -device virtio-net-pci,netdev=hostnet0,id=net0,mac=00:11:22:33:44:55 ... udhcpc -i eth0 -O wpad -s /tmp/dump.sh -S -f -n -q -T3
UCS 3.0-2 has been released: http://forum.univention.de/viewtopic.php?f=54&t=1905 If this error occurs again, please use "Clone This Bug".
*** Bug 7617 has been marked as a duplicate of this bug. ***