LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-24-2024, 05:43 AM   #1
Jason.nix
Member
 
Registered: Feb 2023
Posts: 561

Rep: Reputation: 10
Post SSH only accepts connections from a specific IP address range


Hello,
I installed Docker on a Debian and my iptables rules are:
Code:
-P INPUT ACCEPT
-P FORWARD DROP
-P OUTPUT ACCEPT
-N DOCKER
-N DOCKER-ISOLATION-STAGE-1
-N DOCKER-ISOLATION-STAGE-2
-N DOCKER-USER
-A FORWARD -j DOCKER-USER
-A FORWARD -j DOCKER-ISOLATION-STAGE-1
-A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -o docker0 -j DOCKER
-A FORWARD -i docker0 ! -o docker0 -j ACCEPT
-A FORWARD -i docker0 -o docker0 -j ACCEPT
-A FORWARD -o br-646660b25eeb -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -o br-646660b25eeb -j DOCKER
-A FORWARD -i br-646660b25eeb ! -o br-646660b25eeb -j ACCEPT
-A FORWARD -i br-646660b25eeb -o br-646660b25eeb -j ACCEPT
-A FORWARD -o br-81041652e829 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -o br-81041652e829 -j DOCKER
-A FORWARD -i br-81041652e829 ! -o br-81041652e829 -j ACCEPT
-A FORWARD -i br-81041652e829 -o br-81041652e829 -j ACCEPT
-A FORWARD -o br-b13678883aac -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -o br-b13678883aac -j DOCKER
-A FORWARD -i br-b13678883aac ! -o br-b13678883aac -j ACCEPT
-A FORWARD -i br-b13678883aac -o br-b13678883aac -j ACCEPT
-A FORWARD -o br-1b1370bfafc6 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -o br-1b1370bfafc6 -j DOCKER
-A FORWARD -i br-1b1370bfafc6 ! -o br-1b1370bfafc6 -j ACCEPT
-A FORWARD -i br-1b1370bfafc6 -o br-1b1370bfafc6 -j ACCEPT
-A FORWARD -o br-f14b192fe8d5 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -o br-f14b192fe8d5 -j DOCKER
-A FORWARD -i br-f14b192fe8d5 ! -o br-f14b192fe8d5 -j ACCEPT
-A FORWARD -i br-f14b192fe8d5 -o br-f14b192fe8d5 -j ACCEPT
-A FORWARD -o br-e2386c174feb -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -o br-e2386c174feb -j DOCKER
-A FORWARD -i br-e2386c174feb ! -o br-e2386c174feb -j ACCEPT
-A FORWARD -i br-e2386c174feb -o br-e2386c174feb -j ACCEPT
-A FORWARD -o br-934ab550fff1 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -o br-934ab550fff1 -j DOCKER
-A FORWARD -i br-934ab550fff1 ! -o br-934ab550fff1 -j ACCEPT
-A FORWARD -i br-934ab550fff1 -o br-934ab550fff1 -j ACCEPT
-A FORWARD -o br-5a13cc881d3a -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -o br-5a13cc881d3a -j DOCKER
-A FORWARD -i br-5a13cc881d3a ! -o br-5a13cc881d3a -j ACCEPT
-A FORWARD -i br-5a13cc881d3a -o br-5a13cc881d3a -j ACCEPT
-A DOCKER -d 172.24.0.2/32 ! -i br-b13678883aac -o br-b13678883aac -p tcp -m tcp --dport 6379 -j ACCEPT
-A DOCKER-ISOLATION-STAGE-1 -i docker0 ! -o docker0 -j DOCKER-ISOLATION-STAGE-2
-A DOCKER-ISOLATION-STAGE-1 -i br-1b1370bfafc6 ! -o br-1b1370bfafc6 -j DOCKER-ISOLATION-STAGE-2
-A DOCKER-ISOLATION-STAGE-1 -i br-e2386c174feb ! -o br-e2386c174feb -j DOCKER-ISOLATION-STAGE-2
-A DOCKER-ISOLATION-STAGE-1 -i br-b13678883aac ! -o br-b13678883aac -j DOCKER-ISOLATION-STAGE-2
-A DOCKER-ISOLATION-STAGE-1 -i br-934ab550fff1 ! -o br-934ab550fff1 -j DOCKER-ISOLATION-STAGE-2
-A DOCKER-ISOLATION-STAGE-1 -i br-81041652e829 ! -o br-81041652e829 -j DOCKER-ISOLATION-STAGE-2
-A DOCKER-ISOLATION-STAGE-1 -i br-646660b25eeb ! -o br-646660b25eeb -j DOCKER-ISOLATION-STAGE-2
-A DOCKER-ISOLATION-STAGE-1 -i br-5a13cc881d3a ! -o br-5a13cc881d3a -j DOCKER-ISOLATION-STAGE-2
-A DOCKER-ISOLATION-STAGE-1 -i br-f14b192fe8d5 ! -o br-f14b192fe8d5 -j DOCKER-ISOLATION-STAGE-2
-A DOCKER-ISOLATION-STAGE-1 -j RETURN
-A DOCKER-ISOLATION-STAGE-2 -o docker0 -j DROP
-A DOCKER-ISOLATION-STAGE-2 -o br-1b1370bfafc6 -j DROP
-A DOCKER-ISOLATION-STAGE-2 -o br-e2386c174feb -j DROP
-A DOCKER-ISOLATION-STAGE-2 -o br-b13678883aac -j DROP
-A DOCKER-ISOLATION-STAGE-2 -o br-934ab550fff1 -j DROP
-A DOCKER-ISOLATION-STAGE-2 -o br-81041652e829 -j DROP
-A DOCKER-ISOLATION-STAGE-2 -o br-646660b25eeb -j DROP
-A DOCKER-ISOLATION-STAGE-2 -o br-5a13cc881d3a -j DROP
-A DOCKER-ISOLATION-STAGE-2 -o br-f14b192fe8d5 -j DROP
-A DOCKER-ISOLATION-STAGE-2 -j RETURN
-A DOCKER-USER -j RETURN
The SSH configuration file is as follows:
Code:
Port 22
ListenAddress 172.20.2.58
KbdInteractiveAuthentication no
UsePAM yes
X11Forwarding yes
PrintMotd no
AcceptEnv LANG LC_*
Subsystem	sftp	/usr/lib/openssh/sftp-server
My PC IP address is 172.21.50.67 and I can only connect to this server from the IP address range 172.20.2.X. Why?

Thank you.
 
Old 03-24-2024, 06:22 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,306

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Your config is going out to home users mainly. There's people in unsavoury parts of the world routinely scanning for open ports and taking advantage of any they find. A sysadmin will know how to setup /etc/sshd.conf to let in who he wants, but that's a safe default - your own network. That prevents users getting in to your network through the router.
 
Old 03-24-2024, 06:34 AM   #3
lvm_
Member
 
Registered: Jul 2020
Posts: 930

Rep: Reputation: 337Reputation: 337Reputation: 337Reputation: 337
Can you ping it? What's your routing (netstat -r)?
 
Old 03-24-2024, 10:05 AM   #4
Jason.nix
Member
 
Registered: Feb 2023
Posts: 561

Original Poster
Rep: Reputation: 10
Quote:
Originally Posted by business_kid View Post
Your config is going out to home users mainly. There's people in unsavoury parts of the world routinely scanning for open ports and taking advantage of any they find. A sysadmin will know how to setup /etc/sshd.conf to let in who he wants, but that's a safe default - your own network. That prevents users getting in to your network through the router.
Hello,
Thank you so much for your reply.
Yes, this is a private server.
 
Old 03-24-2024, 10:07 AM   #5
Jason.nix
Member
 
Registered: Feb 2023
Posts: 561

Original Poster
Rep: Reputation: 10
Quote:
Originally Posted by lvm_ View Post
Can you ping it? What's your routing (netstat -r)?
Hello,
Thank you so much for your reply.
Yes, I can ping that server. Do you mean netstat -r on that server?
 
  


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
squid accepts connections only from localhost stefanolima Linux - Software 5 06-26-2009 02:33 AM
M-Audio Fast Track Pro only accepts one audio connection at a time BorgAssimilator Linux - Hardware 0 09-29-2008 03:04 AM
Only KDE4 menu search accepts keyboard input Mark_667 SUSE / openSUSE 3 08-12-2008 10:39 PM
Apache won't accept or reject incoming internet connections but accepts on local lan zenchess Linux - Networking 3 06-10-2006 09:06 AM
df only accepts one argument ajwynn Linux - General 2 05-25-2006 06:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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