nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

require shell script

This is a discussion on require shell script within the Shell scripting forums, part of the Development/Scripting category; Dear All. I need a shell script for Linux. The scenrio is .... I have one Linux Box with two ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 04-08-2006, 03:44 PM
Member
User
 
Join Date: Mar 2006
Posts: 63
Rep Power: 0
puppen
Default require shell script

Dear All.

I need a shell script for Linux. The scenrio is ....
I have one Linux Box with two NIC on that on is configure for private IP and second is configure for public IP.
What I want is I have one another server on LAN which is Window Server
and client are connect through RDP, I need a shell script which forward ( anyone configure the Public IP they get the RDP of Windows Server ).
Pls help me.

Thanks.
Puppen
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-08-2006, 06:51 PM
tom tom is offline
Contributors
User
 
Join Date: Jun 2005
Location: London, UK
Posts: 213
Rep Power: 0
tom is an unknown quantity at this point
Default

For RDP from Linux to windows you need to use rdesktop command. Script is not needed or may be you need to give us more info
Reply With Quote
  #3 (permalink)  
Old 04-11-2006, 11:34 PM
Member
User
 
Join Date: Mar 2006
Posts: 63
Rep Power: 0
puppen
Default Re: require shell script

Dear Tom.

Thanks fot reply.
The sceniro ia that
some remote users are connected to WIndows Server using RDP , using private leased line. If this line goes down they are not able to connect to server.
I have internet connection , what i wan t is Users connect to RDP server via internet using Linux Box between them,
I can not give live IP to Win Server. They must come through Linux, for that I require shell script. Win RDP uses Port 3389, but How I configure port forwarding using Linux .



Quote:
Originally Posted by puppen
Dear All.

I need a shell script for Linux. The scenrio is ....
I have one Linux Box with two NIC on that on is configure for private IP and second is configure for public IP.
What I want is I have one another server on LAN which is Window Server
and client are connect through RDP, I need a shell script which forward ( anyone configure the Public IP they get the RDP of Windows Server ).
Pls help me.

Thanks.
Puppen
Reply With Quote
  #4 (permalink)  
Old 04-12-2006, 08:03 AM
rockdalinux's Avatar
Contributors
User
 
Join Date: May 2005
Location: Bangalore
My distro: RHEL, HP-UX, Solaris, FreeBSD, Ubuntu
Posts: 564
Rep Power: 7
rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough
Default

Ok so you wanna have a Windows server on your internal network that you want make available externally, you can use the -j DNAT target of the PREROUTING chain in NAT to specify a destination IP address and port where incoming packets requesting a connection to your internal service can be forwarded. For example, if you wanted to forward incoming UDP 3389 requests to your dedicated Windows Server server system at 172.31.0.5, run the following command at shell prompt (or add to your iptables script):

Enable ip forward, type following command at shell prompt:
Code:
sysctl -w net.ipv4.ip_forward=1
Type following iptables rules at shell or in your script:
Code:
iptables -A FORWARD -i eth1 -j ACCEPT
iptables -A FORWARD -o eth1 -j ACCEPT
iptables -t nat -A PREROUTING -i eth0 -p udp --dport 3389 -j DNAT --to 172.31.0.5:3389
iptables -A FORWARD -i eth0 -p udp --dport 3389 -d 172.31.0.5 -j ACCEPT
So all user will connect to public IP and connection will go to windows server 172.31.0.5.

Code:
Public IP -->Linux Box/Router --> Windows box
3389     -->    forward to        --> internal windows box 172.31.0.5
eth0 ==> assuming the firewall/gateway is assigned public IP address on eth0
eth1 ==> assuming the firewall/gateway is assigned an internal IP address on eth1
__________________
Rocky Jr.
You may have my body & soul, but you will never touch my pride!

If you have knowledge, let others light their candles at it.

Certified to work on HP-UX / Sun Solaris / RedHat
Reply With Quote
  #5 (permalink)  
Old 04-12-2006, 09:42 PM
Member
User
 
Join Date: Mar 2006
Posts: 63
Rep Power: 0
puppen
Default

Dear Rocky.
Thank you very much for your reply. I am very greateful to you.
The script which you have given, is bit incomplete but what ever you given is right.
I added one line in that script and script is working fine.

Anyway thank you very much for your support.


Quote:
Originally Posted by rockdalinux
Ok so you wanna have a Windows server on your internal network that you want make available externally, you can use the -j DNAT target of the PREROUTING chain in NAT to specify a destination IP address and port where incoming packets requesting a connection to your internal service can be forwarded. For example, if you wanted to forward incoming UDP 3389 requests to your dedicated Windows Server server system at 172.31.0.5, run the following command at shell prompt (or add to your iptables script):

Enable ip forward, type following command at shell prompt:
Code:
sysctl -w net.ipv4.ip_forward=1
Type following iptables rules at shell or in your script:
Code:
iptables -A FORWARD -i eth1 -j ACCEPT
iptables -A FORWARD -o eth1 -j ACCEPT
iptables -t nat -A PREROUTING -i eth0 -p udp --dport 3389 -j DNAT --to 172.31.0.5:3389
iptables -A FORWARD -i eth0 -p udp --dport 3389 -d 172.31.0.5 -j ACCEPT
So all user will connect to public IP and connection will go to windows server 172.31.0.5.

Code:
Public IP -->Linux Box/Router --> Windows box
3389     -->    forward to        --> internal windows box 172.31.0.5
eth0 ==> assuming the firewall/gateway is assigned public IP address on eth0
eth1 ==> assuming the firewall/gateway is assigned an internal IP address on eth1
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
shell script for ftp the file vishal_titre Shell scripting 3 12-10-2007 08:40 AM
writing a shell script to find out my shell name jaymob123 Shell scripting 1 10-08-2007 12:36 AM
Require Shell Script Which sends all server info on mail puppen Linux software 3 10-25-2006 08:07 PM
Require shell script using rsync puppen Shell scripting 4 04-23-2006 12:52 AM
Shell Script dought Mahesh Shell scripting 3 02-16-2005 12:13 PM


All times are GMT +5.5. The time now is 04:26 AM.


Powered by vBulletin® Version 3.7.3 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36