LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-28-2018, 05:46 PM   #1
GTA 3
LQ Newbie
 
Registered: Apr 2018
Posts: 1

Rep: Reputation: Disabled
Can't ping gateway - static routing


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)

Basic informations:
VM1: - one Interface (internal Network 0)
192.1.1.4 - 255.255.255.0 - 192.1.1.1 (Gateway) - 192.1.1.2 (DNS)

VM2: - two Interface (internal Network 0)
192.1.1.5 - 255.255.255.0 - 192.1.1.1 (Gateway) - 192.1.1.2 (DNS)

- two Interface (internal Network 1)
192.2.1.5 - 255.255.255.0 - 192.2.1.1 (Gateway) - 192.2.1.2 (DNS)

VM3: - one Interface (internal Network 1)
192.2.1.4 - 255.255.255.0 - 192.2.1.1 (Gateway) - 192.2.1.2 (DNS)

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...

Here are some logs:
Quote:
VM1: eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.1.1.4 netmask 255.255.255.0 broadcast 192.1.1.255
inet6 fe80::a00:27ff:feef:befa prefixlen 64 scopeid 0x20<link>
ether 08:00:27:ef:be:fa txqueuelen 1000 (Ethernet)
RX packets 118 bytes 7963 (7.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 75 bytes 4878 (4.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 16 base 0xd240

VM1:cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.1.1.2

route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.1.1.1 0.0.0.0 UG 100 0 0 eth0
192.1.1.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
Quote:
VM2: eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.1.1.5 netmask 255.255.255.0 broadcast 192.1.1.255
inet6 fe80::a00:27ff:fe59:766b prefixlen 64 scopeid 0x20<link>
ether 08:00:27:59:76:6b txqueuelen 1000 (Ethernet)
RX packets 42 bytes 3166 (3.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 133 bytes 7532 (7.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 16 base 0xd240

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.2.1.5 netmask 255.255.255.0 broadcast 192.2.1.255
inet6 fe80::a00:27ff:fe93:e197 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:93:e1:97 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 126 bytes 19132 (18.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 17 base 0xd260

cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.1.1.2
nameserver 10.0.2.3
nameserver 192.2.1.2

route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.1.1.1 0.0.0.0 UG 100 0 0 eth0
0.0.0.0 10.0.2.2 0.0.0.0 UG 100 0 0 eth2
0.0.0.0 192.2.1.1 0.0.0.0 UG 100 0 0 eth1
10.0.2.0 0.0.0.0 255.255.255.0 U 100 0 0 eth2
192.1.1.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
192.2.1.0 0.0.0.0 255.255.255.0 U 100 0 0 eth1
Hope you guys can help me

Last edited by GTA 3; 04-28-2018 at 06:14 PM.
 
Old 04-28-2018, 08:10 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Debian, Mageia, and whatever VMs I happen to be playing with
Posts: 13,832
Blog Entries: 24

Rep: Reputation: 3691Reputation: 3691Reputation: 3691Reputation: 3691Reputation: 3691Reputation: 3691Reputation: 3691Reputation: 3691Reputation: 3691Reputation: 3691Reputation: 3691
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.

Quote:
nameserver 192.1.1.2
nameserver 10.0.2.3
nameserver 192.2.1.2
Are any of these machines identified as nameservers running BIND or some other DNS-resolving server service?

Also, where did 10.0.2.3 come from?
 
Old 04-28-2018, 10:01 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 17,352

Rep: Reputation: 2233Reputation: 2233Reputation: 2233Reputation: 2233Reputation: 2233Reputation: 2233Reputation: 2233Reputation: 2233Reputation: 2233Reputation: 2233Reputation: 2233
Welcome to LinuxQuestions.

Quote:
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"
 
Old 05-16-2018, 06:58 AM   #4
selfprogrammed
Member
 
Registered: Jan 2010
Location: Minnesota, USA
Distribution: Slackware 13.37, 14.2
Posts: 372

Rep: Reputation: 79
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.
 
Old 05-16-2018, 01:06 PM   #5
jefro
Moderator
 
Registered: Mar 2008
Posts: 18,380

Rep: Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739
Fix the subnet mask. Just make it 255.0.0.0 and be done with it?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
IP routing - unable to ping gateway from multiple interfaces Centos 6.7 locomotif Linux - Newbie 9 04-05-2016 12:02 PM
[SOLVED] OpenBSD 5.8 routing: Cannot reach gateway from IF configured to static block Kubitz *BSD 15 01-29-2016 07:14 PM
Dynamic routing isn't done; static routing works for about 2 seconds for wireless gregorian Linux - Networking 7 02-19-2010 06:43 AM
[SOLVED] static ip config: ping to gateway: yes, telnet: no stabu Linux - Networking 4 12-17-2009 08:30 AM
have to ping gateway to "kickstart" net connection and routing bPrompter Linux - Networking 0 01-19-2005 02:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration