Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hey, I am creating a little lab by virtual machines with virtualbox. I am using Kali for all machines.
Idea: One machine is running as a client. (vm1) The second machine will works as a router. (vm2) The last machine will be a server (e.g. webserver). (vm3)
Now the Problem:
I can ping between the vm's with the same subnet, but cannot reach the a vm of the other subnet (from 192.1 to 192.2). Also I can not ping the Gateway and the DNS-Server from all VMs. How can I fix my problem? I'm sitting on a solution since 2 days...
Are you using static ip addresses configured in the appropriate files in /etc (you don't mention what distros you are running in the VMs)? If so, you do not need to be running network manager.
Also I can not ping the Gateway and the DNS-Server from all VMs
As stated you did not provide any information as to where they exist,how they are configured or fit into your Lab environment.
Since VM1 is the client I assume that makes VM2 eth0 the LAN and eth1 the WAN which makes the gateway for VM1 192.1.1.5. You need to configure NAT and ipv4 forwarding on VM2 for VM1 to be able to ping outside the LAN. You do not provide any information about eth2 which could be a bridged adapter to the "outside world"
This would be easy if all the machines were on the same subnet.
192.1.1.4, 192.1.1.5, 192.1.1.6, 192.1.1.7
Then they could see each other, because the netmask would be 255.255.255.0.
The netmask when anded with the ip address tells it which network to find.
If you have a machine with an address like 192.2.1.4 on a network (same router)
as 192.1.1.4, using a netmask of 255.255.255.0, means that one machine thinks that
router is for network 192.2.1.0 and the other thinks that router is for network 192.1.2.0.
Any gateway on such a "dual" network will be confused also. Standard setups assume it will
be exclusively one network address or the other.
Second solution: expand you concept of network to include all the addresses.
So use a netmask of 255.0.0.0 instead, which would include all the VM addresses in the subnet.
Third solution: Route the address explicitly to the target network in each machine.
Don't even know if this will work, but some combination might.
It should look like.
> route add -net 192.2.1.0 netmask 255.255.255.0 dev eth0
This should route all 192.2.1.x addresses to device eth0.
You would need one of these for each address that is not covered by
the standard setup network addressing.
> route add -net 192.2.0.0 netmask 255.255.0.0 dev eth0
This should route all 192.2.x.x addresses to device eth0.
> route add -net 192.0.0.0 netmaks 255.0.0.0 dev eth0
This should route all 192.x.x.x addresses to device eth0, which would
allow all of your targets to be served by the one route setup.
If you are using a network manager, these will keep disappearing as those
often clear the route table before setting up their own routing.
You will have to find a script to tack them onto, such as one that gets
run automatically by udev when the device is discovered. This varies
for each distribution.
I cannot tell you what your router will do for such a setup.
Some routers are transparent, they will forward to the other ports any
traffic they receive.
I suspect some routers will only forward traffic that matches the network
for which they are configured. So if your router has address 192.1.1.1
and a netmask of 255.255.255.0, then it may assume that the network
it serves is 192.1.1.0, and it may ignore other traffic, such as 192.2.x.x.
The solution for that is to change the netmask in the router to 255.0.0.0.
You could make this easier by at least limiting your address range,
using addresses like 192.168.1.4, 192.168.2.4, 192.168.3.4 and 192.168.4.4,
with a netmask of 255.255.0.0. Large networks (more than 255 nodes) need
to do this, and is supported usage, so it should work for you too.
Last edited by selfprogrammed; 05-16-2018 at 07:11 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.