element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum Hostname issue.
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 13 replies
  • Subscribers 665 subscribers
  • Views 2337 views
  • Users 0 members are here
  • wifi
  • cmdrobot
  • help
  • tplink
  • helpme
  • element14
  • raspi
  • wlan
  • network
  • raspberry_pi
  • help!!!!
  • wlan0
  • prototyping
  • raspberrypi
  • hostname
  • rpi
  • wireless
Related

Hostname issue.

wallarug
wallarug over 12 years ago

I have been trying to get this to work for days but have been unsuccessful.

 

I posted here:  http://www.raspberrypi.org/phpBB3/viewtopic.php?f=27&t=10071&p=230854#p230854 but got no responce (which I expected).

 

Most of my details are on there (from last night)

 

I started with a fresh image today and still no luck.

 

What I am trying to do is, using the python command: "socket.gethostbyaddr('10.0.128.2')"

... Check what Raspberry Pi I have connected to and then use this information to decide what to do next.

 

Currently, I have been able to 'hit' every computer on my network with this command except for the raspberry pi.  This is very frustrating.  All the websites that I have read seem to say that it should just work.  I know someone who has a raspberry pi and this seems to work for him.

 

I have set-up a dummy network (which is used above) to attempt to get everything to work.  So far I have had no luck pinging the hostname 'raspberrypi' or 'CMDoverwatch'. 

 

What is really confusing is that the router has the CORRECT hostname but the computers on the network can't use it.

 

I need some help to find out why and then fix it.

 

Below are some of the router setting details:

 

 

DHCP Settings

DHCP Server:Disable Enable
Start IP Address:10.0.128.100
End IP Address:10.0.128.199
Address Lease Time:120 minutes (1~2880 minutes, the default value is 120)
Default Gateway:10.0.128.1 (optional)
Default Domain: (optional)
Primary DNS:10.0.128.1 (optional)
Secondary DNS:8.8.8.8 (optional)

 

Client LIST:

 

IDClient NameMAC AddressAssigned IPLease Time
1raspberrypiB8-27-EB-A0-56-1E10.0.128.10001:58:14
2PC-private10-9A-DD-BC-8F-D210.0.128.10101:45:07

 

 

 

Wireless Settings

SSID:CMDnetwork-base-station
Region:AlbaniaAlgeriaArgentinaArmeniaAustraliaAustriaAzerbaijanBahrainBelarusBelgiumBelizeBolviaBrazilBrunei DarussalamBulgariaCanadaChileChinaColombiaCosta RicaCroatiaCyprusCzech RepublicDenmarkDominican RepublicEcuadorEgyptEl SalvadorEstoniaFinlandFranceGeorgiaGermanyGreeceGuatemalaHondurasHong KongHungaryIcelandIndiaIndonesiaIranIrelandIsraelItalyJapanJapan1Japan2Japan3Japan4Japan5Japan6JordanKazakhstanNorth KoreaKorea RepublicKorea Republic2KuwaitLatviaLebanonLiechtensteinLithuaniaLuxembourgMacauMacedoniaMalaysiaMaltaMexicoMonacoMoroccoNetherlandsNew ZealandNorwayOmanPakistanPanamaPeruPhilippinesPolandPortugalPuerto RicoQatarRomaniaRussiaSaudi ArabiaSingaporeSlovak RepublicSloveniaSouth AfricaSpainSwedenSwitzerlandSyriaTaiwanThailandTrinidad & TobagoTunisiaTurkeyUkraineUnited Arab EmiratesUnited KingdomUnited StatesUruguayUzbekistanVenezuelaViet NamYemenZimbabwe
Warning:Ensure you select a correct country to conform local law.
Incorrect settings may cause interference.

Channel: 12345678910111213
Mode:11Mbps (802.11b)54Mbps (802.11g)

Enable Wireless Router Radio
Enable SSID Broadcast
Enable Bridges

Enable Wireless Security
Security Type:WEP WPA/WPA2WPA-PSK/WPA2-PSK
Security Option: AutomaticWPA-PSKWPA2-PSK
Encryption:AutomaticTKIPAES
PSK Passphrase:doesitreallymatter???
(The Passphrase is between 8 and 63 characters long)
Group Key Update Period:86400(in second, minimum is 30, 0 means no update)

 

LAN

MAC Address:

00-23-CD-C7-12-32

IP Address:
Subnet Mask:      255.255.255.0      255.255.0.0

 

 

That should be all the settings that have been enabled or helpful to people trying to help me.  All the raspberry pi settings are on the link above.

 

Just for those hackers out there, this is not connect to the internet and does not have ANY information on it. image

 

Thanks for anyone who can solve this issue.

  • Sign in to reply
  • Cancel
  • Former Member
    Former Member over 12 years ago

    Fergus,

     

    Where are you running the socket.gethostbyaddr('10.0.128.2') from ?  The Pi itself, another different Pi, a Windows machine ?

     

    There are many different ways of resolving a hostname, DNS, mDNS, WINS, NetBIOS broadcast, /etc/hosts static entries, NIS/YP etc.  You'd need to make sure that the Pi and the other systems are all using the same method and that the method you pick actually works for local names.

     

    What happens behind the gethostbyaddr call is often complex. On a linux machine you can look in /etc/nsswitch.conf for a line starting with hosts: everything after that on the same line are different places that will be queried for a name. However it doesn't end there. Say you have:

     

    hosts:     files     dns     winbind

     

    files says to look in /etc/hosts

    dns says to query a dns server as defined in /etc/resolv.conf, perhaps with a search order defined in the file

    winbind is a daemon (part of samba) that can lookup name details from windows and would need configured in /etc/smb.conf

     

    as the available methods are plugins to glibc there could be many more available (ls /lib/libnss*.so on your Pi for a list of possible methods).

     

    You could also be missing a service like avahi on the linux side or bonjour on windows that would help solve your problem. As someone on the other forum points out, maybe your friends router is helping out somewhere, have you tried your RPi on his network ?  Or his on your network ?

     

    If you're interested in digging into the details, get a copy of wireshark and do a packet trace of what happens when your script runs the gethostbyaddr call. Knowing how the lookup is being done may well help point you in the right direction.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • wallarug
    wallarug over 12 years ago in reply to Former Member

    I have decided to add a check into my python script without using hostnames as that was tempramental.

     

    Here is an extract:

     

    try:

        robot_detection = raw_input("Which Robot do you wish to control? (overwatch = '1' / recon = '2' / butterfly = '3'): ")

       

        while robot_detection != '1' or robot_detection != '2' or robot_detection == '3':

            if robot_detection == '3':

                print 'Support for CMDbutterfly will be coming in a later release.  Please select another option from the ones provided. '

            elif robot_detection == '1' or robot_detection == '2':

                break

            else:

                print 'Enter a valid value! '

            robot_detection = raw_input("Which Robot do you wish to control? (overwatch = '1' / recon = '2' / butterfly = '3'): ")

           

           

        if robot_detection == '1':

            robot_detection = 'CMDoverwatch'

        elif robot_detection == '2':

            robot_detection = 'CMDrecon'

        print " "

        print  "Controlling " +robot_detection

        print " "

    This way you don't need to check because the user has told it.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to wallarug

    On the Pi:

     

    sudo apt-get avahi-daemon

     

    Then any other Linux box running avahi or Apple computer running Bonjour (which I think it includes as its zeroconfig) or if you install Bonjour on Windows, they should all be able to find your Raspberry Pi by the name CMDoverwatch.local, at least for things like ping and ssh.  If you want other services available, you have to figure out what to put in /etc/avahi/services.

     

    [code]efflandt@XPS8100-1204:~$ ping -c4 raspberrypi.local

    PING raspberrypi.local (192.168.1.106) 56(84) bytes of data.

    64 bytes from raspberrypi.local (192.168.1.106): icmp_req=1 ttl=64 time=10.7 ms

    64 bytes from raspberrypi.local (192.168.1.106): icmp_req=2 ttl=64 time=20.3 ms

    64 bytes from raspberrypi.local (192.168.1.106): icmp_req=3 ttl=64 time=45.2 ms

    64 bytes from raspberrypi.local (192.168.1.106): icmp_req=4 ttl=64 time=65.4 ms

     

    --- raspberrypi.local ping statistics ---

    4 packets transmitted, 4 received, 0% packet loss, time 3001ms

    rtt min/avg/max/mdev = 10.710/35.441/65.435/21.418 ms

    efflandt@XPS8100-1204:~$ ssh raspberrypi.local

    Linux raspberrypi 3.2.27+ #250 PREEMPT Thu Oct 18 19:03:02 BST 2012 armv6l

     

    The programs included with the Debian GNU/Linux system are free software;

    the exact distribution terms for each program are described in the

    individual files in /usr/share/doc/*/copyright.

     

    Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent

    permitted by applicable law.

    Last login: Sat Dec 15 01:09:23 2012 from xps8100-1204.local[/code]

     

    And avahi name resolution works as well for a python script sending its status to an Ubuntu box to monitor how long a battery pack lasts (maybe not optimum code, but I am new at python, and not sure if code tags work here to show indents).  I did not need anything in /etc/avahi/services for this, just a python script constantly listening on this port on the server:

     

    [code]#!/usr/bin/python

     

    # client to send uptime to network monitor

    import socket

    import os

    import time

    import math

     

    # hostname.local is if pimon.py server is running avahi or Bonjour

    HOST = 'xps8100-1204.local'  # remote IP resolvable hostname

    PORT = 53142                 # same port used by server

     

    rfPath = "/proc/uptime"

     

    try:

        while 1:

            r = open(rfPath, 'r')

            uptime = r.readline()

            r.close()

     

            # split out first number in line as float

            uptime = float((uptime.split())[0])

     

            # typical Linux like date

            current_time = time.strftime("%a %b %d %X %Z %Y", time.localtime())

     

            # from total sec, figure strings for hrs and 2 digit min, sec

            sec, min = math.modf(uptime / 60)

            #s = str(int(round(sec * 60,0))).zfill(2)

            min, hr = math.modf(min / 60)

            m = str(int(min * 60)).zfill(2)

            if hr > 23:

                hr, days = math.modf(hr / 24)

                h = str(int(hr * 24)).zfill(1)

                d = str(int(days))

                if days > 1 : day = 'days'

                else: day = 'day'

                output = "{} up {} {}, {}:{} hrs".format(current_time, d, day, h, m)

     

            else:

                h = str(int(hr)).zfill(1)

                output = "{} up {}:{} hrs".format(current_time, h, m)

     

            # send data and print confirmation response

            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

            s.connect((HOST, PORT))

            s.sendall(output)

            data = s.recv(1024)

            s.close()

            print 'Received', repr(data)

            # sleep: 60 = 1 min, 300 = 5 min, 900 = 15 min, 1800 = 30 min, 3600 = 1 hr

            try:

                time.sleep(300)

            except KeyboardInterrupt:

                break

     

        # loop until Ctrl+C

    except KeyboardInterrupt:

        pass[/code]

     

    Report on receiving end so far from Pi on battery pack:

     

    Connected by ('192.168.1.106', 60677)

    Sat Dec 15 07:40:51 CST 2012 up 7:27 hrs

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago

    Well, I  have no answer but I need to learn about this stuff, so I have a question ....

     

    If your router is set to 192.168.1.1, with a subnet mask of 255.255.255.255.0 , why would you put your peripheral devices on a different subnet (10.0.128.100)?

    Would you expect to be able to ping them?

    This is a *genuine* question from a relative novice.

    --G

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • wallarug
    wallarug over 12 years ago in reply to Former Member

    I think you might be confused.

     

    I wanted to have a portable network set-up using the 10.0.128.100 IP address.

     

    My Personal Home network uses 192.168.*.*  (removed numbers)

     

    I am talking about two network situations where the devices are in separate situations.

     

     

    About your question:

     

    Would you expect to be able to ping them?

    Yes.  Provided you have put the same subnet mask on both devices.  I have seen this done on Corperate networks where they use an IP address for wireless devices and LAN devices. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • mcb1
    mcb1 over 12 years ago in reply to wallarug

    Cian

    I think you'll find they add a route to allow the different IP address to work, or they use NAT (Network Address Translation) which is effectively what your broadband router does.

    This may be part of the switch, or within the devices protocols.

     

    Normally you will have a gateway address, where the device heads if its not an address on the local LAN.

    For grahame's example there are 254 address's available, so anything that is 192.168.1. x will be treated as Local, and anything else heads out the gateway and is resolved elsewhere.

     

    If I understand correctly you have a portable network that is attached onto your home network.

    Have you tried changing the Gateway address to the 192.168.*.* (pick something that doesn't clash).

    This would then mean that anything not intended to be local (ie 10.0.128. x) will go out the gateway which should be your local lan.

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • GreenYamo
    GreenYamo over 12 years ago in reply to wallarug

    Cian,

    You need to bridge the two networks together, both the 192 and 10 networks are reserved for internal networking. These will be the internal addresses on your own network, not the outward facing IP assigned by your ISP.

    Putting the same netmask will not cause them to be linked, as Mark indicates this is only in reference to the number of ip address available on that subnet. See below, I think it will give you some pointers.

    http://serverfault.com/questions/198419/how-to-bridge-networks-192-168-191-0-24-and-10-9-0-0-16

    Steve

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to GreenYamo

    I wasn't confused Cian, so much as curious. Thanks for explaining about your two networks. The comments above seem to be well in line with my own humble thinking, and will hopefully help you reach your goal.

    --G

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to Former Member

    P.S.

     

    Since you know the IPs on your alternative network -- I imagine that you use Address Reservation or no DHCP -- it should be very simple to access them  that way. Interested to know the advantage(s) of calling them by name (lots to learn, here).

    --G

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to Former Member

    I was curious, and cautiously so, to know what would happen if one sends an IP request 'intended' for local receipt out onto the internet, so I did a whois on    10.0.128.100   and got this....

     

    NetRange:       10.0.0.0 - 10.255.255.255

    CIDR:           10.0.0.0/8

    OriginAS:      

    NetName:        PRIVATE-ADDRESS-ABLK-RFC1918-IANA-RESERVED

    NetHandle:      NET-10-0-0-0-1

    Parent:        

    NetType:        IANA Special Use

    RegDate:       

    Updated:        2011-04-12

    Ref:            http://whois.arin.net/rest/net/NET-10-0-0-0-1

     

    OrgName:        Internet Assigned Numbers Authority

    OrgId:          IANA

    Address:        12025 Waterfront Drive

    Address:        Suite 300

    City:           Los Angeles

    StateProv:      CA

    PostalCode:     90292

    Country:        US

    RegDate:       

    Updated:        2012-08-31

     

    I suppose it doesn't matter much, and they might blame the Albanians anyway, according to your info.

    --G

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube