3

My CentOS XYZ has two network interfaces:

iface1 136.136.10.10 is connected to gateway 136.136.10.1
iface2 192.168.10.1 is connected to private network

XYZ can access the internet through gateway 136.136.10.1 which is connected to the internet.

My other CentOS ABC has one network interface iface (192.168.10.2) that is internal. Now, how do I connect ABC to the internet?

I tried to add masquerade but with no avail:

On XYZ:

 # iptables --flush
 # iptables --table nat --flush
 # iptables --delete-chain
 # iptables --table nat --delete-chain
 # iptables --table nat --append POSTROUTING --out-interface iface1 -j MASQUERADE
 # iptables --append FORWARD --in-interface iface2 -j ACCEPT
 # echo 1 > /proc/sys/net/ipv4/ip_forward
 # systemctl restart network.service

on ABC:

 added 192.168.10.1 as gateway

Thanks,

BestCoderEver
  • 31
  • 1
  • 3
  • 1
    Probably when you restart the network.service the network settings go back to their original settings and /proc/sys/net/ipv4/ip_forward reverts to 0. Do you have network without restarting the service? Also if you use firewalld you only need: firewall-cmd --add-masquerade --zone= – nkms Sep 23 '15 at 10:11
  • As nkms mentioned, in order to save ip_forward configuration, add the following into `/etc/sysctl.conf`: net.ipv4.ip_forward = 1 – Eduardo Ramos Sep 24 '15 at 12:36
  • i tried both guys and doesn't work. – BestCoderEver Sep 24 '15 at 16:20

1 Answers1

0

After I fixed another problem in one of my interfaces, the problem is solved. Bottom line: the instructions I followed are valid and can be used to connect ABC to the internet.

BestCoderEver
  • 31
  • 1
  • 3