Can I connect LAN and Internet using the same cable?

  LAN computers ------\
  Ubuntu server ------Switch
  ADSL Router --------/

I want to make LAN computers, server will have real IP and some "virtual" IP ADSL router will have

So all traffic will go via server where I can make statistics, filters etc.

  • Why would you want to do that instead of just fitting a second NIC into the server? – John Gardeniers Jan 10 '11 at 21:34

yes, you can. it's called router-on-the-stick configuration, just make sure your switch supports tagged vlans and put wan [adsl] and lan in separate vlans, connect trunk with tagging to the linux box.

under linux you treat separate vlans like they were separate interfaces. debian way of configuring those: here.


The ideal way would be to use VLANs.

But, if you don't have equipment that will support VLANs, you may be able to do this via a single network without VLANs.

You can put multiple IPs on a single interface, but normally the router system would notice that both the source and destination for the packets are on the same interface. You will have to disable this, it is called an ICMP redirect. You can disable it on the interface in question by writing "0" to the file /proc/sys/net/ipv4/conf/<ifname>/send_redirects.

The WAN and the LAN will need to have different IP address blocks, and you will also almost certainly have to disable DHCP on the WAN router, or configure it to only give addresses to the Ubuntu router machine.

You may also run into problems with other broadcast or multicast traffic, but this will probably work for some situations. However, realize that it is a very unusual configuration and is likely to require some futzing to get to work.


Take into consideration that as all traffic with go through that cable, the processing capacity of the NIC must be appropriate to support the worst traffic, and that anyway if things go wrong it's quite a... point of catastrophic failure ;-)

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.