0

we use an internal little server with a dhcpd service (pxe system). The server has two nic's: - LAN (PXE) - WAN (uplink of remaining company lan / network)

WAN NIC is auto configured by DHCP server.

I need to route the traffic beetween these nic's.

Client's on LAN side should be have an internet connection (internet connection of wan side but there may not be traffic of dhcp on wan).

How can I implement it ?

1

Found the soulution by myself.

eth0 = WAN eth1 = LAN

Enable ip forwarding in kernel:

echo 1 > /proc/sys/net/ipv4/ip_forward

Adding iptables rules for nat:

iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface eth1 -j ACCEPT

& restart your network :-)

|improve this answer|||||
0

You have to be careful with that NAT rule; ANY packet leaving the eth0 interface will have its source IP address and port changed to the IP address of the eth0 interface (random port), even if the source of the connection is your server. This could affect services on your server that send traffic from eth0 and expect to not have its ports changed.

For example, if you're running an IPSec VPN service bound to the eth0 interface on your server, it will have the source port in its outbound packets changed and thus will cause the connection to fail.

I recommend you change that NAT rule to the following:

 iptables --table nat --append POSTROUTING --source $lan_network --out-interface eth0 -j MASQUERADE

This will ensure that ONLY your LAN network's Internet connections will be masqueraded out of the WAN interface.

Hope this helps :)

|improve this answer|||||

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.