1
Windows 컴퓨터의 netbios 이름을 반환하는 데 socket.gethostbyaddr을 사용하는 데 문제가 있습니다. 창에이 내가Linux의 Python에서 socket.gethostbyaddr을 사용하여 Windows 컴퓨터의 netbios 이름을 반환하는 방법
Python 3.2.3 (default, Feb 27 2014, 21:31:18)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> socket.gethostbyaddr("10.10.1.22")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
socket.herror: [Errno 1] Unknown host
>>>
를 얻을 나는 리눅스 시스템에서 winbind를 설치 그래서 내가 지금의 NetBIOS 이름을 사용할 수 있습니다 /etc/nsswitch.conf 파일 수정 한 내 리눅스 시스템에서
Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:19:30) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> socket.gethostbyaddr("10.10.1.22")
('ZUNIT1', [], ['10.10.1.22'])
>>>
을 반환 netbios 이름을 사용하여 장치를 ping하는 것과 같은 것들.
[email protected]:~$ ping ZUNIT1
PING ZUNIT1 (10.10.1.22) 56(84) bytes of data.
64 bytes from 10.10.1.22: icmp_req=1 ttl=128 time=0.461 ms
64 bytes from 10.10.1.22: icmp_req=2 ttl=128 time=0.371 ms
^C
--- ZUNIT1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1006ms
rtt min/avg/max/mdev = 0.371/0.416/0.461/0.045 ms
[email protected]:~$
누구든지 파이썬이 socket.gethostbyaddr 메소드에서 netbios 이름을 반환하도록하려면 어떻게해야합니까?
@ user590028 용으로 편집하면 gethostbyname이 예상대로 작동합니다.
Python 3.2.3 (default, Feb 27 2014, 21:31:18)
[GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> socket.gethostbyname("ZUNIT1")
'10.10.1.22'
>>>
입력 한 ping은 정방향 해상도를 보여줍니다. socket.gethostbyname ('ZUNIT1')이 밝혀내는 것을 보여줄 수 있습니까? – user590028
samba/libnss-winbind를 설치하고 http://superuser.com/questions/670714/setup-netbios-client-in-ubuntu-13-10과 같은 다양한 구성을 설정합니다 (특히/etc/nsswitch). conf 구성을 사용하고 smb.conf가 도메인에 구성되어 있는지 확인하십시오. – nos
@ User590028 gethostbyname이 올바르게 작동합니다 (문제의 업데이트 참조). – Alex