LinuxQuestions.org
Review your favorite Linux distribution.
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 01-19-2018, 05:07 PM   #1
liken
LQ Newbie
 
Registered: Jan 2018
Posts: 4

Rep: Reputation: Disabled
Linux as intermediate gateway?


Hello.

Unfortunately I have a router without firewall and I want to block p2p traffic from a LAN ip camera.

I have a Ubuntu Server in the LAN (1 NIC only) and my idea would be to configure this server as the camera gateway with firewall.


IP CAMERA -> UBUNTU INTERMEDIATE GATEWAY WITH FIREWALL --> ROUTER GATEWAY -->
IP:192.168.1.8 // IP:192.168.1.7 // IP:192.168.1.1
GW:192.168.1.7 // GW:192.168.1.1 //


So, basically Linux Server redirecting to real gateway router, but applying firewall rules previously.

Is this possible? How could it be done?
 
Old 01-20-2018, 02:51 AM   #2
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,804

Rep: Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140
You'll need two NICs to fulfil your ambition to use your Ubuntu server as a firewall...

https://killtacknine.com/building-an...rk-interfaces/
 
Old 01-20-2018, 03:36 AM   #3
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
It might be best to describe your setup in a little more detail. Your assertion that you have a router which opens a machine to the internet without filtering seems more than a little strange.
 
Old 01-20-2018, 04:23 AM   #4
liken
LQ Newbie
 
Registered: Jan 2018
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by 273 View Post
It might be best to describe your setup in a little more detail. Your assertion that you have a router which opens a machine to the internet without filtering seems more than a little strange.

Not strange. P2P IP Cameras connect automatically with an internet cloud server, so people do not need to configure routers or port forwarding. But this is a security hole and in fact I suspect somebody or a bot from China is controlling my camera through the insecure cloud. I use port forwarding so I don't need P2P and camera does not allow to disable it.

My Router is a usual router (Vodafone Vox UI) , you can configure NAT and port forwarding but there is nothing similar to iptables in order to block ports or connections started by LAN devices.


Quote:
Originally Posted by ferrari View Post
You'll need two NICs to fulfil your ambition to use your Ubuntu server as a firewall...

https://killtacknine.com/building-an...rk-interfaces/

But I do not want to replace my router with a Linux PC and 2 NICs. Also, I do not want 2 networks or 2 subranges. My idea is to use the Linux Server as a filter to block outside connections to the cloud from the camera. So I configure the camera with gateway 192.168.1.7 (linux server pc) instead of 192.168.1.1 (router), and Linux PC working as a router LAN to LAN (Instead LAN to WAN).
 
Old 01-20-2018, 04:42 AM   #5
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,804

Rep: Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140
Thanks for the added detail. I can understand that you want to block particular outgoing traffic from the camera, but I still don't get how you plan to implement this on an Ubuntu machine with only one network interface. I would consider purchasing an enterprise router to manage outgoing traffic.
 
Old 01-20-2018, 05:59 AM   #6
liken
LQ Newbie
 
Registered: Jan 2018
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ferrari View Post
Thanks for the added detail. I can understand that you want to block particular outgoing traffic from the camera, but I still don't get how you plan to implement this on an Ubuntu machine with only one network interface. I would consider purchasing an enterprise router to manage outgoing traffic.

Well. I just found another alternative.

I configure the camera without a gateway (or a invalid gateway). So, Camera has not internet access and cannot start outgoing traffic. Then, I map a Linux PC port to the camera port, they are in the same LAN. After this point Linux PC is acting as if it were the camera, but only with an open or allowed port, so it is an effective firewall. Then I configure port forwarding in router pointing to Linux Server instead of Camera.

IPTABLES rules in Linux PC are:

iptables -t nat -A PREROUTING -p tcp --dport 8181 -j DNAT --to-destination IP_CAMERA:8181
iptables -t nat -A POSTROUTING -p tcp -d IP_CAMERA --dport 8181 -j SNAT --to-source IP_LINUX_PC

This is working. I can reach the camera from Internet through 8181 port forwarding, but P2P apps are not able to reach the camera.
 
Old 01-20-2018, 07:59 AM   #7
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Quote:
Originally Posted by liken View Post
Not strange. P2P IP Cameras connect automatically with an internet cloud server, so people do not need to configure routers or port forwarding. But this is a security hole and in fact I suspect somebody or a bot from China is controlling my camera through the insecure cloud. I use port forwarding so I don't need P2P and camera does not allow to disable it.

My Router is a usual router (Vodafone Vox UI) , you can configure NAT and port forwarding but there is nothing similar to iptables in order to block ports or connections started by LAN devices.





But I do not want to replace my router with a Linux PC and 2 NICs. Also, I do not want 2 networks or 2 subranges. My idea is to use the Linux Server as a filter to block outside connections to the cloud from the camera. So I configure the camera with gateway 192.168.1.7 (linux server pc) instead of 192.168.1.1 (router), and Linux PC working as a router LAN to LAN (Instead LAN to WAN).
Thank you for explaining and confirning that your router does not simply expose ports to the internet.
If you're worried about the webcam get a refund.
Or set up specific rules on your router that the webcam is not allowed toi "dial out".
The
 
Old 01-21-2018, 07:40 AM   #8
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Rep: Reputation: 103Reputation: 103
So you configured two IPs on the same NIC of your Linux machine and the camera has an ip belonging to a subnet under the main subnet of your lan?
 
Old 01-21-2018, 05:03 PM   #9
liken
LQ Newbie
 
Registered: Jan 2018
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by vincix View Post
So you configured two IPs on the same NIC of your Linux machine and the camera has an ip belonging to a subnet under the main subnet of your lan?
No. Linux PC, 1 NIC, 1 IP.

Linux PC doing network address translation (NAT) in same NIC, unique IP, in order to map or link a camera port to a local port (similar to tunnels with reverse SSH, but with iptables and NAT). So Camera can be disconnected from Internet (No configured Gateway) and it is only visible in local ethernet network. For all intents and purposes Linux PC has the port of the camera and any port forwarding in router is pointed to this PC.

Last edited by liken; 01-21-2018 at 05:10 PM.
 
Old 01-21-2018, 06:34 PM   #10
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,804

Rep: Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140
Yes, interesting use of NAT with a single interface/network.
 
  


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
Intermediate Linux user here skirtum LinuxQuestions.org Member Intro 8 05-23-2017 04:18 AM
Intermediate Linux user. technokiddietoy LinuxQuestions.org Member Intro 3 10-07-2012 03:06 AM
Hi, Linux intermediate here timesheet LinuxQuestions.org Member Intro 1 07-11-2012 12:47 PM
VM as intermediate gateway mowglinz Linux - Wireless Networking 1 04-03-2011 08:21 PM
Distro For a Intermediate Linux User iotc247 Linux - Distributions 7 10-05-2004 09:06 AM

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

All times are GMT -5. The time now is 09:40 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