BBB as router Ethernet to other peripherals


could anyone direct me to right way of doing BBB as “Virtual” router. Main functions it will be doing are:

  • receive data packets already encapsulated in IPv6+UDP headers from it’s peripherals,
  • will need to send these packets to server defined in these headers destination address fields,
  • receive packets from server,
  • send them to designated device on its peripherals according to receiver address.

So far my biggest question is how can I on BBB connect to some server and send him that data which I received so server would send me back reply (would know that source address is within my local “network”), also ideally as I understand server application should receive already unwrapped RAW data which was sent to BBB already in IPv6+UDP header.

Thank you in advance for any valuable replies.