Page 1 of 1

[Solved] How I can setup this topology over CentOS?

Posted: 2018/01/21 18:04:45
by sincorchetes
Good afternoon folks,

I does have some problems to get work the next topology in all CentOS computers over VirtualBox:

My network:
I have a ISP's router with local area is set up as 192.168.1.0/24
My laptop does have 192.168.1.90

Server side VM:
CentOS with bridged network card -> enp0s3:
* 192.168.1.223/24

Internetwork card -> enp0s8
* 172.16.1.1/16

Client side VM:
Internetwork card -> enp0s3
* 172.16.1.10/16

ifcfg-enp0s3:
DEVICE=enp0s3
IPADDR=172.16.1.10
NETMASK=255.255.0.0
GATEWAY=172.16.1.1
GATEWAY_DEV=enp0s3
ONBOOT=yes
BOOTPROTO=static
NETWORKING=yes

At client side, I added this commands to add default route
route add -net 192.168.1.0 netmask 255.255.255.0 gw 172.16.1.1

I get this message when I execute ip route:
default via 172.16.1.1 dev enps03 proto static metric 100
172.16.0.0/16 dev enp0s3 proto kernel scope link src 172.16.1.10 metric 100
192.168.1.0/24 via 172.16.1.1 dev enp0s3

When I do ping to Server from Client, It's works.

But when I try to ping my laptop computer 192.168.1.90 or gateway 192.168.1.1 that's does not work.

What am I doing bad?

Re: How I can setup this topology over CentOS?

Posted: 2018/01/21 20:25:20
by hunter86_bg
What is the output of this (run on CentOS Server VM):

Code: Select all

sysctl net.ipv4.ip_forward

Re: How I can setup this topology over CentOS?

Posted: 2018/01/22 00:03:27
by sincorchetes
hunter86_bg wrote:What is the output of this (run on CentOS Server VM):

Code: Select all

sysctl net.ipv4.ip_forward
Yes, I made that but It's does not work.

I have to apply this:

Code: Select all

iptables -t nat -A POSTROUTING -o enp0s3 -j MASQUERADE
Now, I can do ping from client into 8.8.8.8, but I cannot perform:

Code: Select all

ping google.com
Because It does not find servers.

I have setup /etc/resolv.conf in the client side the same DNS servers as laptop and server (Works fine in both devices).

Re: How I can setup this topology over CentOS?

Posted: 2018/01/22 00:20:01
by sincorchetes
sincorchetes wrote:
hunter86_bg wrote:What is the output of this (run on CentOS Server VM):

Code: Select all

sysctl net.ipv4.ip_forward
Yes, I made that but It's does not work.

I have to apply this:

Code: Select all

iptables -t nat -A POSTROUTING -o enp0s3 -j MASQUERADE
Now, I can do ping from client into 8.8.8.8, but I cannot perform:

Code: Select all

ping google.com
Because It does not find servers.

I have setup /etc/resolv.conf in the client side the same DNS servers as laptop and server (Works fine in both devices).
Okay, It was solved:

Commands performed to solve this issue:

Code: Select all

sysctl net.ipv4.conf.all.forwarding=1
iptables -I FORWARD -o enp0s8 -j ACCEPT
iptables -I FORWARD -i enp0s8 -j ACCEPT
iptables -t nat -A POSTROUTING -o enp0s3 -j MASQUERADE