Cannot console into new created Openstack instance - python

I installed Openstack Mitaka using Devstack on an Ubuntu virtual machine in Virtualbox. After installation, things seemed to be alright. Then I start a new Cirros instance, and it succeeded. However, when I tried to console this instance using ip nets exec xxxxxx ssh cirros#172.24.4.3 it returned ssh: connect to host 172.24.4.3 port 22: no route to host. Result for ip nets exec xxxxxx ping 172.24.4.3 is Destination Host Unreachable.
I checked the ip netsh, the result was like:
qrouter-xxxxxxx
qdhcp-xxxxxx
If I use ip nets exec qrouter-xxxxxx ip addr show , the result includes:
127.0.0.1, 10.0.0.1, 172.24.4.2, and another item with no ip address.
If I user ip nets exec qdhcp-xxxxxx ip addr show, the result includes:
127.0.0.1, 10.0.0.2
The instance is connected to public network as shown in Openstack Dashboard. And if I try to connect to the console in WebUI - Dashboard/Compute/Instances/xxxx/Console, there was an error shown on the page, saying:
Error response. Error code 404.Message: File not found.
Error code explanation: 404 = Nothing matches the given URI.
So how can I console into the instances created by Openstack? Is it something to do with the network configuration?
Thank you for your answers in advance.

Related

socket.gethostbyaddr() on a linux system and local network

I have a django application using this function, i'm trying to get the computer name of the ip address accessing my application. I'm doing this by using django-ipware to get the client's ip address, this part is working fine. Then i'm using socket.gethostbyaddr() to get the client's computer name, this works fine on my windows development machine.
def get_comp_name(request):
client_ip = get_client_ip(request)
try:
comp_name = socket.gethostbyaddr(client_ip[0])[0]
except socket.herror:
comp_name = ''
When i tried to deploy to a centOS 7 machine, I get the following error when executing socket.gethostbyaddr() on local network ip addresses.
socket.herror: [Errno 1] Unknown host
I can ping local ip addresses without issue. Am I missing a configuration on my centOS 7 machine?
Your DNS server needs to have an entry for this to work. Check /etc/resolv.conf if the DNS server IP is correct, check if DNS server is reachable from the CentOS node and finally, check if the entry in the DNS server is correct.

Host command and ifconfig giving different ips

I am using server(server_name.corp.com) inside a corporate company. On the server i am running a flask server to listen on 0.0.0.0:5000.
servers are not exposed to outside world but accessible via vpns.
Now when i run host server_name.corp.com in the box i get some ip1(10.*.*.*)
When i run ifconfig in the box it gives me ip2(10.*.*.*).
Also if i run ping server_name.corp.com in same box i get ip2.
Also i can ssh into server with ip1 not ip2
I am able to access the flask server at ip1:5000 but not on ip2:5000.
I am not into networking so fully confused on why there are 2 different ips and why i can access ip1:5000 from browser not ip2:5000.
Also what is equivalent of host command in python ( how to get ip1 from python. I am using socktet.gethostbyname(server_name.corp.com) which gives me ip2)
As far as I can tell, you have some kind of routing configured that allows external connections to the server by hostname (or ip1), but it does not allow connection by ip2. And there is nothing unusual in this. Probably, the system administrator can advise why it is done just like this. Assuming that there are no assynchronous network routes, the following function can help to determine public ip of server:
import socket
def get_ip():
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.connect(("8.8.8.8", 80))
local_address = sock.getsockname()
sock.close()
local_address = local_address[0]
except OSError:
local_address = socket.gethostbyname(socket.gethostname())
return local_address
Not quite clear about the network status by your statements, I can only tell that if you want to get ip1 by python, you could use standard lib subprocess, which usually be used to execute os command. (See subprocess.Popen)

Accessing locally hosted site through public ip

I have setup a django app on a apache server in a VM. The site is accessible when I use the apache server IP in the VM browser. It is also accessible from the host browser through it's local IP. But, I cannot access it through the public IP over the internet. I get a site can't be reached error
I have set up port forwarding such that:
1. All router requests on port 80 are forwarded to local IP
2. All requests to local IP on port 80 are forwarded to the VM
I checked if my port is open on my public ip using http://www.yougetsignal.com/tools/open-ports/
It says that my port is closed. Same results with http://canyouseeme.org/
I am able to ping my public ip successfully.
I have tried disabling all my firewalls but this has not helped. Please tell me if you need any code to be shared. Any help would be appreciated.
Edit:
Extra information: It seems my router's WAN IP is different from my public IP. I can access the site through the WAN IP from the host browser but again, I am not able to access it over the internet.
You just need a public IP address or push your application to the hosting (like this for example https://gpdhost.com/offers/).
ToDo: learn DMZ, learn WAN-LAN packet forwarding process, learn TCP/IP routing, learn public and private IP addressing and learn NAT.
Description: http/https connection conversation (client-outside vs your-server):
1) client: in browser write: sharan-site/;
2) get IP by DNS name from public servers? But public servers don't know your ip:dns-name pair...
=> fail
next example:
1) client: 192.168.1.1/ - where IP is your server
2) so where is it?
=> nowhere, it is private IP address! Fail...
Desc+: Port forwarding it is NAT feature. Your router must have public IP address, and you must setup DMZ like scheme in your local network: https://www.cisco.com/c/en/us/support/docs/ip/network-address-translation-nat/13772-12.html
Desc++: that sites check outside tcp/80 port on your router and PC, and it's open, no questions... But this no help for your task.

Python 2.7 [Errno 113] No route to host

