I have configured Centos 6.2 as Gateway machine.its having two interfaces

eth0 with ip address that provided by isp 116.x.x.x(Static) and eth1 with ip address,dns,no dhcp configured yet just ip-forwarding is enabled in router box).

Client machine is configured as:

ip address and gateway

After i reboot centos,iptables rules are not all gone.


Router machine:two interfaces eth0:116.X.X.X(static ip) eth1:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

iptables -A FORWARD -i eth0 -j ACCEPT

Save the iptable rules in /etc/sysconfig/iptables

Selinix is disabled.

changes done on /etc/sysctl.conf

sysctl -w net.ipv4.ip_forward=1

But still when system reboot everything gone.

  • Do you enable ip forward in Centos server? – cuonglm Jul 12 '13 at 6:19
  • yes i did,everything is going fine before restart,but after restart no connectivity to internet from client side – vic Jul 12 '13 at 9:10
  • I would expect that the nic connected to "the modem" (eth1) would be the internet facing IP? – symcbean Jul 12 '13 at 9:57
  • yes eth1 is internet facing ip – vic Aug 5 '13 at 8:21
  • Couple of things. 1. Double check you ip_forward is still enable sysctl net.ipv4.ip_forward 2. What does your routing table look like route -n 3. You have under you steps followed eth1 is set to, is that a typo? – Ryan Gibbons Aug 9 '13 at 4:05

When you say that you enabled ip forwarding, did you set it in sysctl.conf so that it is pervasive across reboots?

Setting it via sysctl -w net.ipv4.ip_forward=1 or echo 1 >/proc/sys/net/ipv4/ip_forward is only good for the current runtime and it is reset to the default or whatever is in /etc/sysctl.conf at boot time.

Also make sure that your iptables rules are getting saved in /etc/sysconfig/iptables

  • i did everything as described by you,but still the result is same – vic Jul 23 '13 at 10:32
  • At this point I would start adding logging rules into iptables -j LOG --log-prefix <some text indicating which table> and running tcpdump -ni eth0 and tcpdump -ni eth1 on the router and see what is happening to the packets. – numeric illustration Jul 24 '13 at 6:36
  • can elaborate it more,plz.....i configured and install centos and other distro many times,never face such issue,don't know why this time i am facing it.....if possible can you plz give me all steps that has perform while installing and configuring centos as a internet gateway(permanent settingings so that it won't go after restart)...Please its important for me to do it as soon as possible – vic Jul 24 '13 at 11:33

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.