Redirecting all IP over USB traffic to a fixed address

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












Say I have a device connected by IP over USB to my computer (running Ubuntu), that connects to 10.0.0.1. I configured my Ubuntu's Wifi over USB so that my computer's IP on that connection is 10.0.0.1, but I would actually like to redirect all traffic (on all ports) to another server, and just use my computer as a proxy.



I played around with some solutions, but my lack of familiarity with network concepts is slowing me down (I spend too much time looking stuff up, and the documentation is often a bit lacking). I'm not even sure if I want to set up a proxy, a firewall (I don't think so), or use the routing tables. What I want to do sounds pretty simple ("redirect anything coming from IP over USB to that server over there"). So is there a standard way of doing that? iptables? squid? ufw?










share|improve this question















migrated from serverfault.com Aug 12 '13 at 15:03


This question came from our site for system and network administrators.










  • 3




    For this use case, forget about USB. The network device driver presents the hardware in exactly the same way as any other network device. So if you find a generic solution, it will work for this, or any other Ethernet device.
    – EEAA
    Aug 12 '13 at 14:19














up vote
1
down vote

favorite












Say I have a device connected by IP over USB to my computer (running Ubuntu), that connects to 10.0.0.1. I configured my Ubuntu's Wifi over USB so that my computer's IP on that connection is 10.0.0.1, but I would actually like to redirect all traffic (on all ports) to another server, and just use my computer as a proxy.



I played around with some solutions, but my lack of familiarity with network concepts is slowing me down (I spend too much time looking stuff up, and the documentation is often a bit lacking). I'm not even sure if I want to set up a proxy, a firewall (I don't think so), or use the routing tables. What I want to do sounds pretty simple ("redirect anything coming from IP over USB to that server over there"). So is there a standard way of doing that? iptables? squid? ufw?










share|improve this question















migrated from serverfault.com Aug 12 '13 at 15:03


This question came from our site for system and network administrators.










  • 3




    For this use case, forget about USB. The network device driver presents the hardware in exactly the same way as any other network device. So if you find a generic solution, it will work for this, or any other Ethernet device.
    – EEAA
    Aug 12 '13 at 14:19












up vote
1
down vote

favorite









up vote
1
down vote

favorite











Say I have a device connected by IP over USB to my computer (running Ubuntu), that connects to 10.0.0.1. I configured my Ubuntu's Wifi over USB so that my computer's IP on that connection is 10.0.0.1, but I would actually like to redirect all traffic (on all ports) to another server, and just use my computer as a proxy.



I played around with some solutions, but my lack of familiarity with network concepts is slowing me down (I spend too much time looking stuff up, and the documentation is often a bit lacking). I'm not even sure if I want to set up a proxy, a firewall (I don't think so), or use the routing tables. What I want to do sounds pretty simple ("redirect anything coming from IP over USB to that server over there"). So is there a standard way of doing that? iptables? squid? ufw?










share|improve this question















Say I have a device connected by IP over USB to my computer (running Ubuntu), that connects to 10.0.0.1. I configured my Ubuntu's Wifi over USB so that my computer's IP on that connection is 10.0.0.1, but I would actually like to redirect all traffic (on all ports) to another server, and just use my computer as a proxy.



I played around with some solutions, but my lack of familiarity with network concepts is slowing me down (I spend too much time looking stuff up, and the documentation is often a bit lacking). I'm not even sure if I want to set up a proxy, a firewall (I don't think so), or use the routing tables. What I want to do sounds pretty simple ("redirect anything coming from IP over USB to that server over there"). So is there a standard way of doing that? iptables? squid? ufw?







linux networking iptables






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 21 at 8:18









Rui F Ribeiro

36.7k1271116




36.7k1271116










asked Aug 12 '13 at 14:14









Emile

1063




1063




migrated from serverfault.com Aug 12 '13 at 15:03


This question came from our site for system and network administrators.






migrated from serverfault.com Aug 12 '13 at 15:03


This question came from our site for system and network administrators.









  • 3




    For this use case, forget about USB. The network device driver presents the hardware in exactly the same way as any other network device. So if you find a generic solution, it will work for this, or any other Ethernet device.
    – EEAA
    Aug 12 '13 at 14:19












  • 3




    For this use case, forget about USB. The network device driver presents the hardware in exactly the same way as any other network device. So if you find a generic solution, it will work for this, or any other Ethernet device.
    – EEAA
    Aug 12 '13 at 14:19







3




3




For this use case, forget about USB. The network device driver presents the hardware in exactly the same way as any other network device. So if you find a generic solution, it will work for this, or any other Ethernet device.
– EEAA
Aug 12 '13 at 14:19




For this use case, forget about USB. The network device driver presents the hardware in exactly the same way as any other network device. So if you find a generic solution, it will work for this, or any other Ethernet device.
– EEAA
Aug 12 '13 at 14:19










