I have an Ubuntu machine that is my firewall

The Machine has 2 NIC Cards. eth0 and eth1. eth1 is connected to a modem that gives it an IP of 10.10.1.X

eth1 is required to provide DHCP on 192.168.2.X and have another IP from a switch that is connected to a router that provides DHCP on 192.168.1.X

Currently this machine has the following IPs

eth0 -
eth1 - (DHCP Server, Gateway)
eth1:0 -

I am trying to accomplish the following

If a machine is connected to eth1 over a switch, It should be able to ping which

 (eth0)                  |----- [ Server]
 Ubuntu                  |
Firewall (eth1) ----- [Switch]-----[Modem+Router]
         (eth1:0)--------| \

My fundamental problem lies in the fact that I receive packets coming from 2.4 that are destined for the internet and I am able to route them properly using IpTables. Whereas, If a packet arrives for 1.10, I am supposed to send it back to the switch with the appropriate options set.

I have tried the following

  • setting the default gateway for 1.0 to be 2.1 at 2.4 and set the next hop as 1.1 which i hoped would do the right forwarding
  • I have also bridged eth1 and eth1:0 using bridge-utils and then applied iptables forwarding for anyone in 2.X wanting to go out to the internet from
  • 1
    1) Should eth1:0 be *192*.168.1.103? 2) Addresses are useless without netmasks/prefixes, please add them. 3) "If a packet arrives for 1.10..."; yes, but from where? 4) You mention setting a route on 2.4 for 1.0/?? via 2.1, but 2.1 does not appear on the diagram. By and large, this question would be improved by a big dose of show, not tell - show us examples of PINGs / TCP attempts that do/don't work, instead of just saying what you think you can and can't do. – MadHatter supports Monica Dec 17 '15 at 9:32

Your configuration generally should work out of the box. Routing in principle is supported by Linux routing code and has nothing to do with Netfilter. "iptables" is userspace utility for configuration of kernel Netfilter framework, which do filtering and packet modification (mangling and address translation), but does not do any routing. So it is incorrect to say "I route using iptables".

Bridging is also different sort of things and isn't supposed to help you here. Bridging of aliased interfaces probably should make a loop and thus break networking in that ethernet segment.

You need routes on both sides, for example, ip route add via on hosts in network and set up as default gateway on hosts in network.

If you have tightly set firewall on firewall box, you need to enable forwarding of traffic from eth1 to eth1:1 and back:

iptables -A FORWARD -i eth1 -o eth1:0 -j ACCEPT
iptables -A FORWARD -o eth1 -i eth1:0 -j ACCEPT

Or you might need only one first rule, if you alredy have configured stateful firewall with iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT or with -m state (obsolete).

Special iptables configuration is only needed if you want to masquerade that traffic, for hosts in to not know that you are connecting from network. Then you not need any additional routes on .1.0/24 side, but need NAT rule and forward enable rule:

iptables -t nat -A POSTROUTING -o eth1:1 -s -o -j SNAT --to-source
iptables -A FORWARD -i eth1 -o eth1:0 -j ACCEPT
  • Thanks @Nikita. The iptables -A FORWARD -i eth1 -o eth1:0 -j ACCEPT iptables -A FORWARD -o eth1 -i eth1:0 -j ACCEPT is what i was missing, And you are right. The bridging did not help because it should not. – Hitesh Dharamdasani Dec 17 '15 at 12:53

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.