title: Why does Python's socket.getfqdn() return a long string that looks like an IPv6 host rather than what `hostname -f` returns?
body: <p>Why does Python's <code>socket.getfqdn()</code> return <code>'1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa'</code> rather than matt-mmf-macbook.local?</p>
  
  <pre><code>mlm@matt-mmf-macbook.local:~
  $ python
  Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39) 
  [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; import socket
  &gt;&gt;&gt; socket.getfqdn()
  '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa'
  &gt;&gt;&gt; 
  
  mlm@matt-mmf-macbook.local:~
  $ hostname
  matt-mmf-macbook.local
  
  mlm@matt-mmf-macbook.local:~
  $ hostname -f
  matt-mmf-macbook.local
  </code></pre>
  
  <p>The unexpected output of <code>socket.getfqdn()</code> is making my Duplicity backups fail with the output below. My last successful Duplicity backup was on 12/19.</p>
  
  <pre><code>mlm@matt-mmf-macbook.local:~
  $ ~/config/bash/backup.sh
  Reading globbing filelist /Users/mlm/config/bash/backup-include-matt-mmf-macbook.txt
  Reading globbing filelist /Users/mlm/config/bash/backup-exclude-matt-mmf-macbook.txt
  Local and Remote metadata are synchronized, no sync needed.
  Warning, found the following remote orphaned signature files:
  duplicity-new-signatures.20110929T140604Z.to.20110929T143209Z.sigtar.gpg
  duplicity-new-signatures.20110929T143209Z.to.20110929T150055Z.sigtar.gpg
  duplicity-new-signatures.20110929T150055Z.to.20110929T161503Z.sigtar.gpg
  duplicity-new-signatures.20110929T161503Z.to.20110930T161505Z.sigtar.gpg
  duplicity-new-signatures.20110930T161505Z.to.20111005T024235Z.sigtar.gpg
  duplicity-new-signatures.20111005T024235Z.to.20111005T024907Z.sigtar.gpg
  duplicity-new-signatures.20111005T024907Z.to.20111005T161508Z.sigtar.gpg
  duplicity-new-signatures.20111005T161508Z.to.20111006T161509Z.sigtar.gpg
  duplicity-new-signatures.20111006T161509Z.to.20111007T161507Z.sigtar.gpg
  duplicity-new-signatures.20111007T161507Z.to.20111010T161511Z.sigtar.gpg
  duplicity-new-signatures.20111010T161511Z.to.20111011T161507Z.sigtar.gpg
  duplicity-new-signatures.20111011T161507Z.to.20111012T161510Z.sigtar.gpg
  duplicity-new-signatures.20111012T161510Z.to.20111013T161505Z.sigtar.gpg
  duplicity-new-signatures.20111013T161505Z.to.20111017T161506Z.sigtar.gpg
  duplicity-new-signatures.20111017T161506Z.to.20111018T161505Z.sigtar.gpg
  duplicity-new-signatures.20111018T161505Z.to.20111019T161506Z.sigtar.gpg
  duplicity-new-signatures.20111019T161506Z.to.20111020T161506Z.sigtar.gpg
  duplicity-new-signatures.20111020T161506Z.to.20111021T161511Z.sigtar.gpg
  duplicity-new-signatures.20111021T161511Z.to.20111025T161507Z.sigtar.gpg
  duplicity-new-signatures.20111025T161507Z.to.20111026T161510Z.sigtar.gpg
  duplicity-new-signatures.20111026T161510Z.to.20111027T161506Z.sigtar.gpg
  duplicity-new-signatures.20111027T161506Z.to.20111028T161511Z.sigtar.gpg
  duplicity-new-signatures.20111028T161511Z.to.20111104T161506Z.sigtar.gpg
  duplicity-new-signatures.20111104T161506Z.to.20111115T222417Z.sigtar.gpg
  Last full backup date: Wed Nov 16 12:16:14 2011
  Fatal Error: Backup source host has changed.
  Current hostname: 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa
  Previous hostname: matt-mmf-macbook.local
  
  Aborting because you may have accidentally tried to backup two different data sets to the same remote location, or using the same archive directory.  If this is not a mistake, use the --allow-source-mismatch switch to avoid seeing this message
  
  mlm@matt-mmf-macbook.local:~
  $ 
  </code></pre>
  
  <p>My backup.sh contains:</p>
  
  <pre><code>#! /bin/bash
  
  PATH=/usr/local/bin:/Library/Frameworks/Python.framework/Versions/2.6/bin:$PATH
  
  . ~/config/bash/awskeys.sh
  
  . $(type -p virtualenvwrapper.sh)
  workon duplicity
  
  ulimit -n 1024
  
  duplicity \
      --encrypt-key DEADBEEF \
      --include-globbing-filelist ~/config/bash/backup-include-$(hostname -s).txt \
      --exclude-globbing-filelist ~/config/bash/backup-exclude-$(hostname -s).txt \
      / \
      s3://s3.amazonaws.com/backup-$(hostname -s)/
  </code></pre>