How to go from geth in WSL to vEthernet adaptor to Router - go

On my windows 10 pro laptop I am running geth in WSL. The problem is I can not seem to get reach my wireless router. I am getting a status of not connected to my router. So the web3J calls returns a can not connect. I setup my geth:
geth --http.port "8545" --http.addr "192.168.1.15" --datadir test-chain-dir --http --dev
I setup eth0 to match my address in my ipv4 settings config in my vethernet adaptor
ifconfig eth0 192.168.1.15 and the mask ifconfig eth0 netmask 255.255.255.0
I also add a route ip route add default via 192.168.1.15
So what am I doing wrong? I also tried adding on the windows side the command to setup portproxy.
Is there some definitive instructions somewhere about setting up geth to work within WSL and able to reach out to the router? I wrote some simple code using web3j running on a android phone that is connected on my local network.
Thanks!

Related

Using k6 on docker to test a localhosted site

I've got a app running on my computer in localhost:1235, and I'm trying to load test it.
I installed k6 container for docker to test it, but of course from the nature of docker, my container has a different localhost. I'm trying to understand what do.
I run the following command:
docker run -it --rm --net=host -v c:/users/k6:/k6 loadimpact/k6 run /k6/script
I read somewhere that --net=host doesn't work on windows, is that right? How would I find the host IP?
I've tried running by this tutorial:
http://blog.michaelhamrah.com/2014/06/accessing-the-docker-host-server-within-a-container/
The IP I find 172.17.0.1 doesn't work in my test.
I also tried adding -p 1235:1235 but it failed, I guess docker tries to bind this port and just forward to it.
Thanks in advance,
Chaim
Inside your k6 script use the url host.docker.internal to access something running on the host machine.
For example to access a service running on the host at http://localhost:8080
// script.js
import http from "k6/http";
import { sleep } from "k6";
export default function () {
http.get("http://host.docker.internal:8080");
sleep(1);
}
Then on windows or mac this can be run with:
$ docker run -i loadimpact/k6 run - <script.js
for linux you need an extra flag
$ docker run --add-host=host.docker.internal:host-gateway -i loadimpact/k6 run - <script.js
References:
Mac: https://docs.docker.com/docker-for-mac/networking/#use-cases-and-workarounds
Windows: https://docs.docker.com/docker-for-windows/networking/#known-limitations-use-cases-and-workarounds
Linux: https://stackoverflow.com/a/61424570/3757139
k6 inside the docker instance should be able to connect to the "public" IP on your host machine - the IP that is configured on your ethernet or Wifi interface. You can do a ipconfig /all to see all your interfaces and their IPs.
On my Mac I can do this:
$ python httpserv.py &
[1] 7824
serving at port 8000
$ ifconfig en1
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether b8:09:8a:bb:f7:ed
inet6 fe80::148f:5671:5297:fc24%en1 prefixlen 64 secured scopeid 0x5
inet 192.168.0.107 netmask 0xffffff00 broadcast 192.168.0.255
nd6 options=201<PERFORMNUD,DAD>
media: autoselect
status: active
$ echo 'import http from "k6/http"; export default function() { let res = http.get("http://192.168.0.107:8000"); console.log(res.status); };' |docker run -i loadimpact/k6 run -
I.e. I start a simple HTTP server on port 8000 of the host machine, then executes the k6 docker image and tells it to access a URL based on the IP address of the physical, outward-facing en1 interface on the host machine. In your case, on Windows, you can use ipconfig to find out your external-facing IP.

Unable to access local network IP from docker container

