1

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 192.168.0.1(no,dns,no dhcp configured yet just ip-forwarding is enabled in router box).

Client machine is configured as:

ip address 192.168.0.5 and gateway 192.168.0.1

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

STEPS FOLLOWED

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

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.

vic
  • 71
  • 10
  • Do you enable ip forward in Centos server? – cuonglm Jul 12 '13 at 06: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 09:10
  • I would expect that the nic connected to "the modem" (eth1) would be the internet facing IP? – symcbean Jul 12 '13 at 09:57
  • yes eth1 is internet facing ip – vic Aug 05 '13 at 08: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 192.168.0.3, is that a typo? – Ryan Gibbons Aug 09 '13 at 04:05

1 Answers1

0

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 ` 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 06: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