I'm actually working on a devops tutoriel and so i need to run jenkins in a ubuntu virtual machine in virtual box. The problem is that I can't access jenkins from my host Windows 10 (browser: ip_address_vm:8080) after trying anything I found on the internet. I tried port forwarding, setting the network adapter to bridged in vbox, NAT, Nat network, setting two adapters nat and host-only. But nothing seems to work, when on bridged I couldnt even ping the host from the guest, but I can now after setting to network adapters nat and host-only. However, I can't access jenkins from my browser in windows even if it works fine in ubuntu and I can access it by the ip address of the vm. I even changed the httpListnerAddress in /etc/default/jenkins to 0.0.0.0 but nothing changes. Where do the problem exist and how to solve it please, is it just a configuration thing in vbox or something else?
port forwarding, setting the network adapter to bridged in vbox, NAT, Nat network, setting two adapters nat and host-only, changed the httpListnerAddress in /etc/default/jenkins to 0.0.0.0 but nothing changes.
I've almost forgotten the features of NAT and bridge networking on VirtualBox. Nonetheless, let's proceed with some troubleshooting using the following steps.
Ensure that your Windows host can connect to your Ubuntu machine. This means there should be a DNAT rule permitting access to Jenkins on port 8080, as well as an SNAT rule (like MASQUERADE) that allows all applications to connect to external systems (such as Windows) and the internet. On Ubuntu, use this command to display NAT rules.
iptables -nvL -t nat
$iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
Check if there are any INPUT/OUTPUT ACL rules blocking your access to Jenkins.
iptables -nvL
Check the Listen tcp port 8080 for Jenkins.
netstat -tulpn | grep LISTEN
Jenkins running on IPv6 solution: Modify this file of /etc/sysconfig/jenkins.
It should be set to the address 0.0.0.0, not 127.0.0.1. Otherwise, external systems (Windows, in this case) won't be able to connect to this Jenkins portal.
Reference:
With bridged networking, Oracle VM VirtualBox uses a device driver on your host system that filters data from your physical network adapter. This driver is therefore called a net filter driver. This enables Oracle VM VirtualBox to intercept data from the physical network and inject data into it, effectively creating a new network interface in software. When a guest is using such a new software interface, it looks to the host system as though the guest were physically connected to the interface using a network cable. The host can send data to the guest through that interface and receive data from it. This means that you can set up routing or bridging between the guest and the rest of your network.
Internal Networking is similar to bridged networking in that the VM can directly communicate with the outside world. However, the outside world is limited to other VMs on the same host which connect to the same internal network.
Host-only networking can be thought of as a hybrid between the bridged and internal networking modes. As with bridged networking, the virtual machines can talk to each other and the host as if they were connected through a physical Ethernet switch. As with internal networking, a physical networking interface need not be present, and the virtual machines cannot talk to the world outside the host since they are not connected to a physical networking interface.