Ping a virtualbox machine from the host machine shows "Destination Host Unreachable" - linux

I don't know why but I can't ping a virtual machine node from the host. I have created a network:
vboxnet1:
IPv4 Address: 192.168.57.0
IPv4 Network Mask: 255.255.255.0
IPv6 Address: fe80:0000:0000:0000:0800:27ff:fe00:0000
IPv6 Network Mask Length: 64
Then I have created a virtual machine with 2 interfaces:
adapter 1: NAT
adapter 2: Host-only Adapter. Name: vboxnet1
Check "Cable Connected"
Then I have Installed CentOS 7 on VM.
edit: /etc/sysconfig/network-scripts/ifcfg-eth0:
DEVICE=eth0
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
ONBOOT=yes
edit: /etc/sysconfig/network-scripts/ifcfg-eth1:
TYPE=Ethernet
IPADDR=192.168.57.111
NETMASK=255.255.255.0
BOOTPROTO=static
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eth1
DEVICE=eth1
ONBOOT=yes
"ip addr" on VM shows that eth0 is 10.0.2.15/24 and eth1 is 192.168.57.111/24
"route -n" on host machine shows:
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 wlan0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0
192.168.56.0 0.0.0.0 255.255.255.0 U 0 0 0 vboxnet0
192.168.57.0. 0.0.0.0 255.255.255.0 U 0 0 0 vboxnet1
Virtual machines can ping each other. Also, Virtual machines can ping the host machine but the host machine can't ping virtual machines.
Can somebody explain why it isn't working?

I used a bridge network because security isn't a concern in my setup.
Here is a summary of tutorial in the link from #ser99.sh
Select the virtual machine that you want to connect to your network:
Rightclick your virtual machine and select settings --> network settings --> bridge network:
Start up your virtual machine and select a suitable static IP address:
Verify that you have access to other computers:

If you want connect your host machine with guest machines, you can use "bridge network"
http://www.thegeeky.space/2015/06/how-to-set-and-run-bridge-virtual-network-on-CentOS-Kali-Linux-Windows-in-Virtualbox-with-practical-example.html

Related

Can't access website in virtualbox after Windows 10 update

