Two subnets on one interface












0














I'm trying to configure a zoneminder video server that connects to IP cameras on the LAN but I would like the cameras to be on a different subnet to our office and I'm not sure how to accomplish that via static routes.



It seems that most other about this topic questions are based on having two subnets that each have a router with a gateway. What I'm trying to do is have eth0 connect to 192.168.1.0 and have the cameras be in 192.168.2.0 but be accessible by the server without needing any additional network devices.



Any ideas?










share|improve this question
























  • You'd have to modify every device on the network, but you could treat "192.168" as a class B network.
    – Elliott Frisch
    May 19 '14 at 18:40
















0














I'm trying to configure a zoneminder video server that connects to IP cameras on the LAN but I would like the cameras to be on a different subnet to our office and I'm not sure how to accomplish that via static routes.



It seems that most other about this topic questions are based on having two subnets that each have a router with a gateway. What I'm trying to do is have eth0 connect to 192.168.1.0 and have the cameras be in 192.168.2.0 but be accessible by the server without needing any additional network devices.



Any ideas?










share|improve this question
























  • You'd have to modify every device on the network, but you could treat "192.168" as a class B network.
    – Elliott Frisch
    May 19 '14 at 18:40














0












0








0


1





I'm trying to configure a zoneminder video server that connects to IP cameras on the LAN but I would like the cameras to be on a different subnet to our office and I'm not sure how to accomplish that via static routes.



It seems that most other about this topic questions are based on having two subnets that each have a router with a gateway. What I'm trying to do is have eth0 connect to 192.168.1.0 and have the cameras be in 192.168.2.0 but be accessible by the server without needing any additional network devices.



Any ideas?










share|improve this question















I'm trying to configure a zoneminder video server that connects to IP cameras on the LAN but I would like the cameras to be on a different subnet to our office and I'm not sure how to accomplish that via static routes.



It seems that most other about this topic questions are based on having two subnets that each have a router with a gateway. What I'm trying to do is have eth0 connect to 192.168.1.0 and have the cameras be in 192.168.2.0 but be accessible by the server without needing any additional network devices.



Any ideas?







networking interface routing






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 24 '18 at 17:04









Zanna

50.1k13131240




50.1k13131240










asked May 19 '14 at 18:07









user2696964

111




111












  • You'd have to modify every device on the network, but you could treat "192.168" as a class B network.
    – Elliott Frisch
    May 19 '14 at 18:40


















  • You'd have to modify every device on the network, but you could treat "192.168" as a class B network.
    – Elliott Frisch
    May 19 '14 at 18:40
















You'd have to modify every device on the network, but you could treat "192.168" as a class B network.
– Elliott Frisch
May 19 '14 at 18:40




You'd have to modify every device on the network, but you could treat "192.168" as a class B network.
– Elliott Frisch
May 19 '14 at 18:40










2 Answers
2






active

oldest

votes


















0














If are devices connected to the same switch you simple can add virtual interface



sudo ifconfig eth0:1 192.168.2.xxx netmask 255.255.255.0


You will have one nic with 2 ip address, but only network 192.168.1.xxx will have default gateway.






