LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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-30-2017, 08:29 AM   #1
arya6000
Member
 
Registered: Sep 2005
Posts: 30

Rep: Reputation: 15
route all traffic through another server with iptables?


Let's say I have 2 servers

Server A and Server B

I want all traffic from server B to pass through Server A, I understand one way to do this is by using a VPN server on Server A. But as far as I know there is a way to do this by using iptables which will be very reliable.

How can this be achieved by using iptables? both machines are running Debian Linux.
 
Old 07-30-2017, 11:24 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,292

Rep: Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322
Why not set up a default network route for B through A?
 
Old 07-30-2017, 12:10 PM   #3
arya6000
Member
 
Registered: Sep 2005
Posts: 30

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by business_kid View Post
Why not set up a default network route for B through A?
you mean something like this?

Code:
ip route del default  
ip route add default via IP_of_A

I lose my ssh connection as soon as I execute
Code:
ip route del default
 
Old 07-31-2017, 03:22 AM   #4
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,292

Rep: Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322
Of course you lose your connections when you delete the default route. What else did you expect to happen. If you don't configure things correctly, they shouldn't work.

Try man route. Just running 'route' with no options gives me this
Code:
bash-4.3$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.178.1   0.0.0.0         UG    304    0        0 wlan0
loopback        *               255.0.0.0       U     0      0        0 lo
192.168.178.0   *               255.255.255.0   U     304    0        0 wlan0
bash-4.3$
That's all set up automagically by dhcpcd and I never have to think about it, although I did cover the CCNA1-4 syllabus in former times.
 
Old 07-31-2017, 05:08 AM   #5
elcore
Senior Member
 
Registered: Sep 2014
Distribution: Slackware
Posts: 1,753

Rep: Reputation: Disabled
Could be the op read somewhere about TPROXY target, but lacks documentation.
I'd suggest starting with:
Code:
man iptables-extensions
However, there are certain rules and regulations involved because it may be considered a MITM attack to use this on external networks.
Should be fine if you own the network, but quite possibly against the forum rules to discuss the abuse of this feature.
 
Old 08-01-2017, 02:12 PM   #6
LVsFINEST
Member
 
Registered: Aug 2006
Posts: 99

Rep: Reputation: 21
Just set server A as the default gateway.
 
  


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
(OpenVPN) Route one user's traffic into tun0 with iptables Märk Owen Linux - Networking 0 05-20-2015 08:45 PM
Using iptables to route all outbound traffic to internal box jaredscott Linux - Networking 4 04-26-2014 03:33 PM
Route all traffic to Loopback with iptables altaf123 Linux - Networking 1 07-16-2013 12:37 PM
IPtables: Route outgoing traffic from internal host to only go a internet interface predatorz Linux - Networking 4 11-24-2010 09:05 AM
iptables command to route all incoming traffic ger88005 Linux - Networking 2 02-11-2008 09:40 AM

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

All times are GMT -5. The time now is 11:39 AM.

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