1 Answer
1






active

oldest

votes

















up vote
4
down vote













What you are asking for is known as a NAT, a Network Address Translation. There are a number of tools that can provide NAT functionality, but at the IP address level it is probably easiest with iptables:



 iptables -t nat -I PREROUTING -d 10.0.0.1 --j DNAT --to 10.x.x.x


in the special nat table of iptables -t nat, insert at the first rule on the PREROUTING chain (-I PREROUTING), providing a destination nat -j DNAT where the incoming destination IP is to 10.0.0.1 (-d 10.0.0.1) over to the host 10.x.x.x (--to 10.x.x.x).



You may also need enable IP Fowarding, so your host acts as a network router with:



sysctl -w net.ipv4.ip_forward=1


And that should be it! (Just as simple as you thought it might be!)



Oh and both of these need to be ran as the root user, or via sudo (if you have access to run those commands via sudo!)






share|improve this answer






















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    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',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f86439%2fredirecting-all-ip-over-usb-traffic-to-a-fixed-address%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    4
    down vote













    What you are asking for is known as a NAT, a Network Address Translation. There are a number of tools that can provide NAT functionality, but at the IP address level it is probably easiest with iptables:



     iptables -t nat -I PREROUTING -d 10.0.0.1 --j DNAT --to 10.x.x.x


    in the special nat table of iptables -t nat, insert at the first rule on the PREROUTING chain (-I PREROUTING), providing a destination nat -j DNAT where the incoming destination IP is to 10.0.0.1 (-d 10.0.0.1) over to the host 10.x.x.x (--to 10.x.x.x).



    You may also need enable IP Fowarding, so your host acts as a network router with:



    sysctl -w net.ipv4.ip_forward=1


    And that should be it! (Just as simple as you thought it might be!)



    Oh and both of these need to be ran as the root user, or via sudo (if you have access to run those commands via sudo!)






    share|improve this answer


























      up vote
      4
      down vote













      What you are asking for is known as a NAT, a Network Address Translation. There are a number of tools that can provide NAT functionality, but at the IP address level it is probably easiest with iptables:



       iptables -t nat -I PREROUTING -d 10.0.0.1 --j DNAT --to 10.x.x.x


      in the special nat table of iptables -t nat, insert at the first rule on the PREROUTING chain (-I PREROUTING), providing a destination nat -j DNAT where the incoming destination IP is to 10.0.0.1 (-d 10.0.0.1) over to the host 10.x.x.x (--to 10.x.x.x).



      You may also need enable IP Fowarding, so your host acts as a network router with:



      sysctl -w net.ipv4.ip_forward=1


      And that should be it! (Just as simple as you thought it might be!)



      Oh and both of these need to be ran as the root user, or via sudo (if you have access to run those commands via sudo!)






      share|improve this answer
























        up vote
        4
        down vote










        up vote
        4
        down vote









        What you are asking for is known as a NAT, a Network Address Translation. There are a number of tools that can provide NAT functionality, but at the IP address level it is probably easiest with iptables:



         iptables -t nat -I PREROUTING -d 10.0.0.1 --j DNAT --to 10.x.x.x


        in the special nat table of iptables -t nat, insert at the first rule on the PREROUTING chain (-I PREROUTING), providing a destination nat -j DNAT where the incoming destination IP is to 10.0.0.1 (-d 10.0.0.1) over to the host 10.x.x.x (--to 10.x.x.x).



        You may also need enable IP Fowarding, so your host acts as a network router with:



        sysctl -w net.ipv4.ip_forward=1


        And that should be it! (Just as simple as you thought it might be!)



        Oh and both of these need to be ran as the root user, or via sudo (if you have access to run those commands via sudo!)






        share|improve this answer














        What you are asking for is known as a NAT, a Network Address Translation. There are a number of tools that can provide NAT functionality, but at the IP address level it is probably easiest with iptables:



         iptables -t nat -I PREROUTING -d 10.0.0.1 --j DNAT --to 10.x.x.x


        in the special nat table of iptables -t nat, insert at the first rule on the PREROUTING chain (-I PREROUTING), providing a destination nat -j DNAT where the incoming destination IP is to 10.0.0.1 (-d 10.0.0.1) over to the host 10.x.x.x (--to 10.x.x.x).



        You may also need enable IP Fowarding, so your host acts as a network router with:



        sysctl -w net.ipv4.ip_forward=1


        And that should be it! (Just as simple as you thought it might be!)



        Oh and both of these need to be ran as the root user, or via sudo (if you have access to run those commands via sudo!)







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Aug 12 '13 at 23:55

























        answered Aug 12 '13 at 22:03









        Drav Sloan

        9,20023038




        9,20023038



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f86439%2fredirecting-all-ip-over-usb-traffic-to-a-fixed-address%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay