lundi 1 juin 2015

[Postfix] simple relay host configuration

I installed a new SLES 11 server for a customer. As I need to follow cron's results, I configured postfix on this machine as a simple relay. All mails are sent to my MX server.

By default SLES 11 does not install postfix or related yast modules ( or my image was not configured like that :-) ).

So after installing postfix and yast2-mail module, I finally clean up the configuration files.

In /etc/postfix/main.cf, I keep following lines



inet_protocols = all
smtp_dns_resolver_options = res_defnames
smtpd_banner = $myhostname
biff = no
myhostname =
inet_interfaces = loopback-only # not a mail forwarder
mydestination = # yeah empty
relayhost =
alias_maps = hash:/etc/aliases
mailbox_size_limit = 0
message_size_limit = 10240000
smtp_generic_maps = hash:/etc/postfix/generic 

In /etc/postfix/generic, I added accounts linked to email adresses.

Do not forget to execute 
# postmap /etc/postfix/generic

and 
# service postfix restart

to finish configuration 



samedi 18 avril 2015

Configurer Unbound sur Raspberry Pi ( Raspbian )

Cet article sur différentes sources dont celui de Stéphane Bortzmeyer ( http://www.bortzmeyer.org/son-propre-resolveur-dns.html ) et celle ci https://calomel.org/unbound_dns.html

J'ai fait l'acquisition d'un Raspberry Pi 2 pour qu'il me serve de résolveur DNS et de serveur DHCP. Cela permet de ne plus être contributaire des DNS de free ou d'un autre.

Sur Raspbian, basée sur une Debian, l'intallation nécessite le package Unbound et dnsutils pour pouvoir utiliser dig

# sudo bash // passage en root 
# apt-get install unbound dnsutils

Pour que le mode racine fonctionne, il faut télécharger un fichier comprenant la liste des serveurs racine ( et mettre à jour le fichier tous les 6 mois ).

# wget ftp://FTP.INTERNIC.NET/domain/named.cache -O /etc/unbound/root.hints

# cd /etc/unbound
# vi unbound.conf

Et saisir les informations suivantes :



server:
    verbosity: 1
    # The following line will configure unbound to perform cryptographic
    # DNSSEC validation using the root trust anchor.
    auto-trust-anchor-file: "/var/lib/unbound/root.key"
    root-hints: "/etc/unbound/root.hints"
    do-ip4: yes
    do-ip6: yes
    do-udp: yes
    do-tcp: yes
    interface: 0.0.0.0
    access-control: 192.168.0.0/24 allow
    access-control: 127.0.0.0/8 allow
    access-control: 0.0.0.0/0 refuse
    private-domain: "monvlan."
    include: /etc/unbound/local.conf
remote-control:
    control-enable: no


La ligne include: /etc/unbound/local.conf sert à définir dans le DNS son réseau local.

Exemple de configuration pour ma freebox. Il faut définir le lien nom > IP puis le lien IP nom

local-zone: "monvlan." static
local-data: "freebox.monvlan. IN A 192.168.0.254"        #résolution sens nom -> adresse
local-data-ptr: "192.168.0.254 freebox.monvlan"

Dans mon cas, monvlan est mon domaine local :-)

Il faut encore modifier la résolution du DNS du système. Sous Raspbian, modifier le fichier /etc/resolv.conf

search monvlan
nameserver 127.0.0.1

Une fois la configuration faite, relancer le service Unbound

# service unbound restart

On peut vérifier son bon fonctionnement en regardant le fichier de log /var/log/syslog

Pour vérifier la bonne définition du DNS local, on peut utiliser le script disponible ici : https://calomel.org/dns_verify.html


mercredi 4 mars 2015

Customize SOAP header in .Net framework ( VB.Net code )

Last week, someone ask on twitter if someone can help with VB.Net code for SOAP.

The demand was how to customize SOAP header to add new fields.
 The result was something like below

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://a.com/">
<soap:Header   xmlns:soapHeader="http://a.com/Header">
<soapHeader:shopId>83486117>/soapHeader:shopId>
<soapHeader:requestId>ba45b5e9-db3f-4ff7-8766-98a5099d6a8b>
<soapHeader:timestamp>2015-02-25T21:54:18Z>/soapHeader:timestamp>
<soapHeader:mode>TEST<soapHeader:mode>
<soapHeader:authToken>gZ+zva7ZWhUvZK43v8vS8Jwf2ozb5PXN/O9LwyVUKZ8= </soapHeader:authToken> 
</soap:Header> 
<soap:Body>
<a:findPayments>
</a:findPayments>
</soap:Body> 
</soap:Envelope>


 By default, .Net framework access Web Services using a Service Reference to create a Web Service proxy from a WSDL description.
But the default object does not provide a direct way to customize the header except username, password and authtoken.

After a lot of research on Technet, forums and so on... I find the solution.

 Add the following import in the code

Imports System.ServiceModel
Imports System.ServiceModel.Channels


Create a Service Reference for creating the proxy ( called service below ).

Dim service As Service.PaymentAPIClient = New Service.PaymentAPIClient()



' Add a namespace ( mandatory in my case )
Dim ns As String = "http://a.com/Header"


' create a contect object. It uses to customize the InnerChannel which define the behaviour of the outbound request ( https://msdn.microsoft.com/fr-fr/library/ms553832%28v=vs.110%29.aspx )
Dim context = New OperationContextScope(service.InnerChannel())



' create a new Header for each field
Dim msgHeader1 = MessageHeader.CreateHeader("shopId", ns, xxxx)

[...]

' add header to "normal header"
 OperationContext.Current.OutgoingMessageHeaders.Add(msgHeader1)


To check the SOAP message, use a tool like Fiddler ( http://www.telerik.com/fiddler ) that will display the SOAP message when debugging.

vendredi 30 janvier 2015

Commands to check Linux updates

Those scripts were created to send result by email using cron.

For Suse Linux

Create a shell script and run it by cron every day.

#!/bin/sh
/usr/bin/zypper list-patches | mail -s "SUSE Patch to install"



For Ubuntu

#!/bin/sh
FILE=/tmp/update.log
touch $FILE
/usr/lib/update-notifier/update-motd-updates-available > $FILE

/usr/lib/update-notifier/update-motd-reboot-required >> $FILE

/bin/cat $FILE

SAP HANA, core dumps and Embedded Statistic server

We installed two new SAP B1 for Hana some months ago.  First installation was on ESXi and second on a physical machine.

Both were installed with SAP HANA rev 74.3, but sometimes SAP B1 authentication failed because SAP HANA did not respond. It happened several times per week.
Each time, SAP HANA stopped with a core dump.

Meanwhile, I found SAP NOTE 1917938 - Migration of the statistics server for Revision 74 or higher and 2092033 - Embedded Statistics Service Migration Guide.
They explained that a new statistic server exists called ESS ( Embedded Statistic Server ) instead of the existing service and described the migration process.

I try the migration on our SAP HANA server to check if it is working correctly. After some week of testing, it appears that the new ESS works without problem.

So I decided to apply this solution to our customer running ESXi.

For the last 2 weeks, SAP HANA run perfectly and it does not crash anymore.

Apply this note could solve this type of problem.