Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 06-24-2016, 12:32 PM   #1
LQ Newbie
Registered: Jul 2010
Posts: 13

Rep: Reputation: 5
Debian router with 3 interfaces


I'm running a debian system as a router which is working perfectly fine.

My current setup is the following:

eth0 is the interface towards the internet, it's plugged with a cable from my fiber output in to the router.

eth1 is the interface that forwards everything, this one is connected to a switch and then all the computers in the switch.

I run a DHCP server on the router, it's working perfectly fine.

My iptables looks like this:

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

iptables --table nat --append POSTROUTING --out interface eth0 -j MASQUERADE

iptables --append FORWARD --in-interface eth1 -j ACCEPT
Now I want to add a third network card (eth2)that I will connect to a wireless router (It's connected to the switch now and in bridge mode, works perfect.) and give the wireless clients a different subnet.

I know how to make that happen in my DHCP (dnsmasq) but I don't know how to make the appropriate iptable rules.

Is it even possible? Because eth0 needs to send the data to two different interfaces depending on what computer is communicating.

Thanks in advance.
Old 06-24-2016, 08:54 PM   #2
LQ Newbie
Registered: Jul 2010
Posts: 13

Original Poster
Rep: Reputation: 5
I made some progress:

I use this as my IP-tables:

#Enable internal interfaces to communication between each other

echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -A FORWARD -i eth0 -o eth2 -m state --state ESTABLISHED,RELATED \-j ACCEPT
iptables -A FORWARD -i eth1 -o eth2 -m state --state ESTABLISHED,RELATED \-j ACCEPT
iptables -A FORWARD -i eth2 -o eth1 -m state --state ESTABLISHED,RELATED \-j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to MY.EXTERNAL.IP.ADRESS

And this in my router /etc/network/interfaces:

#WAN port to get IP via DHCP

auto eth0
iface eth0 inet dhcp

#Configure LAN port

auto eth1
iface eth1 inet static

#Configure second LAN port

auto eth2
iface eth2 inet static

This enables me to ping and connect to the router via adress.

But when I plug in a computer, I get nothing.

I have enabled dnsmasq to listen to eth1 and eth2 and my DHCP-ranges looks like tis:

I also tried using netmask for the eth2 interface. Same thing there. I can ping from any other computer, but I cannot get any connection.

I also tried to make a static IP-adress while connecting to eth2 on the laptop plugged into the network card that runs eth2, but no dice.

Any ideas what I'm doing wrong?
Old 06-25-2016, 06:33 PM   #3
Registered: Mar 2008
Posts: 21,811

Rep: Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607Reputation: 3607
Might look at this too.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Centos 7] Router with 2 interfaces bryn1u Linux - Networking 8 01-10-2016 06:41 AM
Router command line interfaces keepStriving Linux - Networking 2 08-07-2013 08:51 PM
Linux router MTU between 2 interfaces dot_txt Linux - Networking 1 03-25-2011 06:51 AM
ifup: couldn't read interfaces file "/etc/network/interfaces" debian lenny lorimer73 Linux - Networking 1 08-24-2010 04:47 PM
problem with linux router with 2 interfaces arty Linux - Networking 6 07-01-2009 06:49 AM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:06 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration