Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Can I connect LAN and Internet using the same cable?

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

I want to make LAN computers 192.168.0.2-50, server will have real IP 192.168.0.1 and some "virtual" IP 192.168.1.2. ADSL router will have 192.168.1.1.

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

share|improve this question
    
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
add comment

3 Answers

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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 ;-)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.