ip/Port forwarding

Hello OpenSuse community!

Am quite the newbie when it comes to this, so this might be easy, hard or impossible, but here goes!

I have a box with two NICs.

eth0 is 192.168.3.3
eth1 is 192.168.1.7

Default gateway is 192.168.1.1

What I want to do, is access a second computer (268.23.256.34) via ssh. and it has to be done through the 192.168.3.1 gateway.

So my questions are:

Can I somehow set up a port forwarding from 192.168.1.7:222 to 268.23.256.34:22 via 192.168.3.1 as gateway?

Or is it simpler to do it from 192.168.3.3:222?

And how do I do it?

Have tried to read up a bit on ip, iptables and such, but too much information makes me unsure what is the best practice etc…

Cheers,

Richard

:~ # more /etc/SuSE-release
openSUSE 11.2 (x86_64)
VERSION = 11.2
:~ # uname -srv
Linux 2.6.31.14-0.6-desktop #1 SMP PREEMPT 2010-12-10 11:18:32 +0100

You add a routing entry to your routing table on the box with the two nics using this command :

route add -host 268.23.256.34 gw 192.168.3.1

but I think this command will not survive a reboot. I’ll have to get to my openSUSE to check how to make it permanent or You could check if there is a GUI in Yast to do this.

Best regards,
Greg

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

If you’re SURE you should be going through 3.1 (instead of 1.1) then you
would basically need to add a host route that tells your computer that all
packets destined for 268.23.256.34 (you know this is a completely invalid
IP address, right?) should go through 192.168.3.1.

I think this would do it:

sudo ip route add 268.23.256.34 via 192.168.3.1

Good luck.

On 01/12/2011 08:06 AM, rydman wrote:
>
> Hello OpenSuse community!
>
> Am quite the newbie when it comes to this, so this might be easy, hard
> or impossible, but here goes!
>
> I have a box with two NICs.
>
> eth0 is 192.168.3.3
> eth1 is 192.168.1.7
>
> Default gateway is 192.168.1.1
>
> What I want to do, is access a second computer (268.23.256.34) via ssh.
> and it has to be done through the 192.168.3.1 gateway.
>
> So my questions are:
>
> Can I somehow set up a port forwarding from 192.168.1.7:222 to
> 268.23.256.34:22 via 192.168.3.1 as gateway?
>
> Or is it simpler to do it from 192.168.3.3:222?
>
> And how do I do it?
>
> Have tried to read up a bit on ip, iptables and such, but too much
> information makes me unsure what is the best practice etc…
>
> Cheers,
>
> Richard
> —
>
> :~ # more /etc/SuSE-release
> openSUSE 11.2 (x86_64)
> VERSION = 11.2
> :~ # uname -srv
> Linux 2.6.31.14-0.6-desktop #1 SMP PREEMPT 2010-12-10 11:18:32 +0100
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJNLcdDAAoJEF+XTK08PnB5bgkQAMjZk0l+69ARDP9Wi14SVw5Q
gjkXdlLWoAVMEI75J1ArJluTb5uVaHRJf5lPOq9DOL/SauqGhLDj0YUwOzImiLmk
hcgdi4FwRaB45v2rmnGPek4L/qeXT4nDZUNt/CB064TNNg66Q4o+Hwk55YsJCuRl
dREEIQCpXrUNcPWZJZgBgLzGL8MCO/UlbXuyFrxU+p9RbIu+eKV6tIl58hbF2M1J
M0wOZMC+Ym3dr0ZVwBeR7/ckYJdLSsW8Y/ZtRIGacbw73C/D7Zhc0u+BM+mlM6Fq
S5AIJVGB0fWH3Af8RN+l9ULWwqB63rffR+D50OW8AyPfGeFaxGV78tpT+HoB9i84
yXhW9PJAXL1Rz02dFQKX7dtLM7EipYIUPjVN4i7Re3GOTDyCocSAxFM2lq87xhkc
MQC7/g6JG/t9zPTUd3Z8BwsBif74xQLOFIMJh4b5l1WlwPOtdflcL1PlCUxjkzJR
dth6JebpCfeKo+og7PIgpZIY8NUsSW1lt/j7nToMSWW9/7n7Otu5mp1afE23/M8Q
DPF2IkZP+/ioTR9GHSrd6gHH3cvha++vxSsnlxu2NXlrePjOlaNu4YargXPiUBQy
ATdR5VJVT1ty9YN2VmclrarX8RrVbcRblxx1xDk6lhTvUwBcq9InuhzPsdosooUt
djFC4hoHPcjHSQy9RGig
=K4He
-----END PGP SIGNATURE-----

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

For completeness, this is a pretty good set of examples found online:

http://linux-ip.net/html/tools-ip-route.html

Good luck.

On 01/12/2011 08:22 AM, ab@novell.com wrote:
> If you’re SURE you should be going through 3.1 (instead of 1.1) then you
> would basically need to add a host route that tells your computer that all
> packets destined for 268.23.256.34 (you know this is a completely invalid
> IP address, right?) should go through 192.168.3.1.
>
> I think this would do it:
>
> sudo ip route add 268.23.256.34 via 192.168.3.1
>
> Good luck.
>
>
>
>
>
> On 01/12/2011 08:06 AM, rydman wrote:
>
>> Hello OpenSuse community!
>
>> Am quite the newbie when it comes to this, so this might be easy, hard
>> or impossible, but here goes!
>
>> I have a box with two NICs.
>
>> eth0 is 192.168.3.3
>> eth1 is 192.168.1.7
>
>> Default gateway is 192.168.1.1
>
>> What I want to do, is access a second computer (268.23.256.34) via ssh.
>> and it has to be done through the 192.168.3.1 gateway.
>
>> So my questions are:
>
>> Can I somehow set up a port forwarding from 192.168.1.7:222 to
>> 268.23.256.34:22 via 192.168.3.1 as gateway?
>
>> Or is it simpler to do it from 192.168.3.3:222?
>
>> And how do I do it?
>
>> Have tried to read up a bit on ip, iptables and such, but too much
>> information makes me unsure what is the best practice etc…
>
>> Cheers,
>
>> Richard
>> —
>
>> :~ # more /etc/SuSE-release
>> openSUSE 11.2 (x86_64)
>> VERSION = 11.2
>> :~ # uname -srv
>> Linux 2.6.31.14-0.6-desktop #1 SMP PREEMPT 2010-12-10 11:18:32 +0100
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJNLchYAAoJEF+XTK08PnB5qkAP+wewDJSjqOdH0mB6tcp76whs
04nsDwPY5HbmmueCcBkKjRDlpaDgp6+4lQNOsmVO/vXIdmb1HcXSD5Z0ao8sHA3L
RbqOXdz/WW1Xzp33uSkShlbaJBQsis472RMt08UuNRa8HSKSh88vOHnmLSE0n/PE
wSfX0oZ68xL70xDB3GFfBp5qmYlGHPdYeoYm/YX6Q0PWGvEmHlVPCBQKv7wveOZG
wUT9n7mlvOG8IMw1+NLwhAvohZ4bDofyP7AekVq21Fny25szH24eRZLOO/FcNLUR
4ohIGzSFafatFDDV2gyqfCZ1A2AWBF1qILr6xZhQpH6iQ4o2Qegu+5f2K8hx0NgK
/JyiMFTL2CRhi4O8Mn4l28YDJqZuyN9S7uBMG6yjR+R6ksqNN2RbfTEQdSC8HMm/
T3SN6flICvjh7e0zu5w6ewb8hAMVpF/qv7wLaS4+PYplQrjlJUOazjuIRX/9CXG0
OWMkM2/TK6W+yrbSzrSYuTblYOzCbfD/Mzq3oHtY0P/o9HloHZJteQOYEisZlhpW
OGhwIhCu3lh4ZcLoGlEoYIFZh0lITMk3UZhhXbEaXoVLHDC/vI857sPFiVe4yRTR
r+KA6ZZhPKk1JR3v1yiQ1UQmS9Ss+idyYw6u+lkL+667jgbD87hUS8HlO2xNqhkn
dwE/v93slvLt0KeIl+ir
=A8QZ
-----END PGP SIGNATURE-----

