LinuxQuestions.org
Visit Jeremy's Blog.
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 11-13-2008, 01:39 PM   #1
dahweeds
LQ Newbie
 
Registered: Nov 2008
Posts: 24

Rep: Reputation: 0
can is send multiple ports out through one port on CentOS via iptables?


Thanks for looking at this post.
I am trying to make Hamachi work seamlessly in a small office.
By the bosses orders I can only allow ports open per machine and all others closed. The problem is that the linux version of Hamachi cannot specify the TCP port. Windows versions are able.

When Hamachi tries to connect to the VPN mediation server, it uses a TCP connection with a variable port. Afterward the tunneling happens on a UDP connection. I can open the port for UDP, but when the linux box tries to get peer information from the mediation server it sends out some request through ###.###.###.###:30000-60000 (guess of dynamic range), but this is blocked by the router on the way back.

At present, I have seen that this contact normally takes place through ports between the guess above so I have set a trigger on the router firewall to allow this short communication. But this is borderline with the boss. The boss really wants all ports shut except for the individual communication port for each VPN host.

My question is Can I use some iptables to force the request from my linux host out to the mediation server through the available port?

Maybe it looks like this:
Code:
               |-30000-|               
               |       |                  |
Linux host     |       |-iptables|-123456-|-Meidation server-|
dynamic request|       | redirect|        |                  | 
               |       |                  |                  |
               |-60000-|                  |                  |
                                          |                 \ /
                                    Router Firewall          |
                                          |                  |
                                          |                  |
linux host     |                          |                  |
recieves info  |---------<---------123456-|--------<---------|
thanks again if you have any ideas.
 
Old 11-13-2008, 07:07 PM   #2
OdinnBurkni
Member
 
Registered: Feb 2007
Location: Iceland
Distribution: Fedora 14, CentOS, FreeNAS
Posts: 127

Rep: Reputation: 20
Port opening

Hi there.
I'm not sure I remember this correctly but you should be able to use established related commands. Don't remember exactly how to use it, would have to take a look at my iptables but I hope this will give you an idea.

Regards,
Odinn Burkni
 
Old 11-13-2008, 08:54 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,691

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
You can configure a static UDP port in linux. The TCP port does not matter.

http://logmeinwiki.com/wiki/Hamachi:...coming_traffic
 
Old 11-14-2008, 08:11 AM   #4
dahweeds
LQ Newbie
 
Registered: Nov 2008
Posts: 24

Original Poster
Rep: Reputation: 0
Thanks for the encouraging words.

Thanks Odinn, I have been trying to understand Iptables for this, but have not had a lot of time. Since my trigger hack is working now, I am trying to manage some other thing at the moment. If you come by any clues in your free time please post.

Thanks too Michealk, I have that UDP according to Hamachi set up and it does work for the data tunnel on the 5.*.*.* ip addresses. But there is one step in Hamachi's communication that goes via TCP. I will show some clips from a 'hamachi start debug session' that may keep the issue cleared up.
Code:
[root@myhost ~]# hamachi start debug
.
**** it will hang here if I turn the firewall on. 
**** this step uses a dynamic port (43352 this time, apparently
**** via TCP which I cannot open on the fire wall.
11 10:57:39.878 [   3] [14527] ses: connecting to 69.25.21.229:12975 ..
11 10:57:39.897 [   4] [14527] ses: io_ready -- 192.168.1.19:43352
.
**** Later, this connection uses the correct port 
**** (specified by UdpPort ##### in .hamachi/config)
.
11 10:57:40.313 [   8] [14527] ses: udp sock -- 192.168.1.19:12345
.
**** The peer will show up with 5.*.*.*:12345 ipaddress from other peers.
**** So with the firewall off, I can connect to the networks. 
.
11 10:57:40.758 [  14] [14527] ses: received network myhamachinetwork
At this point, I turn on the firewall again.
Not long after (about 1 minute) I lose the connections.
Notice the 'io_ready' step. My host has lost the ip.
Code:
11 11:29:39.637 [3351] [14709] ses: connecting to 69.25.21.229:12975 ..
11 11:32:48.645 [3352] [14709] ses: io_ready -- 0.0.0.0:46014
11 11:32:48.645 [3352] [14709] ses: state 3.0 -> 3.1
11 11:32:48.645 [3352] [14709] ses: state 3.1 -> 4.0
11 11:32:48.645 [3352] [14709] ses: sending helo ..
11 11:32:48.645 [3352] [14709] ses: error 2 send 32 33
11 11:32:48.645 [3352] [14709] ses: error 2 send 32 33
11 11:32:48.645 [3352] [14709] ses: go_offline
Now when I open the dynamic TCP range of firewall ports (port forward or trigger) this connection succeeds. So I want to map the range in a way that the io_ready communication will flow out through the one allowable open port.

Thanks again for your help.

By the way, I have used the iptables with
Code:
-A POSTROUTING -o ham0 -j MASQUERADE
enabled and disabled but it does not affect this issue.
 
Old 11-16-2008, 04:26 PM   #5
OdinnBurkni
Member
 
Registered: Feb 2007
Location: Iceland
Distribution: Fedora 14, CentOS, FreeNAS
Posts: 127

Rep: Reputation: 20
Established related.

Hello again.
Not sure if it's the right one but you could try this:
Code:
-A FORWARD -p ALL -m state --state ESTABLISHED,RELATED -j ACCEPT
You might also want to look at this site:
http://www.kalamazoolinux.org/presen...conntrack.html

Regards,
Odinn Burkni
 
  


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
[SOLVED] What port/ports does Centos use when checking for updates on the internet? warnold Linux - Networking 1 11-08-2008 10:32 AM
open ports for utorrent using iptables n close smpt to that ports shtorrent00 Linux - Networking 2 09-30-2008 03:34 PM
CentOS 5x, IpTables dont work port 80 and 3784. linuxy Linux - Security 1 01-29-2008 11:07 AM
iptables - using ! to allow multiple ports chibi Linux - Security 23 07-04-2006 03:42 AM
port forwarding with iptables and multiple ethernet interf. CleonII Linux - Security 8 04-15-2005 08:27 AM

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

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