Running macOS and docker ubuntu on it, I am unable to ping my local network's IP addresses. Below is the network configuration of my docker container. I can ping my host machine's IP address but I am unable to access other IP addresses on the local network.
root# ping 172.17.101.192
PING 172.17.101.192 (172.17.101.192) 56(84) bytes of data.
From 172.17.0.3 icmp_seq=1 Destination Host Unreachable
From 172.17.0.3 icmp_seq=2 Destination Host Unreachable
root# ifconfig
eth0 Link encap:Ethernet HWaddr 02:42:ac:11:00:03
inet addr:172.17.0.3 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::42:acff:fe11:3/64 Scope:Link
Is there any network configuration which would help me to perform this operation?
I have tried net=host but it is not helping it.
I was using docker for mac, the issue was docker internal network conflicting with my local network addressing.
To resolve the this issue, i need to go to Preferences in the dokcer menu.
In Preferences menu Daemon>Advanced Menu, i can supply other bip.
{
"bip" : "12.12.0.1/24"
}
Click apply and restart. The next time docker will start with internal network as 12.12.0.1/24.
I think docker internal network could be conflicting with your local network addressing.
Try to run Docker changing the default internal network to something that doesn't conflict, as 172.31.0.0/24. Add to your Docker startup options --bip 172.31.0.1/24, probably located in /etc/default/docker:
# Use DOCKER_OPTS to modify the daemon startup options.
DOCKER_OPTS="--bip 172.31.0.1/24"
UPDATE: Although this is true in Linux, Mac implementation is different, see docs here, so it depends if you're using Docker for Mac or for Linux.
Just to test, try to attach your laptop to a different network, any in the range of 192.168.0.0/16 would suffice.
I'm guessing you're using docker-machine.
You should check out docker for mac as it has some networking improvements that may make this work for you. This is what I'm using and I'm able to reach other hosts on my internal network from docker.
I tried the following, and it works:
mac-os $> ifconfig
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 78:31:c1:bd:4b:84
inet6 fe80::1425:a90d:9c00:ef53%en0 prefixlen 64 secured scopeid 0x4
inet 10.191.41.1 netmask 0xfffff800 broadcast 10.191.47.255
nd6 options=201<PERFORMNUD,DAD>
media: autoselect
status: active
So my ip is 10.191.41.1. Then I do:
mac-os $> docker run -ti --rm ubuntu bash -c "apt-get update && apt-get install -y inetutils-ping && ping 10.191.41.1"
Which installs the "ping" command, and tries to ping my host. I get the right answers:
[...]
PING 10.191.41.1 (10.191.41.1): 56 data bytes
64 bytes from 10.191.41.1: icmp_seq=0 ttl=37 time=0.303 ms
64 bytes from 10.191.41.1: icmp_seq=1 ttl=37 time=0.536 ms
[...]
I wanted to throw this answer out as it happened to me on Windows, but could really on any environment. I was using a bridge network on my local machine for a service I was developing and ran into similar issues, what was weird was that pinging our production physical servers (which started with a 10.10... IP pattern) or the random sites on the internet I was able to receive a response. But the physical dev server which sat on a 172.16... pattern didn't work.
Finally I discovered through doing docker network inspect on the networks I had locally that one had created with the same subnet of 172.16... which overlapped my physical server IP address range. So when I was pinging the physical dev server, it was trying to find it on the virtual docker network, where it didn't exist.
After deleting that network (it was a dev one I didn't use), everything worked.
docker network rm {networkName}
If I had to keep the network, it is possible to change the subnet in the docker-compose file. If you need to change the conflicting subnet, the link to that is here How do configure docker compose to use a given subnet if a variable is set, or choose for itself if it isn't?
That would look something like this (if you wanted a 12.12 subnet):
networks:
default:
ipam:
config:
- subnet: 12.12.0.0/16

Boot2Docker: Connect to container over LAN

I'm using Boot2Docker 1.3.0 on my Mac and I'm pretty happy so far using it. But now I'd like to connect to a http container (exposes port 8080) not from my local machine but from another machine in my local network? If I'm doing it locally I just use http://192.168.59.103:8080 so I'm using the ip address of the docker host. This can't work for other machines in my local network but using the ip address of my mac does not work either. I'm pretty sure there are some solutions for this problem but I can't find any. It can't be that hard right? What I want is to make a request to http://[IP-Address-of-mac]:8080 from another host in my local network. I think I have to set up some routing rules on my local machine right? May anybody tell me what to do? Thanks in advance.
Best regards
Sascha
You need to port forward from the OSX box to the virtual machine
VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port8080,tcp,,8080,,8080";
should do the trick
or, you could use ssh based port forwarding:
boot2docker ssh -L 8000:localhost:8000
see https://github.com/boot2docker/boot2docker/blob/master/doc/WORKAROUNDS.md
On your Mac, determine the IP address that it uses on your local LAN:
$ ifconfig | grep 192
inet 192.168.1.21 netmask 0xffffff00 broadcast 192.168.1.255
inet 192.168.59.3 netmask 0xffffff00 broadcast 192.168.59.255
Then port forward:
$ boot2docker ssh -vnNTL 192.168.1.21:8080:localhost:8080
Now, requests that come into your Mac on port 8080 will get forwarded to the boot2docker Linux VM on port 8080. The docker server will then forward from the exposed port (VM port 8080) to the port your container is using for httpd (probably 80).
Note that "localhost" above is from the point of view of the Linux VM, not the Mac, because that is the host you are ssh'ing into.

Assign static local ip address to OS inside virtual machine with bridged connection

I have win 7 OS on my laptop, and linux(debian 7) inside vmware. I have set the debian to have bridged connection with the network. I am connected by wifi, and if the wifi modem is being restarted the local ip address of the debian changes, e.g. from 192.168.0.106 to 192.168.0.102. Is there a way to set the local ip address, so it will always remain the same ?
Thanks
You have to change your /etc/network/interfaces like this
and after that remember to restart your service using
sudo service networking restart
ok, found the solution
here is the source
http://www.cyberciti.biz/tips/howto-ubuntu-linux-convert-dhcp-network-configuration-to-static-ip-configuration.html
basically for debian
1) vim /etc/network/interfaces
2) comment/delete this line iface eth0 inet dhcp
3) add this
iface eth0 inet static
address 192.168.1.106 # this is the ip address you want to assign
netmask 255.255.255.0
network 192.168.1.0

