Multi subnet in ubuntu with dnsmasq

9,851

-----------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:
9,851

Related videos on Youtube

Fox Mulder
Author by

Fox Mulder

Updated on September 18, 2022

Comments

  • Fox Mulder
    Fox Mulder over 1 year

    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 trying with following command:

    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.

  • Fox Mulder
    Fox Mulder about 12 years
    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
    Fox Mulder about 12 years
    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
  • rwc
    rwc about 12 years
    You're going to need some kind of load balancing/firewall in place in order to correctly NAT the route the traffic.
  • Fox Mulder
    Fox Mulder about 12 years
    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 ....