Thanks for all the replies! Will try tomorrow when I have access to the box.

And just to clarify, I want to able to type

ssh 192.168.1.7 -p 222 (alt 192.168.3.3)
and end up at 268.23.256.34:22 using the 192.168.3.3 gw.

268.23.256.34 (yes, fake i know) only accepts connections from this gw, so has to use that one.

And will read up a bit more on this!

Cheers,

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Um… when you say that the destination box will only accept a
connection from a certain box then routing is not the right way to go
since routing doesn’t change a source IP. You may be looking for
something more like tunneling or port forwarding in that case. Knowing
that requirement makes a big difference.

Good luck.

On 01/12/2011 09:36 AM, rydman wrote:
>
> Thanks for all the replies! Will try tomorrow when I have access to the
> box.
>
> And just to clarify, I want to able to type
>
> ssh 192.168.1.7 -p 222 (alt 192.168.3.3)
> and end up at 268.23.256.34:22 using the 192.168.3.3 gw.
>
> 268.23.256.34 (yes, fake i know) only accepts connections from this gw,
> so has to use that one.
>
> And will read up a bit more on this!
>
> Cheers,
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJNLeZaAAoJEF+XTK08PnB5CLkQAJQFcQZDbvxzzEKAYeqna1TR
Sr/KceNMFb4nxQ8Y8JGmj7N0GsxlVEYYFXdwyXOBReSI6deKflPqfrgSbk+yGs99
sDkVgUk2VhOh3+JZIGkVuna76ay80qNf7d9TYQ3a2Zn1IheyHioOzGUADD4myAJc
54mzZruoRsLjXLP8fU5VbT4oPV9dIUvnt/QEUDQZH7xRWTjjIBe0FjGQyEJUXTHF
kILN//BZqWy3Qpl2aD3inPqyttsEjfMGl8Osa+SdOdtAqTzV/XdEVEuJpEbv1FQn
jsOPcIHJ5oBhIhOeCpC4C6iljnYfxLviSmKCNGC/SowoB5O3zSaMtHFyHzmqQ2Kt
Ihhfn1kz+W84X8haLF5w0dh6Zgf9uUzKhEbrzG8A289SFXJsPKrJpYypqepMgtpF
CeVbyp04VLnHHuRZHuDZKUcjZXFQOVO/jgcq5w+hu7uP7cITMgp3epz2ycF1tVr1
yAlHE4t1APNQVN9Blmn6B5fXcNO39zKVhW2XT/0LLUenLykBwgoqZiZAatUJKVFt
ZIGlB0jnYKqNrPAaFXE5hiAU9bOc8C+ZUZ1v3iIxxZ4T4BYOnIYJ4vS7c4zwD/a/
iqHJWKixheQPHJh7p0Ts4ZK417jZOKQx1kR/nFtAbC+qwx9lfeBb1ki1Dxt4ZtN1
goDrL0xV3aAzepREGHTx
=Frhm
-----END PGP SIGNATURE-----

On 01/12/2011 06:36 PM, rydman wrote:
>
> Thanks for all the replies! Will try tomorrow when I have access to the
> box.
>
> And just to clarify, I want to able to type
>
> ssh 192.168.1.7 -p 222 (alt 192.168.3.3)
> and end up at 268.23.256.34:22 using the 192.168.3.3 gw.
>
> 268.23.256.34 (yes, fake i know) only accepts connections from this gw,
> so has to use that one.
>

Assuming you can ssh to “gatewaymachine” and your “finalmachine” accepts
ssh from “gatewaymachine”, then basically:

ssh -t gatewaymachine ssh finalmachine

Vahis

http://waxborg.servepics.com
openSUSE 11.3 (x86_64)
2.6.34.7-0.7-default