I have two NIC Card in CentOS Operating System.

Configuration :

(Modem)Router IP =
eth0 : ------ LAN IP
Mask :
GW :
eth1 : ---- Public ID [Static IP]
MASK :
GW :


I want to transfer the network traffic eth1[Public IP] to eth0 [Local IP] . so the windows host can also connected to Internet connection.


I have also Enable Forward_IPV4.
I Disable Firewall Using This Command : chkManager iptables off

Problem IS How Can I Routing table?

IS There Any Problem Regrding Firewall?

Is Any Extra Configuration Require?

Please Give Suggestion for Routing Table For This Configuration.

thanks

Dani AI

Generated

Short summary and practical fix recommendations for the setup described (one LAN interface and one public/interface on the same CentOS host). The goal is to let Windows hosts on the LAN reach the Internet through the CentOS box. Current thread correctly spotted gateway confusion () and suggested either making the CentOS host the LAN gateway () or using a bridge (). Below are concise, concrete options, the simplest recommended approach, and a short troubleshooting checklist.

Recommended (simplest) — NAT/masquerade (Linux as gateway for the LAN)

  • Make the CentOS machine the LAN gateway and forward traffic from eth0 to eth1. Ensure only the external interface provides the system default route; do not set a competing gateway on the LAN NIC.
  • Enable IPv4 forwarding and add NAT rules (temporary shown here; make persistent after verifying).
    
    sysctl -w net.ipv4.ip_forward=1
    echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf

iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
iptables -A FORWARD -i eth0 -o eth1 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT

save on CentOS 6:

service iptables save

or:

iptables-save > /etc/sysconfig/iptables

- On LAN Windows hosts set the default gateway to the CentOS LAN IP (the Linux machine). Use an ISP DNS or public resolver (e.g., 8.8.8.8) unless CentOS runs a DNS forwarder.

Alternative — bridge (when the LAN hosts must get public addresses)
- Bridge eth1 and eth0 only if the ISP/upstream allows multiple MACs or public addressing on the LAN side. Bridging places Windows directly on the public segment (no NAT) and requires different configuration (brctl/ifcfg-br0 or NetworkManager). Bridging has security and provider-compatibility caveats.

Key configuration notes
- Only one default gateway on the CentOS host; set DEFROUTE=no on the LAN if using network-scripts for that interface, and set the external interface as the default route.
- If running CentOS 7+/firewalld, use `firewall-cmd --add-masquerade --permanent` then `firewall-cmd --reload` instead of raw iptables.

Troubleshooting checklist

ip route show
cat /proc/sys/net/ipv4/ip_forward
iptables -t nat -L -n -v
ping -c3 8.8.8.8 (from CentOS and from a Windows host)
route -n (from Windows: check gateway)


If forwarding/ping works on the CentOS host but Windows cannot reach out, re-check Windows gateway/DNS and the FORWARD/NAT rules.

Recommended Answers

All 4 Replies

GW for eth0 should be 192.168.1.254. I dont' understand what you mean by:
I want to transfer the network traffic eth1[Public IP] to eth0 [Local IP] . so the windows host can also connected to Internet connection.

first of all i want to know is your windows host is in network ? if so then as you already forwarded ip now what you have to do is set the gateway and dns ip for windows host as follows:
gateway : your lan ip of linux host
dns: your public ip address

Hi chiragsathit,
Are you able to ping the router's i.p() and the Windows machine from the Cent-OS machine? And also, help us to understand your setup. Here is how I understand it. Windows machine---->Router(in bridge mode)---->Cent-OS machine--->Internet Link.

You might need to set up the CentOS system to be a network bride. The video in this link may help:
And this how-to may also:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.