Community discussions

MikroTik App
 
ramirez
Member Candidate
Member Candidate
Topic Author
Posts: 157
Joined: Sun May 12, 2013 9:48 pm

Directing all internet traffic through a device

Mon Sep 16, 2019 2:26 pm

If anyone can please help with the following:

I have a raspberry Pi running Raspbian buster and is connected to vpn service provider.

That raspberry is connected on my Mikrotik router on which router my PC is also connected.

How can I run all traffic (to and from my PC) through the raspberry so that my PC also receives the vpn service? My PC has 192.168.10.25/24 and the Raspberry 192.168.10.33/24.

Thank you in advance.
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 13030
Joined: Thu Mar 03, 2016 10:23 pm

Re: Directing all internet traffic through a device

Mon Sep 16, 2019 2:32 pm

The easiest way would be to set Rpi's IP address as default gateway on PC. If PC is getting it's network settings via DHCP server, you'll have to create static DHCP lease for that PC. On that particular lease you'll set different IP address as gateway. (It will be some more work than I just wrote, but should direct you towards your goal).
If, OTOH, PC is set up statically, then just change settings on the PC.
 
ramirez
Member Candidate
Member Candidate
Topic Author
Posts: 157
Joined: Sun May 12, 2013 9:48 pm

Re: Directing all internet traffic through a device

Mon Sep 16, 2019 2:58 pm

Thank you mkx, I would like to try it with my PC first as then I would like to do the same for a media player that is also connected to the router. Therefore regarding the PC I would only wish to make changes on the router without changing any settings on the pc (as the media player is "dumb" and does not allow for changes other than entering a password to connect to wifi) .

I gave the PC a static address on the router but do not see (in winbox IP/DHCP server/ leases) an option to input a gateway after clicking on that particular static PC address, should I be looking into the IP/routes?
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 13030
Joined: Thu Mar 03, 2016 10:23 pm

Re: Directing all internet traffic through a device

Mon Sep 16, 2019 4:32 pm

It's not exactly trivial to enforce special config to particular host. Perhaps the easist way would be using DHCP options ... create new one with code=3 (that's default gateway), enter the value (no idea how it should look like) and assign this option to static DHCP lease. Hopefully explicit DHCP option will overwrite the one from generic DHCP network settings ...

I hope somebody more knowledgeable about DHCP options will pop up ...
 
ramirez
Member Candidate
Member Candidate
Topic Author
Posts: 157
Joined: Sun May 12, 2013 9:48 pm

Re: Directing all internet traffic through a device

Mon Sep 16, 2019 5:25 pm

Thank you mkx, I created in options a name raspberry with code 3 and '192.168.10.13' (with single quotes) rule, and assigned it to the static lease for my PC , but when I check "what is my IP address" on a browser it still shows my actual location when the raspberry shows a VPN location. If anything else comes in mind please let me know !
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 13030
Joined: Thu Mar 03, 2016 10:23 pm

Re: Directing all internet traffic through a device

Mon Sep 16, 2019 8:32 pm

Relevant RFC 2132 defines option format to be array of octets and first octet (after the DHCP option number) should be the length of the array (and must be multiple of 4). So I assume that when defining option value should be entered as HEX number, e.g. 0x04c0a80a0d ... I've no idea what should be the order of address octets (MSB or LSB) nor do I gave idea whether the previous value would translate to correct array of octets.

Anyway, when you're testing if the setting works, you should appply the change on RB, then disconnect and reconnect ethernet cable of the PC under test (I'm assuming wired connection; disable and re-enable wireless interface if you're using wireless connection) - keep it disconnected for at least 10 seconds, then wait for a few seconds for DHCP protocol to do the magic and then check the IP settings - router address in particular. If it changes from whatever is default setting on your DHCP server, then we're on right track and it remains to discover the right value format. If it doesnt, then we'll have to think of something else.

Who is online

Users browsing this forum: jaclaz and 104 guests