Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a multi lan port box that install ubuntu server 11.10.

I am setup network in /etc/network/interfaces file as follow:


auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
     address 192.168.128.254
     netmask 255.255.255.0
     network 192.168.128.0
     broadcast 192.168.128.255
     gateway 192.168.128.1
     dns-nameservers xxxxxx

auto eth1
iface eth1 inet static
     address 192.168.11.1
     netmask 255.255.255.0
     network 192.168.11.0
     broadcast 192.168.11.255

auto eth2
iface eth2 inet static
     address 192.168.21.1
     netmask 255.255.255.0
     network 192.168.21.0
     broadcast 192.168.21.255

auto eth3
iface eth3 inet static
     address 192.168.31.1
     netmask 255.255.255.0
     network 192.168.31.0
     broadcast 192.168.31.255


I am also enable the ip forward by echo 1 > /proc/sys/net/ipv4/if_forward in rc.local.

my dnsmasq config as follow

except-interface=eth0
dhcp-range=interface:eth1,set:wifi,192.168.11.101,192.168.11.200,255.255.255.0
dhcp-range=interface:eth2,set:kids,192.168.21.101,192.168.21.200,255.255.255.0
dhcp-range=interface:eth3,set:game,192.168.31.101,192.168.31.200,255.255.255.0

the dhcp was working fine in eth1,eth2,eth3, any machine plug in the subnet can get correct subnet's ip.

My problem was, each subnet machine can't ping each other. for example.

192.168.11.101 can't ping 192.168.21.101 but can ping 192.168.128.1 192.168.31.101 can't ping 192.168.21.101 but can ping 192.168.128.1

I am also try to using route add -net 192.168.11.0 netmask 255.255.255.0 gw 192.168.11.1 (and also 192.168.21.0/192.168.31.0) at this multi-lan-port machine.

But still won't work.

Does anyone can help ? Thanks.

share|improve this question

3 Answers 3

What you're attempting to do is called "Multihoming" with multiple links and multiple address spaces. The problem you're facing is that there is no routing/networking configured and enabled between the different interfaces.

For traffic to pass back and forth between the interfaces, they'll need to be connected through an internal interface. Then you can NAT the external addresses if I'm correct. However, I think what you're trying to do is either going to require virtualization of another interface to associate the internal addresses with.

Essentially, you may be asking too much of the equipment you're describing.

What I would do in this case is configure an internal network that eth1, eth2, eth3 exist on to pass traffic to the NAT'd eth0.

Actually, after writing this response I've got another answer I'm about to respond with for organization's sake.

share|improve this answer
    
thanks your reply. what i trying to do was to split around 120 pcs from single class c, into 4 class c subnet. one class c (192.168.1.0) was connect to an ip-share machine that connecet to Internet. –  Fox Mulder Apr 3 '12 at 4:44
    
You're going to need some kind of load balancing/firewall in place in order to correctly NAT the route the traffic. –  RWC Apr 3 '12 at 17:57
    
I have an 4wans ports load balancing/firewall in 192.168.1.1 and the 192.168.1.0/24 class c net are working fine. Now I try to install this 4 ports linux box to split about 120 pcs into 4subnets. 30s for 192.168.1.0/24, 30s for 192.168.11.0/24, 30s for 192.168.21.0/24, 30s for 192.168.31.0/24 .... –  Fox Mulder Apr 3 '12 at 18:36

-----------Next answer------------

It's also possible that you've configured the gateway incorrectly for each interface. Please configure the interfaces as follows:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
 address 192.168.128.254
 netmask 255.255.0.0
 gateway 192.168.1.1
 network 192.168.128.0
 broadcast 192.168.128.255
 dns-nameservers xxxxxx

auto eth1
iface eth1 inet static
 address 192.168.11.1
 netmask 255.255.0.0
 network 192.168.11.0
 broadcast 192.168.11.255

auto eth2
iface eth2 inet static
 address 192.168.21.1
 netmask 255.255.0.0
 network 192.168.21.0
 broadcast 192.168.21.255

auto eth3
iface eth3 inet static
 address 192.168.31.1
 netmask 255.255.0.0
 network 192.168.31.0
 broadcast 192.168.31.255

With these changes, all of the interfaces should look to the same gateway and communicate properly. You may need to remove some of the routing that you did.

share|improve this answer
    
It's won't work, now, the subnet machine can't ping the interface now. for example, clinet 192.168.21.x can't ping 192.168.21.1 –  Fox Mulder Apr 3 '12 at 14:12

Hi I ham having a senario where I am using 3 lancards and they are able to ping I will just put up how i have configure u see if thats works for u or not as i think u need to enable packet forwarding /etc/sysctl.conf & may be u will also need to use iptables to route packets.Also disable firewall if it is enable to check. I know u have have configure in a almost similar way still can give a try as i am able to ping using the below configuration

/etc/network/interfaces:

-- The loopback network interface

auto lo iface lo inet loopback

-- The primary network interface

auto eth0 iface eth0 inet static address 192.168.1.15 netmask 255.255.255.0 gateway 192.168.1.1

--The secondary network interfaces

auto eth1 iface eth1 inet static address 10.0.0.15 netmask 255.0.0.0

auto wlan0 iface wlan0 inet static address 10.0.1.15

netmask 255.255.255.0

Give static ip but just mention correct gateway for the corresponding

pc-1 ip address - 10.0.0.21 subnet mask - 255.0.0.0 gateway - 10.0.0.15 dns - 10.0.0.15 dns - 192.168.1.15


pc-2 ip address - 10.0.1.21 subnet mask - 255.255.255.0 gateway - 10.0.1.15 dns - 10.0.1.15 dns - 192.168.1.15


I have enable packet forwarding for IPv4 and IPv6 (/etc/sysctl.conf)

Net.ipv4.ip_forward = 1

Net.ipv6.conf.all.forwarding = 1


This should work else you have to also use iptables and mention route for each interface u need Hope this works

I am not good with iptables i have found this on net and mentioning below the same

In case if u need to use iptable try below change the interface as u need to write the lines for all the interfaces as below is the example for 1 interfaces only as only 1 interface. I n this case I think eth0 will able to ping to eth1 for vice versa u need to mention same line for eth1 also

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

sudo iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT

sudo iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT

share|improve this answer

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.