I have several Virtual Machines in Vmware ESXi 6.5 with 2 Network Groups.
Created a DHCP Server Machine on CentOs with 2 networks interface.

1 / vm network from which it takes a network and has IP assigned.
2 / to the internet network in which all the machines that have the Internet will be
- the machine gets internet on interface 1 and it works properly. I can ping etc.
- a simple DHCP is configured in /etc/dhcp/dhcpd.conf file and it serves correctly addresses of machines in the "Internet" network
- machines in the Internet subnet that got DHCP addresses can ping each other and have no conflicts at all

On DHCP Machine (CentOS) I created a another profile network ens192 with IP, mask, no default gateway.

In file dhcpd.conf (ofcourse there is option domain-name)

subnet netmask {
option routers        ; //same as ens192
option subnet-mask    ;
#option routers        //tried with .254 gw

From DHCP Machine I can ping to and to another machines that got a DHCP addresses assigned by DHCP server.

Now lets check one machine with assigned DHCP. Its Ubuntu machine. Assigned address: I can ping each machine, including but cannot

Im not sure whats wrong.


In the meantime, I changed the DHCP server configuration to and range on

Ubuntu machine:
ip addr show inet brd scope global dynamic ens160

ip route default via dev ens160 proto static metric 100 dev ens160 proto kernel scope link src metric 100

CentOS 7.3 DHCP machine:
So all looks line in your post.

I enabled routing by
sysctl -w net.ipv4.ip_forward=1, added it to sysctl.d/ip_forward.conf by
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.d/ip_forward.conf
Should I restart some service at the moment?
Enabled firewalld:
firewall-cmd --permanent --direct --passthrough ipv4 -t nat -I POSTROUTING -o ens192 -j MASQUERADE -s success firewall-cmd --reload

Reboot on Ubuntu machine, and ping still nothing: 15 packets transmitted, 0 received, 100% packet loss

I thought configuring IP Forward and running NAT would solve the problem... Any more ideas? Thank you


To check if your DHCP configuration is good, you can check your ip settings with:

ip addr show

This will show the current configured ip address on the client machine interface, which from your example shows working -

next you can check on the client machine weather the default gateway is set properly:

ip route

This should show something like this:

default via dev eth0 dev eth0 proto kernel scope link src

the first line indicating the default gateway, if this is set to your golden in terms of DHCP config.

The last thing you need to check. Do you have routing enabled on the CentOS machine? In order to have internet access from your ubuntu machine, the CentOS needs to be configured as a router, or you need to have another router on the 192.168.0.x network.

quick n dirty - on the CentOS machine: Enable routing:

sysctl -w net.ipv4.ip_forward=1

to make persistent across reboots edit /etc/sysctl.conf and add:

net.ipv4.ip_forward = 1

to masquerade (NAT) for the 'outside' network:

Enable firewalld:

systemctl start firewalld
firewall-cmd –permanent –direct –passthrough ipv4 -t nat -I POSTROUTING -o *** -j MASQUERADE -s
systemctl restart firewalld

*** above should be your 'outside' interface on the CentOS machine.

  • Thanks for your answer. Edited my first post and added your information, but still nothing.. – Slideroh Nov 13 '18 at 12:27
  • From your original post, ens192 on the CentOS machine is the 'inside' interface (the one on the network. in the command for the firewall (to add NAT) you want the 'outside' interface, eg. the other one ;) – Flash Nov 13 '18 at 12:30
  • Ahh, right. Added another entry with ens160. Restarted firewalld and to be sure the ubuntu machine and it FINALLY works! Thank you so much! – Slideroh Nov 13 '18 at 12:40

I had a similar problem. UBUNTU SERVER 18.04

My Solution: One of the ways of NATing is by using IPTABLES.

iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE

where eth0 is the interface where internet comes in/from.

iptables --append FORWARD --in-interface eth1 -j ACCEPT

where eth1 is the interface which is connected to internal LAN. (the DHCP server interface)

now your client can ping

check this site for more clear reference: https://www.howtoforge.com/nat_iptables
or here's a official guide: https://help.ubuntu.com/community/Internet/ConnectionSharing

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.