Host: Windows 10 (updated)
Guess: Ubuntu 14.04.5
Virtualbox: 5.2.12 r122591 (Qt5.6.2)
After the windows update I tried to access my virtual machine and it kept giving me random errors. After of dozens of tutorials and guides my current settings are:
Hosts file (on windows): 192.168.56.2 devserver
/etc/network/interfaces file(on ubuntu)(couldn't paste):
auto eth1
iface eth1 inet static
address 192.168.56.2
netmask 255.255.255.0
broadcast 192.168.56.0
auto eth0
iface eth0 inet dhcp
auto eth2
iface eth2 inet dhcp
Virtualbox network:
Attacked to: Host-only Adapter
Name: VirtualBox Host-Only Ethernet Adapter #3
Adapter Type: PCnet-FAST III (am79C973)
Promiscuous Mode: Allow All
MAC Address: 0800275A1DBB
But I still can't connect to the website. It keeps giving me the "page not found" message.
Solution
/etc/network/interfaces file
auto eth0
iface eth0 inet static
address 192.168.56.2
netmask 255.255.255.0
broadcast 192.168.56.0
hosts file
192.168.56.2 devserver

VM can't ping host that's two switches and a router away through NAT

I have a Linux VM (Kali) that's connected to a host only switch
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.40 netmask 255.255.255.0 broadcast 192.168.0.255
The Interface is up, the interfaces file looks like this
auto eth0
iface eth0 inet static
address 192.168.0.40
netmask 255.255.255
gateway 192.168.0.254
dns-nameservers 8.8.8.8
the switch is connected to an Ubuntu Server VM that has a masquerade NAT enabled to the 192.168.0.0/24 network and is connected via a bridged switch to the actual host, which is running Ubuntu 16.04
The NAT rule is on the POSTROUTING chain and it goes like this
Chain POSTROUTING (policy ACCEPT 20 packets, 1440 bytes)
pkts bytes target prot opt in out source destination
0 0 MASQUERADE all -- * ens33 192.168.0.0/24 0.0.0.0/0
and the interfaces file on the server machine looks like this
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto ens33
iface ens33 inet static
address 172.16.23.100
netmask 255.255.0.0
gateway 172.16.0.254
dns-nameservers 8.8.8.8
#iface ens33 inet dhcp
#Gateway for LAN1 - 192.168.0.0/24
auto ens38
iface ens38 inet static
address 192.168.0.254
netmask 255.255.255.0
The routing table on the host looks like this
default via 172.16.0.254 dev enp3s0
169.254.0.0/16 dev enp3s0 scope link metric 1000
172.16.0.0/16 dev enp3s0 proto kernel scope link src 172.16.0.6
Now i'm trying to ping the host from the Kali machine (from 192.168.0.40 to 172.16.0.6), but the ping isn't going through, i did tcpdump on the host machine on the only interface with 192.168.0.40 as the host but it doesn't pick up any traffic. the NAT rules aren't being used for some reason.
I can ping the default gateway and the server/router VM with Kali but the ping for the host doesn't go through. What am i doing wrong?
What i think should happen is that the packet goes through to the server through Kali's default gateway, once it's in the server machine it gets translated to ens33's address and from there it will go to the host and the host will send it back to ens33 because that should be the current source ip, but clearly that's not happening
I'm bad at paying attention to things, i put the NAT rule as eth33 instead of ens33, fixed it and it works now

SSH on Raspberry Pi3

I install "ubuntu-17.04-desktop-amd64" and "qt-opensource-linux-x64-5.8.0" on on my laptop.
I wrote an application with Qt 5.8 for windows. It works fine in windows and Ubuntu.
IP address of raspberry ("hostname -I"): 169.254.181.63
Enable SSH:
In raspberry: from Preferences menu of Rasbian.
In Ubuntu:
sudo service ssh status
....
.... Starting OpenBSD Secure Shell server.
.... Server listening on 0.0.0.0 port 22.
.... Server listening on :: port 22.
.... Started OpenBSD Secure Shell server.
I connect raspberry pi to laptop with Ethernet cable.
I create new device (Generic Linux Device) in "Tools -> Options…-> Devices tab"
Host name: 169.254.181.63
SSH port:22
Username: pi
Password: 1 (set by me)
Result test:
Device test: SSH connection: Network unreachable.
In Ubuntu:
ssh pi#169.254.181.63
ssh: connect to host 169.254.181.63 port 22: Network is unreachable
I edit the interface file to set the network configuration in raspberry:
sudo nano /etc/network/interfaces
Update:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.100.100
netmask 255.255.255.0
allow-hotplug wlan0
iface wlan0 inet manual
Update:
But after reboot raspberry and execute "hostname -I", I have "192.168.100.100 169.254.181.63"
You should configure a static IP in this way (see this link):
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.100.100
network 192.168.100.0
netmask 255.255.255.0
broadcast 192.168.200.25
You've to move address, netmask, etc. below the line iface eth0 inet static.
Check if your correct IP address is correct and use command in terminal. Open the terminal use this command and find the exact ip address:
cd /var/misc
cat misc
Copy this IP address and use this command:
ssh pi#ip_address
change the order. put the settings under iface eth0 not the lo.
iface eth0 inet manual
address 192.168.200.100
network 192.168.100.0
netmask 255.255.255.0
broadcast 192.168.200.25

How to divert traffic from a docker container's ethernet interface to a bridge?

We have a virtualized solution in-place. I am trying to port the environment into docker. Now the problem I am facing is that like the way, docker uses the concept of network-namespace to create virtual ethernet interfaces and move the other end of my network-pipe to docker container, in the same way, virtualized environment running inside docker container is creating a bridge and clubbing all the virtual ethernet interfaces created for each virtualized host.
Now I am able to ping bridge IP created inside the docker. But ping is not going for the ip's created inside the network namespace for each virtual host.
This diagram will help in drawing the whole network stack:
Host:
bridge: docker0(172.17.0.1) ----> veth(some name given by docker)
Container:
eth3: 172.17.0.2(renamed purposely)
bridge:eth2(172.16.69.62) ---> eth0_host1 ----- eth1(host1:172.16.69.33) ( namepsace:net_host1)
---> eth0_host2 ----- eth1(host2:172.16.69.34)
namespace:net_host2)
Now, the problem is ping from the host machine to bridge: 172.16.69.62 is going on,
but it doesn't work if I try to ping to 172.16.69.33
Below are the routing tables for docker container:
0.0.0.0 172.17.0.1 0.0.0.0 UG 0 0 0 eth3
172.16.69.32 0.0.0.0 255.255.255.224 U 0 0 0 eth2
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth3
For host:
0.0.0.0 192.168.0.1 0.0.0.0 UG 100 0 0 enp0s8
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 enp0s8

Virtual IP failover on 2 Linux box

I have 2 Linux VM Box.
VM1 ip is 192.168.0.4
VM2 ip is 192.168.0.5
GW: 192.168.0.1, net mask: 255.255.255.0
1)I have added a virtual ip on VM1
ifconfig eth0:1 192.168.0.10 netmask 255.255.255.0 up
Then I can ping it successfully from my client
2)removed the virtual ip on VM1
ifconfig eth0:1 192.168.0.10 netmask 255.255.255.0 down
Then I can NOT ping it successfully from my client
3)Add the same virtual ip on VM2
ifconfig eth0:1 192.168.0.10 netmask 255.255.255.0 up
!!I failed to ping this ip!!
however 1-2 hours later, I can ping it successfully.
3)Add the same virtual ip on VM2
however 1-2 hours later, I can ping it successfully.
Try flushing the ARP table on the client:
ip neigh flush all dev eth0
Also, I believe having the second VM send gratuitous ARPs after getting the new IP will solve the problem.

Resources