networking – is it possible to get internet from another server in local network that has internet?

I have 2 servers, server A and server B. server B has access to the internet via the router. But, router doesn’t let server A to connect to internet by its policy and rules.

enter image description here

I’m thinking about giving internet to server A by means of server B.

enter image description here

I know that it’s possible to set a proxy on server B but I’m looking for a way that work on Layer3 of OSI while proxy works on Layer4. I’m actually looking for a layer 3 proxy. my computers run ubuntu.