share|improve this answer





























    0














    Try changing /etc/network/interfaces to



    auto eth0
    iface eth0 inet static
    address 192.168.1.10
    netmask 255.255.255.0
    network 192.168.1.0
    broadcast 192.168.1.255
    gateway 192.168.1.1
    dns-nameservers 192.168.1.1

    auto eth0:1
    iface eth0 inet static
    address 192.168.2.10
    netmask 255.255.255.0
    broadcast 192.168.2.255


    Restart networking or reboot:



    sudo service networking restart 


    @2707974 's answer will produce:



    SIOCSIFADDR: File exists
    SIOCSIFFLAGS: Cannot assign requested address
    SIOCSIFFLAGS: Cannot assign requested address


    Sadly I don't have enough points to comment under his answer.



    Updated my answer: @2707974 pointed out that my original answer was bogus -> see question.






    share|improve this answer























    • should this work with dhcp for eth0 and static for eth0:1? I did this on 14.04 and it was working great and survived several reboots. Than today there was an issue, when I went to /etc/interfaces eth0 was still on dhcp but eth0:1 disappeared. Network manager was apt-get purged btw
      – user2696964
      Jun 3 '14 at 23:03












    • I can only guess that the problem is not in the configuration, since it did work for some time. Maybe try this question: IP address alias assigned by DHCP
      – goozez
      Jun 4 '14 at 7:16











    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f469272%2ftwo-subnets-on-one-interface%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    If are devices connected to the same switch you simple can add virtual interface



    sudo ifconfig eth0:1 192.168.2.xxx netmask 255.255.255.0


    You will have one nic with 2 ip address, but only network 192.168.1.xxx will have default gateway.






    share|improve this answer


























      0














      If are devices connected to the same switch you simple can add virtual interface



      sudo ifconfig eth0:1 192.168.2.xxx netmask 255.255.255.0


      You will have one nic with 2 ip address, but only network 192.168.1.xxx will have default gateway.






      share|improve this answer
























        0












        0








        0






        If are devices connected to the same switch you simple can add virtual interface



        sudo ifconfig eth0:1 192.168.2.xxx netmask 255.255.255.0


        You will have one nic with 2 ip address, but only network 192.168.1.xxx will have default gateway.






        share|improve this answer












        If are devices connected to the same switch you simple can add virtual interface



        sudo ifconfig eth0:1 192.168.2.xxx netmask 255.255.255.0


        You will have one nic with 2 ip address, but only network 192.168.1.xxx will have default gateway.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered May 20 '14 at 6:15









        2707974

        7,91352138




        7,91352138

























            0














            Try changing /etc/network/interfaces to



            auto eth0
            iface eth0 inet static
            address 192.168.1.10
            netmask 255.255.255.0
            network 192.168.1.0
            broadcast 192.168.1.255
            gateway 192.168.1.1
            dns-nameservers 192.168.1.1

            auto eth0:1
            iface eth0 inet static
            address 192.168.2.10
            netmask 255.255.255.0
            broadcast 192.168.2.255


            Restart networking or reboot:



            sudo service networking restart 


            @2707974 's answer will produce:



            SIOCSIFADDR: File exists
            SIOCSIFFLAGS: Cannot assign requested address
            SIOCSIFFLAGS: Cannot assign requested address


            Sadly I don't have enough points to comment under his answer.



            Updated my answer: @2707974 pointed out that my original answer was bogus -> see question.






            share|improve this answer























            • should this work with dhcp for eth0 and static for eth0:1? I did this on 14.04 and it was working great and survived several reboots. Than today there was an issue, when I went to /etc/interfaces eth0 was still on dhcp but eth0:1 disappeared. Network manager was apt-get purged btw
              – user2696964
              Jun 3 '14 at 23:03












            • I can only guess that the problem is not in the configuration, since it did work for some time. Maybe try this question: IP address alias assigned by DHCP
              – goozez
              Jun 4 '14 at 7:16
















            0














            Try changing /etc/network/interfaces to



            auto eth0
            iface eth0 inet static
            address 192.168.1.10
            netmask 255.255.255.0
            network 192.168.1.0
            broadcast 192.168.1.255
            gateway 192.168.1.1
            dns-nameservers 192.168.1.1

            auto eth0:1
            iface eth0 inet static
            address 192.168.2.10
            netmask 255.255.255.0
            broadcast 192.168.2.255


            Restart networking or reboot:



            sudo service networking restart 


            @2707974 's answer will produce:



            SIOCSIFADDR: File exists
            SIOCSIFFLAGS: Cannot assign requested address
            SIOCSIFFLAGS: Cannot assign requested address


            Sadly I don't have enough points to comment under his answer.



            Updated my answer: @2707974 pointed out that my original answer was bogus -> see question.






            share|improve this answer























            • should this work with dhcp for eth0 and static for eth0:1? I did this on 14.04 and it was working great and survived several reboots. Than today there was an issue, when I went to /etc/interfaces eth0 was still on dhcp but eth0:1 disappeared. Network manager was apt-get purged btw
              – user2696964
              Jun 3 '14 at 23:03












            • I can only guess that the problem is not in the configuration, since it did work for some time. Maybe try this question: IP address alias assigned by DHCP
              – goozez
              Jun 4 '14 at 7:16














            0












            0








            0






            Try changing /etc/network/interfaces to



            auto eth0
            iface eth0 inet static
            address 192.168.1.10
            netmask 255.255.255.0
            network 192.168.1.0
            broadcast 192.168.1.255
            gateway 192.168.1.1
            dns-nameservers 192.168.1.1

            auto eth0:1
            iface eth0 inet static
            address 192.168.2.10
            netmask 255.255.255.0
            broadcast 192.168.2.255


            Restart networking or reboot:



            sudo service networking restart 


            @2707974 's answer will produce:



            SIOCSIFADDR: File exists
            SIOCSIFFLAGS: Cannot assign requested address
            SIOCSIFFLAGS: Cannot assign requested address


            Sadly I don't have enough points to comment under his answer.



            Updated my answer: @2707974 pointed out that my original answer was bogus -> see question.






            share|improve this answer














            Try changing /etc/network/interfaces to



            auto eth0
            iface eth0 inet static
            address 192.168.1.10
            netmask 255.255.255.0
            network 192.168.1.0
            broadcast 192.168.1.255
            gateway 192.168.1.1
            dns-nameservers 192.168.1.1

            auto eth0:1
            iface eth0 inet static
            address 192.168.2.10
            netmask 255.255.255.0
            broadcast 192.168.2.255


            Restart networking or reboot:



            sudo service networking restart 


            @2707974 's answer will produce:



            SIOCSIFADDR: File exists
            SIOCSIFFLAGS: Cannot assign requested address
            SIOCSIFFLAGS: Cannot assign requested address


            Sadly I don't have enough points to comment under his answer.



            Updated my answer: @2707974 pointed out that my original answer was bogus -> see question.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Apr 13 '17 at 12:24









            Community

            1




            1










            answered May 30 '14 at 7:32









            goozez

            10815




            10815












            • should this work with dhcp for eth0 and static for eth0:1? I did this on 14.04 and it was working great and survived several reboots. Than today there was an issue, when I went to /etc/interfaces eth0 was still on dhcp but eth0:1 disappeared. Network manager was apt-get purged btw
              – user2696964
              Jun 3 '14 at 23:03












            • I can only guess that the problem is not in the configuration, since it did work for some time. Maybe try this question: IP address alias assigned by DHCP
              – goozez
              Jun 4 '14 at 7:16


















            • should this work with dhcp for eth0 and static for eth0:1? I did this on 14.04 and it was working great and survived several reboots. Than today there was an issue, when I went to /etc/interfaces eth0 was still on dhcp but eth0:1 disappeared. Network manager was apt-get purged btw
              – user2696964
              Jun 3 '14 at 23:03












            • I can only guess that the problem is not in the configuration, since it did work for some time. Maybe try this question: IP address alias assigned by DHCP
              – goozez
              Jun 4 '14 at 7:16
















            should this work with dhcp for eth0 and static for eth0:1? I did this on 14.04 and it was working great and survived several reboots. Than today there was an issue, when I went to /etc/interfaces eth0 was still on dhcp but eth0:1 disappeared. Network manager was apt-get purged btw
            – user2696964
            Jun 3 '14 at 23:03






            should this work with dhcp for eth0 and static for eth0:1? I did this on 14.04 and it was working great and survived several reboots. Than today there was an issue, when I went to /etc/interfaces eth0 was still on dhcp but eth0:1 disappeared. Network manager was apt-get purged btw
            – user2696964
            Jun 3 '14 at 23:03














            I can only guess that the problem is not in the configuration, since it did work for some time. Maybe try this question: IP address alias assigned by DHCP
            – goozez
            Jun 4 '14 at 7:16




            I can only guess that the problem is not in the configuration, since it did work for some time. Maybe try this question: IP address alias assigned by DHCP
            – goozez
            Jun 4 '14 at 7:16


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f469272%2ftwo-subnets-on-one-interface%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Human spaceflight

            Can not write log (Is /dev/pts mounted?) - openpty in Ubuntu-on-Windows?

            File:DeusFollowingSea.jpg