Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am trying to setup my Centos 4.4 box with two nics as a static router. Here is what I have:
Nic1: 10.0.0.80 eth3
Nic2: 192.168.1.1 eth2
I have applied the following iptables rules:
/sbin/iptables -t nat - A POSTROUTING -o eth2
/sbin/iptables -t nat - A POSTROUTING -o eth3
/sbin/iptables -t filter -A FORWARD -d 192.168.1.1 -s 10.0.0.0/24 -j ACCEPT
I then added a route:
route add -net 10.0.0.0 netmask 255.255.255.0 gw 192.168.1.1 dev eth2
I enabled ip_forwarding in /proc/sys/net/ipv4/ip_forward so that is =1.
I cannot ping one nic to the other. Any ideas on what could be cuasing the problem? Thanks
to route at the simplest level, there's no need for iptables at all, just the ip_forward. you also need do routing commons for those two networks on the routing machine as it already knows where those networks are. what you would need to route is the traffic from each client to that box in the first place.
Thanks for the quick reply. Can you explain "routing commons"? Also, does it matter what their their default gateways are if I'm simply trying to ping from within the machine? For example:
Distribution: Distribution: RHEL 5 with Pieces of this and that.
Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700
Rep:
This is what I do. Setup eth0 as the main nic gateway. Define an IP, netmask, gateway for the interface. Also setup dns ip in /etc/resolv.conf. Then for eth1 set only the IP and netmask values. Do not set a gateway on this nic. Now enable ip_forward like you did that should all that is needed.
This is what I do. Setup eth0 as the main nic gateway. Define an IP, netmask, gateway for the interface. Also setup dns ip in /etc/resolv.conf. Then for eth1 set only the IP and netmask values. Do not set a gateway on this nic. Now enable ip_forward like you did that should all that is needed.
Brian
Tried what you said and still a no go. I have ip_forward enabled, but I can't seem to ping one nic to another within the same physical box. Any suggestions?
Nic1: 10.0.0.80 eth3 - Local system interface
Nic2: 192.168.1.1 eth2 - Internet connected interface
Lets consider 192.168.1.1 which is connected to the internet router
1) ping localy for both interfaces to make sure the interface is up
2) ping your internet gateway from the local system to check whether the system is reachable if it works that subnet(192.168.1.0) is okie
3) you can also make sure by connecting a system in the same subnet like 192.168.1.10 and try pinging 192.168.1.1
4) vi /etc/sysctl.conf
net.ipv4.ip_forward = 1 # Add the above entry in the above file
5) you can set your 192.168.1.10's default gateway as 192.168.1.1 for 10.0.0.0/24 and check whether you receive a reply if you dont want to setup default gateway u can use the route add command
route add -host 10.0.0.80 gw 192.168.1.1 eth1 <------ this is to be configured in the local 192.168.1.10 system
7) ping now 192.168.1.10 ---> 192.168.1.1
ping now 192.168.1.10 ---> 10.0.0.80
As we have enabled forwarding both nic's should be pingable
To Make it as a router we need to configure the table NAT
After issuing the 3 commands hopefully it should work, it works for VPN Server as well.
The above settings are for your settings of eth2 and eth3 nic. In your case eth2 is connected to internet router and eth3 is the local network and systems connected within the 10.0.0.0/24 subnet should point thier gateway as 10.0.0.80 and so that systems in that network will be allowed internet access or to reach the sytem which is reachable via 192.168.1.0/24 subnet
It might be not of help at all, but I was wondering: since machines usualy start counting nic's starting from eth0, what happend to your eth0 and eth1?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.