How to use Putty to connect to a virtual machine?

I am running a virtual machine on Virtual Box
On running ifconfig eth1, I get
inet addr: 192.168.56.11 and many more values.
How do I use Putty (ssh) here?
I entered 192.168.56.11 on the Host Name and 80 on the Port Number, but Putty can't connect.
I am trying to follow the guidelines from this course:
https://s3-us-west-2.amazonaws.com/cs144-misc/instructions/vm.html
What exactly does Putty do? I don't understand why I need to do this.
PuTTY will open a "network" between both machines. You'll get a console (like the shell) when you'll be connected. Really useful to administrate remote server from your computer.
Usually, the port is not 80, but 22.
For oracle vm virtual box:
1)Power of your machine
2)goto Settings -> Network -> Adapter1 -> Enable Network Adapter -> select "Bridge Adapter" in Attache To tab and click 'ok" button
3) open terminal in virtual box and type" ifconfig"
in first paragraph
eth0 Link encap:Ethernet HWaddr 08:00:27:fb:d1:28
inet addr:172.16.2.199
4) Here ip address is "172.16.2.199" using this ip and port 22 ,you can login through putty and winscp also
Try opening terminal through VMWare's console on Ubuntu and then run below given code:
sudo apt-get install openssh-server
I had faced the same issue.
Note: I assume you have already started the VM, importing the ISO image, and tried to access the machine with 10.X.X.X or 172.X.X.X range IP address from the Putty agent and got an time-out message.
Before making any changes to the network configuration on the VM or trying bridge-adapters, as suggested by many of the articles online, I suggest you to check 2 robust points which forms the bus for your VM on VirtualBox and Putty agent installed on your system.
1st Point:
Opening Host Network Manager in File section of your Oracle VirtualBox
Adding a host-only ethernet network (I suggest to keep a 192.X.X.X range)
2nd Point: Adding a host-only adapter, under the network settings of your VM.
Host-Only Adapter settings
If you follow these steps before booting up the VM for the first time, your VM will be allocated with a 192 range IP address (by the dhcp) the moment it boots up and starts running. Now all you need to do is, install and openssh-server and use the 192-range IP address with the Putty agent and Voila!!
Hope this help! Greetings!

Resources