{"action":"created","issue":{"url":"https://api.github.com/repos/home-assistant/home-assistant/issues/14107","repository_url":"https://api.github.com/repos/home-assistant/home-assistant","labels_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/14107/labels{/name}","comments_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/14107/comments","events_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/14107/events","html_url":"https://github.com/home-assistant/home-assistant/issues/14107","id":318247367,"number":14107,"title":"homeassistant.util.get_local_ip() returns outbound IP address on OS X when VPN is present","user":{"login":"diplix","id":4541494,"avatar_url":"https://avatars0.githubusercontent.com/u/4541494?v=4","gravatar_id":"","url":"https://api.github.com/users/diplix","html_url":"https://github.com/diplix","followers_url":"https://api.github.com/users/diplix/followers","following_url":"https://api.github.com/users/diplix/following{/other_user}","gists_url":"https://api.github.com/users/diplix/gists{/gist_id}","starred_url":"https://api.github.com/users/diplix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diplix/subscriptions","organizations_url":"https://api.github.com/users/diplix/orgs","repos_url":"https://api.github.com/users/diplix/repos","events_url":"https://api.github.com/users/diplix/events{/privacy}","received_events_url":"https://api.github.com/users/diplix/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-27T01:22:09Z","updated_at":"2018-04-28T20:03:01Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"**Home Assistant release with the issue:**\r\n0.68.0b1\r\n\r\n**Operating environment (Hass.io/Docker/Windows/etc.):**\r\nosx 10.11.6, python 3.6.5\r\n\r\n\r\n**Component/platform:**\r\nhomeassistant.util.get_local_ip()\r\nhttps://github.com/home-assistant/home-assistant/blob/3442b6741d969def6b97b99d8bc2c978252efed0/homeassistant/util/__init__.py#L93\r\n\r\n\r\n**Description of problem:**\r\nwhen os x is connected to a VPN, `homeassistant.util.get_local_ip()` returns the outbound IP address of the VPN instead of the local IP address\r\n\r\n\r\n**Traceback (if applicable):**\r\nthis is what i get when i enter the commands from `homeassistant.util.get_local_ip()` into the python3 console **while not connected** to a VPN\r\n```\r\n>>> import socket\r\n>>> socket.gethostbyname(socket.gethostname())\r\n'192.168.1.xx'\r\n>>> sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\r\n>>> sock.connect(('8.8.8.8', 80))\r\n>>> sock.getsockname()\r\n('192.168.1.xx', 53xxx)\r\n```\r\nif i am connected to a VPN, this is the result:\r\n```\r\n>>> import socket\r\n>>> socket.gethostbyname(socket.gethostname())\r\n'192.168.1.xx'\r\n>>> sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\r\n>>> sock.connect(('8.8.8.8', 80))\r\n>>> sock.getsockname()\r\n('172.16.xx.x', 62xxx)\r\n```\r\n\r\n**Additional information:**\r\nit affects the startup of the homekit component (https://github.com/home-assistant/home-assistant/issues/14077), but probably also other components."},"comment":{"url":"https://api.github.com/repos/home-assistant/home-assistant/issues/comments/385202036","html_url":"https://github.com/home-assistant/home-assistant/issues/14107#issuecomment-385202036","issue_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/14107","id":385202036,"user":{"login":"dgomes","id":137684,"avatar_url":"https://avatars2.githubusercontent.com/u/137684?v=4","gravatar_id":"","url":"https://api.github.com/users/dgomes","html_url":"https://github.com/dgomes","followers_url":"https://api.github.com/users/dgomes/followers","following_url":"https://api.github.com/users/dgomes/following{/other_user}","gists_url":"https://api.github.com/users/dgomes/gists{/gist_id}","starred_url":"https://api.github.com/users/dgomes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgomes/subscriptions","organizations_url":"https://api.github.com/users/dgomes/orgs","repos_url":"https://api.github.com/users/dgomes/repos","events_url":"https://api.github.com/users/dgomes/events{/privacy}","received_events_url":"https://api.github.com/users/dgomes/received_events","type":"User","site_admin":false},"created_at":"2018-04-28T20:03:01Z","updated_at":"2018-04-28T20:03:01Z","author_association":"CONTRIBUTOR","body":"`homeassistant.util.get_local_ip` will return the local_ip of the default interface. When you are connected to a VPN, the VPN becomes your default interface and therefore local_ip corresponds to the VPN IP address.\r\n\r\nThis issue will happen in any other OS, and it will affect any component that relies in using a local (LAN) IP address for communication with local devices.\r\n\r\nI've done some research and could not find any clean solution to this besides adding an optional configuration option where user defines either the default IP or default network interface. \r\n\r\nI can work on fix for this but I ask @balloob for validation before proceeding."}}
{"actor":{"display_login":"dgomes"}}