I have created my docker image and container using the Dockerfile in this blog.
https://hackernoon.com/raspberry-pi-cluster-emulation-with-docker-compose-xo3l3tyw
I am able to ssh into the rpi and ifconfig returns the following status:
pi#raspberrypi:~ $ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
ether 52:54:00:12:34:56 txqueuelen 1000 (Ethernet)
RX packets 561 bytes 49862 (48.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 386 bytes 47311 (46.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 41 base 0x1000 dma 0xff
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1000 (Local Loopback)
RX packets 2 bytes 100 (100.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2 bytes 100 (100.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Now I want to be able to connect this to internet. As per docker docs, I tried to connect a running container to the internet using:
docker network connect multi-host-network 008796f5316a
It returns the error.
Error response from daemon: network multi-host-network not found.
How can I connect to the internet from inside the docker?
Edit:
The blog talks about running qemu on docker and installing a modified raspbian on top of that(for compatibility with qemu).
When I access the container using docker exec command,
docker exec -it testnode bash
ifconfig returns the following:
root#1f210520938c:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.17.0.2 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:ac:11:00:02 txqueuelen 0 (Ethernet)
RX packets 637 bytes 356778 (356.7 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 404 bytes 39482 (39.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
And the ifconfig command for pi returns the results as shown above.
So, ping google.com is working on the root# and not on pi#raspberry.
I need to connect the pi directly to the internet.
This error occurs because you haven't created a Docker network called multi-host-network. To create it, you may refer to Docker docs.
By default, all docker containers are connected to the default bridge network (the name matches driver type). As for docker-compose, bridge network with name docker-compose-directory-name_defaultwill be created, as described [here][2]. You can check it by runningdocker network inspect docker-compose-directory-name_defaultand find your container inContainers` section.
Since your container is already connected to the internet, it should have internet access without explicitly connecting it to a network.
If there is no internet connection, please try solutions proposed in this question. I would suggest starting with
sysctl -w net.ipv4.ip_forward=1 # both on host and container
sudo service docker restart # (or sudo systemctl restart docker) on host
The instructions you're following set up QEMU to use "user-mode networking". This is (sort of) like QEMU itself emulating a little NAT-router and private network that the VM lives behind. This in turn is inside the docker container and talking to whatever the docker container's networking setup is, so you have two layers here -- you'll want to be clear about this double-layer setup so you don't get confused about which of the two might be the source of any problems you have.
User-mode networking has some limitations: notably, ping doesn't work, and you can't connect from the outside into the VM except where you have specific port-forwarding set up (the instructions include a port-forward from host port 2222 to the VM's ssh port 22).
So you need to figure out whether you can live with user-mode networking's limits, and make sure that whatever testing you're doing is testing what you care about and not things you probably don't really care about like whether ping packets in particular work. If you don't want user-mode networking, you'll need to set up a QEMU tap (bridge) network backend, which is a lot more complicated but does let you make a QEMU VM truly visible as a machine on the host network.
Related
Please help with this
I have a windows laptop --> On this installed VM ware Tool --> On this I've Installed Linux OS
Installed docker and stopped firewalld service (then only docker service start)
If I run the docker run command as:
docker run **--network=host** -p 8080:8080 -d tomcat
Then only can access the URL: http://:8080 i.e http://192.168.0.108:8080 (It was IP of Linux VM) from the browser on windows system
If I run the docker command without using the --network=host option I'm not able to access the container application. for example, if running docker run -p 8080:8080 -d tomcat
how can I access all running containers from the windows system browser?
Do I need to add a route in the Linux OS (the one Installed in a VM ware Tool) or in the Windows one or change the network settings in VMWare configuration?
Docker container Ip start with 172.17.xx.xx series and my windows/LINUX OS was on 192.168.xx.xx series. do need to add any route?
MY network details:
[root#Docker_test ~]# ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
inet6 fe80::42:e8ff:fef2:7ed7 prefixlen 64 scopeid 0x20<link>
ether 02:42:e8:f2:7e:d7 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 500 bytes 23738 (23.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.108 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::20c:29ff:fee6:b685 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:e6:b6:85 txqueuelen 1000 (Ethernet)
RX packets 2310526 bytes 3211791978 (2.9 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 457745 bytes 45884268 (43.7 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root#Docker_test]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 100 0 0 ens33
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
192.168.0.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
Regards
Ram
I am having trouble setting up an internet to be shared on Beaglebone (BB) through the host (Mac running Big Sur OS).
When I do ifconfig on BB, I see two USB interfaces showing up (usb0, usb1) with designated IP addresses but I can't seem to ping to my host machine for instance to verify the internet connection. It says From 192.168.7.2 icmp_seq=1 Destination Host Unreachable
According to this link:
With the latest images, it should no longer be necessary to install drivers for your operating system to give you network-over-USB access to your Beagle. In case you are running an older image, an older operating system or need additional drivers for serial access to older boards, links to the old drivers are below.
usb0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.7.2 netmask 255.255.255.252 broadcast 192.168.7.3
inet6 fe80::e1c:57ff:fe00:c2c0 prefixlen 64 scopeid 0x20<link>
ether 0c:1c:57:00:c2:c0 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
usb1: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.6.2 netmask 255.255.255.0 broadcast 192.168.6.255
ether 0c:1c:57:00:c2:c4 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
I did download the latest image but for further verification, how do you verify the image being run i.e version or something that tells whether this matches the image version 10.3 as stated on the website?
On the host, following is the relevant interface for the USB. For the pings to go through, the netmask needs to be matched with that of the usb0?
en7: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=404<VLAN_MTU,CHANNEL_IO>
ether 0c:1c:57:00:c2:c3
inet6 fe80::d1:b3cb:50eb:72e1%en7 prefixlen 64 secured scopeid 0x14
inet 192.168.7.1 netmask 0xffffff00 broadcast 192.168.6.255
nd6 options=201<PERFORMNUD,DAD>
media: autoselect (none)
status: inactive
In the Network Settings of the host, I see it says Either the cable for BeagleBoneBlack is not plugged in or the device at the other end is not responding. That's weird because in the ifconfig output on the host, I do see en7 showing up which is referring to the USB connection to the BeagleBone
uname -a
This shows your kernel
cat /etc/dogtag
This shows your image
Are you using an Ethernet cable or are you trying to use a USB dongle for Wifi? If you are using Ethernet, it should be plug and play but you will need to use Chrome or Firefox.
I am not sure about the Big Sur OS but you can try beaglebone.local or 192.168.6.2 instead. This may prove useful when using ssh.
also...try this:
use a COM port or if there is no COM ports on Big Sur OS, get a
USB to TTL converter cable and get onto the board via serial...
This way, you can find your IP Address by ip addr.
Look for eth0 on the BBB and not usb(x).
I'm getting this message when running code in Alibaba Free Elastic IP:
OSError: [Errno 99] error while attempting to bind on address ('147.139.5.81', 31333): cannot assign requested address
Here is the code which is correctly working in Amazon EC2:'
ip = '147.139.5.81' #In Amazon EC2, ip will be different
start_server = websockets.serve(
hello, ip, 31333
)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()
ifconfig -a shows:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.31.173.211 netmask 255.255.240.0 broadcast 172.31.175.255
ether 00:16:3e:01:30:8e txqueuelen 1000 (Ethernet)
RX packets 473419 bytes 267646492 (267.6 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 309017 bytes 92824868 (92.8 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1000 (Local Loopback)
RX packets 72620 bytes 4035134 (4.0 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 72620 bytes 4035134 (4.0 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
% dig +short myip.opendns.com #resolver1.opendns.com shows:
147.139.5.81
What could be the problem? I've sshed to this VPS using ip: 147.139.5.81
You must be using a VPC network type ECS instance because inet of your ECS instance is a private IP. For VPC network type ECS instances, the public IP of the ECS instance is not visible inside the OS, hence you cannot bind it.
You can bind 0.0.0.0 and use security groups of ECS instance to allow/block traffic toward the ECS.
I have VPS is not Amazon. ip = '0.0.0.0' it works for me
I bought a Raspberry Pi yesterday and I am facing quite a large problem. I can't sudo apt-get update. I think this error comes from my dns because I am connected via ethernet (Physically). so the message it prints when I execute the command is that:
pi#raspberrypi:~ $ sudo apt-get update
Err:1 http://goddess-gate.com/archive.raspbian.org/raspbian jessie InRelease
Temporary failure resolving 'goddess-gate.com'
Err:2 http://archive.raspberrypi.org/debian stretch InRelease
Temporary failure resolving 'archive.raspberrypi.org'
Reading package lists... Done
W: Failed to fetch http://goddess-gate.com/archive.raspbian.org/raspbian/dists/jessie/InRelease Temporary failure resolving 'goddess-gate.com'
W: Failed to fetch http://archive.raspberrypi.org/debian/dists/stretch/InRelease Temporary failure resolving 'archive.raspberrypi.org'
W: Some index files failed to download. They have been ignored, or old ones used instead.
So to resolve this problem I have tried a few things:
- Changing the etc/apt/sources.list to a valid mirror of my country (france)
- Reinstalling Raspbian (1st try was with NOOBS) and now I installed Raspbian with the .img file
- Changing my /ect/resolv.conf and /etc/network/interfaces nameservers to these ip 8.8.8.8 8.8.4.4
Nothing worked... I am really stucked, there is something elese, I can't browse any website with Chromium but I have internet connexion because I can pip install python modules... here is the Chromium message:
'This site can't be reached' ERR_NAME_RESOLUTION_FAILED
Other things, my inet ip is not valid, usally it should start with 192.168 but here it is 168.254.241.6 ... here is my if config:
pi#raspberrypi:~ $ ifconfig
enxb827ebaf69fc: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 169.254.241.6 netmask 255.255.0.0 broadcast 169.254.255.255
inet6 fe80::5d8b:1a8c:c520:c339 prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:af:69:fc txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 995 bytes 61042 (59.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 806 bytes 77318 (75.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 806 bytes 77318 (75.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether b8:27:eb:fa:3c:a9 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Type following at the command line in order to edit resolv.conf which is the linux configuration file where domain-name to IP mapping is stored for the purpose of DNS resolution.
sudo nano /etc/resolv.conf
then add these 2 lines:
nameserver 8.8.8.8
nameserver 8.8.4.4
hope it will help ...
The ip-adress range 169.254.0.0 to 169.254.255.255 is used by zeroconf.
Probably there is no active DHCP server in the LAN. Mostly the router is also a DHCP server.
You also have no public IPv6 address. But this could also come from a IPv4 only internet connection.
Try to configure the interface completly manual with corrected ip-address. When there should be an active DHCP server, try to fix it. Sometimes a reboot helps.
You can show your gateway with "ip r". It should be the address of the router.
Important is that the ip-address of the Pi is in the same subnet as the gateway.
sudo nano /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
I connected Raspberry Pi Directly with an Ethernet Cable.
it work.
I am trying to install Jupyter inside CentOS 7 VM (that I already had) so I can access it via port 8888 at my host Mac laptop. However, I cannot figure out the networking piece.
I am changing the IP address to 200.100.x.x for convenience
From Host Machine
I have 2 adapters for that CentOS VM
$ ifconfig gives me this (I believe those are the same):
vmnet1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 00:50:56:c0:00:01
inet 200.100.42.1 netmask 0xffffff00 broadcast 200.100.42.255
vmnet8: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 00:50:56:c0:00:08
inet 200.100.40.1 netmask 0xffffff00 broadcast 200.100.40.255
From within CentOS
[root#localhost ~]# ifconfig
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 200.100.40.145 netmask 255.255.255.0 broadcast 200.100.40.255
inet6 fe80::20c:29ff:febf:4878 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:bf:48:78 txqueuelen 1000 (Ethernet)
RX packets 645 bytes 97963 (95.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 215 bytes 24854 (24.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eno33554984: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 200.100.42.128 netmask 255.255.255.0 broadcast 200.100.42.255
inet6 fe80::250:56ff:fe3d:7210 prefixlen 64 scopeid 0x20<link>
ether 00:50:56:3d:72:10 txqueuelen 1000 (Ethernet)
RX packets 18 bytes 1884 (1.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 45 bytes 6130 (5.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 220 bytes 50398 (49.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 220 bytes 50398 (49.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
My tests
I pinged the following IP addresses from my host machine and they all worked:
200.100.42.128
200.100.40.145
200.100.42.1
200.100.40.1
That means there is networking connectivity into the VM. Correct?
When I do jupyter notebook, I could access http://localhost:8888/tree inside the VM but I cannot go there using any IP address from my host OS on the Macbook.
I have restarted my VM many times.
Questions
Is it because of port blocking / not forwarding (8888) or something and if so, how to fix it?
Did I setup the networking incorrectly? Is there something else I need to do inside CentOS? I read this blog here http://twiki.org/cgi-bin/view/Blog/BlogEntry201310x2 and I don't see eth0 at all.
The problem is Jupyter picked 127.0.0.0 or localhost by default. If you have the adapter with other IP addresses, it won't work.
You need to change the IP of Jupyter inside the VM
http://jupyter-notebook.readthedocs.org/en/latest/config.html
$ jupyter notebook --generate-config
Edit it:
vi /root/.jupyter/jupyter_notebook_config.py
Then change:
c.Notebookapp.ip = '0.0.0.0'
Restart jupyter notebook and should be good to go.
Make sure firewall is off or open for port 8888 as well.