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 02-25-2014, 06:18 PM   #1
dinopunch4000
LQ Newbie
 
Registered: Feb 2014
Posts: 3

Rep: Reputation: Disabled
Configure two servers to only communicate with each other via SSH?


I have two servers, let's call them server1 and server2. I want to restrict them to only be able to communicate with each other via SSH.

I'm new to iptables, but I've written the following iptables rules on server1:
Code:
iptables -A INPUT -s server2 -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -s server2 -j DROP
This has the intended effect of only allowing server2 to connect to server1 over SSH, but it also has the unintended effect of preventing server1 from connecting to server2 at all. When I also do the reverse on server2, neither server can talk to the other.

Am I missing something here? Or is there perhaps a better way to do this than iptables?
 
Old 02-25-2014, 06:58 PM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
You can also set their subnets to be /31, which is two hosts. I generally set up p2p routers with that kind of subnet.

http://www.cyberciti.biz/tips/linux-...allow-ssh.html

Your ssh iptables question is very very common. Please see this URL for a quick howto.

Last edited by szboardstretcher; 02-25-2014 at 07:06 PM.
 
Old 02-25-2014, 07:11 PM   #3
dinopunch4000
LQ Newbie
 
Registered: Feb 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
That's not quite what I'm trying to do. I want to ensure that any communication that happens between server1 and server2 happens through SSH. I need to enable SSH communication, and only SSH communication between the two servers.
 
Old 02-25-2014, 07:19 PM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
A quote from that page:

"This script is purely strict firewall. It only allows incoming ssh. No other incoming service or ping request or no outgoing service or request allowed."

which is what you said:

"I need to enable SSH communication, and only SSH communication between the two servers."

Am i not understanding something in your request?

Last edited by szboardstretcher; 02-25-2014 at 07:21 PM.
 
Old 02-25-2014, 07:25 PM   #5
dinopunch4000
LQ Newbie
 
Registered: Feb 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
Oh, okay. Sorry, I must have missed the link in your first post. I'll try it out. Thanks for your help.
 
  


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
VMs on different servers cannot communicate sanaz Linux - Virtualization and Cloud 3 02-10-2013 04:26 PM
Getting two Linux servers to communicate (PING issues) orakris Linux - Networking 3 12-19-2010 08:04 AM
Can't communicate with servers on same subnet CarlKB Linux - Networking 3 04-20-2009 10:28 AM
configure network to communicate between two Virtual Machines. vikas027 Solaris / OpenSolaris 11 10-11-2008 12:56 AM
How to configure Squid to communicate with another proxy server? davidas Linux - Networking 1 05-19-2004 04:23 PM

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

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