I have 2 computers on the same LAN. The first PC has an ip address 192.168.178.30, the other PC has an ip address 192.168.178.26.
Ping, traceroute, telnet, ssh, everything works between the two PCs. Both PCs run the same OS - CentOS 7 and both PCs have the same python version 2.7.5 (checked with the python -V command).
I copied simple python code from a computer networking book.
client.py
from socket import *
serverName = '192.168.178.30'
serverPort = 12000
clientSocket = socket(AF_INET, SOCK_STREAM)
clientSocket.connect((serverName,serverPort))
sentence = raw_input('Input lowercase sentence: ')
clientSocket.send(sentence)
modifiedSentence = clientSocket.recv(1024)
print 'From Server:', modifiedSentence
clientSocket.close()
server.py
from socket import *
serverPort = 12000
serverSocket = socket(AF_INET,SOCK_STREAM)
serverSocket.bind(('192.168.178.30',serverPort))
serverSocket.listen(5)
print 'The server is ready to receive'
while 1:
connectionSocket, addr = serverSocket.accept()
sentence = connectionSocket.recv(1024)
capitalizedSentence = sentence.upper()
connectionSocket.send(capitalizedSentence)
connectionSocket.close()
The code works when it is ran on the same PC (where the server is listening on localhost).
When I run the client code on one PC and the server code on the other PC I get this error on the client side.
Traceback (most recent call last):
File "client.py", line 5, in <module>
clientSocket.connect((serverName,serverPort))
File "/usr/lib64/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 113] No route to host
Can someone help?
Check the firewall (on the server).
I stopped the firewall like Messa suggested and now it works.
service firewalld stop
I still don't understand what the problem was. I even tried using different distributions. Do all distributions have strict firewalls or something. For example Ubuntu to Ubuntu, Ubuntu to CentOS, CentOS to Ubuntu I still had the same problem (error).
~]#supervisord
Error: No config file found at default paths (/usr/etc/supervisord.conf, /usr/supervisord.conf, supervisord.conf, etc/supervisord.conf, /etc/supervisord.conf); use the -c option to specify a config file at a different path
For help, use /usr/bin/supervisord -h
You should use
ln -s /etc/supervisor/supervisord.conf /usr/etc/supervisord.conf
None of this stuff worked for me. I just connected both the devices to the same WiFi network and my program worked!
You can also get this same error ([Errno 113] No route to host) if you are trying to connect 2 devices on the same network. the error can be fixed by double checking to make sure both devices are connected to the mqtt_client or whatever you are using. as soon as I connected the device I was trying to talk to everything worked as to be expected.I would also check to make sure the right IP_Address is being passed
We had this problem. I am putting our findings here in case anyone else stumbles across this question like I did.
Our configuration:
Host A: IP address 192.168.0.1, netmask 255.255.255.0
Host B: IP address 192.168.1.1, netmask 255.255.254.0
Neither host has a default gateway.
We are connecting from Host B to Host A. (That is not a typo.) The connect call succeeds, but when we try to send data, we get errno 113 aka. EHOSTUNREACH aka. "No route to host".
The fix, of course, was to change the subnet on Host A to match Host B.
We were surprised to see this error on a connection within the same subnet / same LAN. And we were surprised that connect succeeded followed by send failing. And we were surprised to see this error on Host B even though the network configuration on Host B itself was fine.
Somehow, the incorrect subnet on Host A caused this error on Host B...
...and just like that, today I learned about ICMP "destination unreachable" messages.

Flask server not visible from my public ip address

I'm trying to run a flask server on my desktop PC that is publicly available on the internet. I've done the following:
Set up a static IP address: 192.168.1.11 (http://i.imgur.com/Z9GEBYV.png)
Forwarded port 33 on my router to my static ip address (http://i.imgur.com/KGNQ2Qk.png)
Setup flask to use my static ip and port: 33
I'm using the following code as a test webserver
from flask import Flask, request, redirect
app = Flask(__name__)
#app.route("/")
def hello_world():
return "Test 123 "
if __name__ == "__main__":
app.run(host="0.0.0.0", port="33")
When I open my browser to: http://192.168.1.11:33/ the page displays properly, I see "Test 123"
My problem comes when trying to connect to my webserver from my public ip address When I open my browser to http://xx.xxx.xxx.xx:30 (my ip address) all I see is "this site can't be reached, xx.xxx.xxx.xx refused to connect"
I've looked up all the stack overflow answers, I've done the following:
Turned off windows firewall
Changed host from "192.168.1.11" to "0.0.0.0"
Tried a different port
screenshot of code running and error shown: http://i.imgur.com/a05GvEs.png
My question is: What do I need to do to make my flask server visible from my public ip address?
Do you have DHCP activated on your router?
If yes do you see your host as 192.168.1.11 in there?
You have to use '0.0.0.0' on host, that tells Flask to listen on all addresses.
Try specifying the port with quotes as app.run(host="0.0.0.0", port="33")
change it to app.run(host= '0.0.0.0', port="33") to run on your machines IP address.
Documented on the Flask site under "Externally Visible Server" on the Quickstart page:
http://flask.pocoo.org/docs/0.10/quickstart/#a-minimal-application
Add port forwarding to port 33 in your router
Port forwarding explained here
http://www.howtogeek.com/66214/how-to-forward-ports-on-your-router/
You must give the public ip address/LAN ip address as an argument to app.run method.
When you don't provide host argument, it works fine with http://localhost:8888/ and http://127.0.0.1:888/, but not to access outside the system where you are running the REST services
Following is the example.
app.run(host="192.168.0.29",debug=True, port=8888)
You must try and use the same ip of the development server. Thus, for instance, if the dev server is running on a PC with the address 192.168.1.11
and port 33, other clients must point at the same address: 192.168.1.11:33.
As far as my small experience, it works with the debugger disabled, but I did not check if this is an essential prerequisite.
good luck
Every webservice should be run from different port address.Single service is running from a single port.

Categories