LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-16-2018, 04:23 AM   #1
anon09
LQ Newbie
 
Registered: Jul 2018
Posts: 6

Rep: Reputation: Disabled
Iptables - cannot allow ONLY one lan to VPN


Hello...

I have two internal LANS. 192.168.10.4 and 192.168.42.2, with the same interface name enp33s0. I am connecting to a VPN on port TCP 443.

I would like to connect to VPN when I use 192.168.42.2 and block from 192.168.10.4.

Can anyone help me how to do that?


Thank you!
 
Old 07-17-2018, 05:34 PM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,783

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
That's not really a job for iptables, but should be easy with policy based routing. A search for that brings up a good introduction in the very first hit.

Last edited by rknichols; 07-17-2018 at 05:35 PM.
 
1 members found this post helpful.
Old 07-18-2018, 01:16 AM   #3
anon09
LQ Newbie
 
Registered: Jul 2018
Posts: 6

Original Poster
Rep: Reputation: Disabled
In the past I had 2 lines with iptables and it worked but not now.
 
Old 07-18-2018, 05:01 AM   #4
anon09
LQ Newbie
 
Registered: Jul 2018
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rknichols View Post
That's not really a job for iptables, but should be easy with policy based routing. A search for that brings up a good introduction in the very first hit.
Is better to do over ovpn file or in my linux machine?

Thank you
 
Old 07-18-2018, 08:36 AM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,783

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
You'll have to describe your setup in more detail. I interpreted your post to mean that you wanted to route outgoing traffic from one of your internal LANs via some external VPN provider. "Do over ovpn file" suggests that is not the case.
 
Old 07-18-2018, 10:19 AM   #6
anon09
LQ Newbie
 
Registered: Jul 2018
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rknichols View Post
You'll have to describe your setup in more detail. I interpreted your post to mean that you wanted to route outgoing traffic from one of your internal LANs via some external VPN provider. "Do over ovpn file" suggests that is not the case.
As I said I have two internal LANS. 192.168.10.4 and 192.168.42.2, (with the SAME PC) I am connecting to VPN (nordvpn ipvanish....etc) with port on TCP 443.

Everything works fine but I don't want to connect when I use 192.168.10.4, I want to block it. I am linux user and I am connecting in VPN with ovpn file via openvpn in mate environment.

I thought that I could do with iptables , So how can I route the traffic only at 192.168.42.2 and any other lans reject. I am thinking that I can do it over ovpn file or route command via terminal.

Would you like to tell me how to do that? I am searched a lots of examples but I cannot understand.

Thank you for your time.

Last edited by anon09; 07-20-2018 at 03:18 AM.
 
Old 07-20-2018, 10:58 AM   #7
anon09
LQ Newbie
 
Registered: Jul 2018
Posts: 6

Original Poster
Rep: Reputation: Disabled
Can anyone help? I try three week to find a solution.
 
Old 07-20-2018, 11:42 AM   #8
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,783

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
I haven't had a chance to look into the details. It would help to know what your routing looks like with the VPN active. Post the output from "ip route show" (wrapped in [CODE] ... [/CODE] tags, please).
 
Old 07-20-2018, 11:52 AM   #9
anon09
LQ Newbie
 
Registered: Jul 2018
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rknichols View Post
I haven't had a chance to look into the details. It would help to know what your routing looks like with the VPN active. Post the output from "ip route show" (wrapped in [CODE] ... [/CODE] tags, please).
This example is when I want to connect to a vpn.

default via 10.7.7.1 dev tun0 proto static metric 50
default via 192.168.42.3 dev enp33s0 proto static metric 100
10.7.7.0/24 dev tun0 proto kernel scope link src 10.7.7.13 metric 50
169.254.0.0/16 dev enp33s0 scope link metric 1000
192.168.42.0/24 dev enp33s0 proto kernel scope link src 192.168.42.24 metric 100
217.23.3.91 via 192.168.42.3 dev enp33s0 proto static metric 100

This example is when I DON'T want to connect to a vpn, but I want to block it.

default via 192.168.10.1 dev enp33s0 proto static metric 100
169.254.0.0/16 dev enp33s0 scope link metric 1000
192.168.10.0/28 dev enp33s0 proto kernel scope link src 192.168.10.3 metric 100
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
iptables - problem with rules( VPN tunnel and problem with access to server in LAN) jargrzyb Linux - Networking 2 09-05-2017 05:28 AM
Remote connection problem(build a separated lan in two VPN connected lan) William17 Linux - Networking 0 12-04-2011 01:33 AM
IPTABLES: Forward from VPN to LAN, Need traffic to appear as if its coming from LAN. a2brute Linux - Networking 3 11-17-2008 11:53 AM
sharing VPN access with lan + after vpn connected unable to ping lan/public ip xxx_anuj_xxx Linux - Networking 1 03-14-2008 02:50 AM
How to access VPN + LAN in iptables Firewall pradeepjagtap Linux - Security 4 10-24-2006 12:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration