LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-05-2013, 03:47 PM   #16
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444

with the VPN you probably need to get your server to push routing information to client


Also is the VPN server running on your target, or somewhere else on your local network?

If 'somewhere else' you may need a tap bridge instead of a tunnel, or iptable rules

You could run into problems if you use a common IP address like 192.168.0.x
best to mix it up a little, e.g 192.168.219.x so your client doesn't endup talking to something local to it instead of your VPN

Last edited by Firerat; 08-05-2013 at 03:50 PM.
 
Old 08-06-2013, 08:09 AM   #17
ilesterg
Member
 
Registered: Jul 2012
Distribution: Arch, Debian, and CentOS/RHEL
Posts: 539

Rep: Reputation: 56
Not sure if you've already done this, but have you already tried pinging the other box?

Also, what verifications have you made to check that the port on the other box is visible from the local box?
 
Old 08-12-2013, 02:43 AM   #18
NotAComputerGuy
Member
 
Registered: Jun 2012
Distribution: Linux Mint - Debian Edition
Posts: 349

Original Poster
Rep: Reputation: 13
Bit a of a delay with this, as it's "that time of the year" (interpret that as you like).

The VPN server is hosted through my employer so that I can work from home.

I've got two computers with SSH server running on them. I can log into both. I've changed my network to 192.168.168.xxx to ensure that it's less common. I've tried pointing my router at either computer for SSH, and neither respond from outside my network if the VPN client is connected. As soon as I disconnect the VPN, then I can connect from outside the network.

I believe (please remember I am not a computer person, just a regular guy who is a complete newbie with computers) that this, along with my router log, demonstrates my router port forwarding is working fine.

I need to be able to connect to my local network's public IP -> SSH, I'm sure if I talked really nicely to my work they would forward SSH traffic, but depending on which site I'm working for depends on which address I connect to for the VPN and therefore the public IP of that VPN would change too.
 
Old 08-12-2013, 05:23 AM   #19
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
Let me see I have this right..
  • Your router is setup as an OpenVPN Client to WorkOpenVPNServer
  • You are 'out and about' and want to ssh to a machine on your HomeNetwork
  • Your router is forwarding PublicIP:22 to 192.168.168.184:22
  • it fails

I think this is because your router is sending all traffic through the VPN

BUT lots of guessing going on there, I am probably way off.

please detail where the VPN Client is on your network
 
Old 08-12-2013, 05:28 AM   #20
NotAComputerGuy
Member
 
Registered: Jun 2012
Distribution: Linux Mint - Debian Edition
Posts: 349

Original Poster
Rep: Reputation: 13
Very nearly.

My Broadband connection comes via my router into which all devices are plugged into.
I have one main 'server' (a grand word for a very old computer left on all the time), which runs as a SSH server and an OpenVPN client into my work.

I want to take my laptop out and about and SSH into my 'server'. I connect into my public IP/Router which forwards on the connection into my 'server'.

If OpenVPN isn't running, it works fine. If OpenVPN is running, it fails.
 
Old 08-12-2013, 06:47 AM   #21
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
hmm,
try adding this to your OpenVPN client.conf


Code:
route 192.168.168.1 255.255.255.255 net_gateway

wait, that will probably kill the VPN

OK, back to your sshd config

Code:
# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
ListenAddress 192.168.168.184
restart sshd
Code:
sudo service ssh restart
cross fingers
 
Old 08-12-2013, 10:58 AM   #22
NotAComputerGuy
Member
 
Registered: Jun 2012
Distribution: Linux Mint - Debian Edition
Posts: 349

Original Poster
Rep: Reputation: 13
I'll try this when I get home.

Thanks
 
Old 08-12-2013, 11:33 AM   #23
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
Quote:
Originally Posted by NotAComputerGuy View Post
I'll try this when I get home.

Thanks
if that doesn’t work, then I'm sure something can be done with iptables PREROUTING
 
Old 08-12-2013, 02:19 PM   #24
NotAComputerGuy
Member
 
Registered: Jun 2012
Distribution: Linux Mint - Debian Edition
Posts: 349

Original Poster
Rep: Reputation: 13
Quote:
Originally Posted by Firerat View Post
if that doesn’t work, then I'm sure something can be done with iptables PREROUTING
It didn't work.

I'll have a look at Prerouting but I'm fairly sure it will make as much sense to me as iptables man page does.
 
Old 08-12-2013, 02:40 PM   #25
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
actually, preroute looks overkill

found this
http://serverfault.com/questions/425...nternal-server

which looks a perfect fit for you.

Last edited by Firerat; 08-12-2013 at 02:42 PM.
 
1 members found this post helpful.
Old 08-12-2013, 02:53 PM   #26
NotAComputerGuy
Member
 
Registered: Jun 2012
Distribution: Linux Mint - Debian Edition
Posts: 349

Original Poster
Rep: Reputation: 13
Goodness that does look pretty good!

In my journeys of searching trying to resolve this, I have changed the port to 443 (in case my ISP was blocking certain ports), which (I read) serves a two fold effect. 1) It will get round any public firewalls that try to restrict outgoing ports. 2) More importantly: It may assist in preventing anyone from trying to hack/crack/break into my SSH server as when they port scan me it doesn't look like an SSH server.

Would that interfere with my setup at all, as it's a machine with no monitor plugged in, so it's doubtfully any web browsing will occur on it.

Please feel free to re-educate me if either of these two 'facts' are not facts at all, as computers and their security are hardly my forté, but they certainly sound plausible.
 
Old 08-13-2013, 07:16 AM   #27
NotAComputerGuy
Member
 
Registered: Jun 2012
Distribution: Linux Mint - Debian Edition
Posts: 349

Original Poster
Rep: Reputation: 13
Quote:
Originally Posted by Firerat View Post
actually, preroute looks overkill

found this
http://serverfault.com/questions/425...nternal-server

which looks a perfect fit for you.
This has solved my problem. Unfortunately, it states that it's not permanent. Which bits will reset to default after a reboot and which bits won't? It states the tables will, but they all seem to mention table in.
Also, what's the best method of making it permanent in Debian? I've read about a few methods for making IP tables for example.

Thanks

Last edited by NotAComputerGuy; 08-13-2013 at 08:03 AM.
 
Old 08-13-2013, 08:04 AM   #28
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
you need to execute those commands once your VPN is up,
( ok not all of them, e.g. you no longer need
echo "201 novpn" >> /etc/iproute2/rt_tables
)
so I would look at how you are starting VPN, and if it will run post scripts for you

if you are starting via init.d service you could add to that
You could also have it 'undo' when the vpn is stopped ( via init.d )
 
Old 08-13-2013, 08:12 AM   #29
NotAComputerGuy
Member
 
Registered: Jun 2012
Distribution: Linux Mint - Debian Edition
Posts: 349

Original Poster
Rep: Reputation: 13
Thanks. The VPN starts through /etc/init.d/openvpn which runs at boot so it connects automatically for me. I had a look at that file and there doesn't seem to be anything obvious as to where to put extra commands. In fact, it looks horrifyingly complicated. None of the comments mention anything like "Run X once started" or words to that effect.

I have the commands I entered listed below a file with #!/bin/sh at the top. I have that saved in /etc/openvpn/ and it's executable.

Last edited by NotAComputerGuy; 08-13-2013 at 08:22 AM.
 
Old 08-13-2013, 08:54 AM   #30
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
ok,
I'm on Debian jessie/sid
which is not a million miles away from Mint Debian.

This is a little crude,
using sed to add two functions
one to 'fix ssh' and the other to 'undo the fix'

to get it to write, add -i

Code:
sed -e '/start_vpn ()/ i fix_ssh () {\
ip rule add fwmark 65 table novpn\
ip route add default via YOUR.GATEWAY.IP.HERE dev eth0 table novpn\
ip route flush cache\
iptables -t mangle -A OUTPUT -p tcp --sport 22 -j MARK --set-mark 65\
iptables -A INPUT -i tun0 -p tcp -m tcp --dport 22 -j DROP\
}\
undo_fix_ssh () {\
iptables -D INPUT -i tun0 -p tcp -m tcp --dport 22 -j DROP\
iptables -t mangle -D OUTPUT -p tcp --sport 22 -j MARK --set-mark 65\
ip route del default via YOUR.GATEWAY.IP.HERE dev eth0 table novpn\
ip rule del fwmark 65 table novpn\
ip route flush cache\
}'\
   -e 's/start_vpn$/& \&\& fix_ssh/' \
   -e 's/stop_vpn$/& \&\& undo_fix_ssh/' \
/etc/init.d/openvpn
if you have it as a script some place 'safe' you can use it to 'patch' again if mint updates /etc/init.d/openvpn

I should point out, untested.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Help with Ubuntu server remote ssh and local network ssh issues using putty. scottpops Linux - Server 8 05-17-2012 05:07 PM
sudden loss of ability to access network (can ssh in but not ssh out) lenafabr Red Hat 5 10-31-2008 08:33 AM
Cannot SSH from outside the network hradtke Linux - Networking 4 08-30-2006 02:33 AM
SSH - How can i alllow someone SSH to my network from Internet - please help me b:z Linux - Networking 4 04-05-2005 07:21 AM
can't telnet/ssh across network paul.nel Linux - Networking 4 11-14-2003 03:15 AM

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

All times are GMT -5. The time now is 02:18 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration