Unable to access internet via NAT... NICs to blame?
Posted: 8. Mar 2020, 03:07
I have to connect to the internet from the VM, but cannot use bridged networking, because the physical NIC is limited to have only one IP address.
The software versions are: VirtualBox 5.2.34_Ubuntur133883 on an Ubuntu 18.04 dedicated server, without GUI.
The commands I used:
created two networks and related DHCP servers:
then imported a worker, and assigned two networks to it:
Unfortunately inside the VM, the second NIC has no IP:
gives me this result (lo is removed):
I tried to set a manual IP address using ifconfig enp0s8 inet 10.10.10.4 netmask 255.255.255.0, though it does not connect.
The result for `VBoxManage list natnetworks`:
The result for VBoxManage list dhcpservers:
I noticed that replacing the NIC configs make hostonly NIC unreachable. Therefore, did I make a mistake or there is an issue with NICs, and either way how to solve it?
Update:
In a windows host, I had the same experience with the same machine. However, when I set the first NIC to NAT, and the second to hostonly, NAT worked and hostonly is fixed by setting the address inside the machine. So, what to do on Linux host?
The software versions are: VirtualBox 5.2.34_Ubuntur133883 on an Ubuntu 18.04 dedicated server, without GUI.
The commands I used:
created two networks and related DHCP servers:
Code: Select all
VBoxManage hostonlyif ipconfig vboxnet1 --ip 192.168.57.1
VBoxManage dhcpserver add --ifname vboxnet1 --ip 192.168.57.1 --netmask 255.255.255.0 --lowerip 192.168.57.10 --upperip 192.168.57.200
VBoxManage natnetwork add --netname natnet1 --network "10.10.10.0/24" --enable --dhcp on
Code: Select all
VBoxManage import worker1.ova
VBoxManage modifyvm worker1 --nic1 hostonly --hostonlyadapter2 vboxnet1
VBoxManage modifyvm worker1 --nic2 natnetwork --nat-network1 natnet1
Code: Select all
VBoxManage startvm worker1 --type headless
ssh user@192.168.57.10
ifconfig -a
Code: Select all
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.57.10 netmask 255.255.255.0 broadcast 192.168.57.255
inet6 fe80::a00:27ff:fe55:c1f6 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:55:c1:f6 txqueuelen 1000 (Ethernet)
RX packets 53 bytes 7239 (7.2 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 55 bytes 8521 (8.5 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp0s8: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether 08:00:27:3f:b6:21 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
The result for `VBoxManage list natnetworks`:
Code: Select all
NetworkName: natnet1
IP: 10.10.10.1
Network: 10.10.10.0/24
IPv6 Enabled: No
IPv6 Prefix: fd17:625c:f037:2::/64
DHCP Enabled: Yes
Enabled: Yes
loopback mappings (ipv4)
127.0.0.1=2
Code: Select all
NetworkName: HostInterfaceNetworking-vboxnet1
IP: 192.168.57.1
NetworkMask: 255.255.255.0
lowerIPAddress: 192.168.57.10
upperIPAddress: 192.168.57.200
Enabled: Yes
NetworkName: natnet1
IP: 10.10.10.3
NetworkMask: 255.255.255.0
lowerIPAddress: 10.10.10.4
upperIPAddress: 10.10.10.254
Enabled: Yes
Update:
In a windows host, I had the same experience with the same machine. However, when I set the first NIC to NAT, and the second to hostonly, NAT worked and hostonly is fixed by setting the address inside the machine. So, what to do on Linux host?