How to redirect traffic to another machine in Linux कैसे एक और मशीन के लिए यातायात लिनक्स में अनुप्रेषित को

by Sukrit Dhandhania on April 15, 2009 Sukrit Dhandhania द्वारा 15 अप्रैल 2009 पर

लिनक्सवेब डिज़ाइन और देव

If you have ever handled the migration of a web service or a website from one server to another you know how crazy the experience can be. यदि आप कभी भी एक सर्वर से एक वेब सेवा का पलायन या एक वेबसाइट पर एक और तुम कैसे पागल अनुभव जानने के लिए संभाला हो सकता है. However, if you break the process up into clear steps and run constant checks you can make the experience a little easier on yourself. हालांकि, अगर आप इस प्रक्रिया को स्पष्ट कदम में टूटने और लगातार जाँच आप अपने अनुभव पर एक आसान सा बना सकते हैं चलाते हैं. One of the problems that you might run into towards the end of the migration is the period when you have the website running well on the new location but need to wait for the domain name to be forwarded to the new server. समस्याओं में से एक है कि आप में प्रवास के अंत में चला सकते हैं जब आप अवधि के नए स्थान पर अच्छी तरह से चल रहा है, लेकिन वेबसाइट को डोमेन नाम के लिए प्रतीक्षा की जरूरत है नए सर्वर को भेजा जाएगा. you can either shut down your service till the domain is done forwarding, or you can setup your first server to forward all its traffic to the new server. आप या तो नीचे अपनी सेवा डोमेन तक बंद कर सकते हैं अग्रेषण किया है, या आप अपने पहले सर्वर सेटअप कर सकते हैं नए सर्वर से सभी यातायात आगे. Let's take a look at how you can do that on a Linux machine using IPTables. चलो पर एक नज़र रखना तुम कैसे कर सकते हैं उस पर एक लिनक्स iptables का उपयोग कर मशीन.

In case you didn't already know, IPtables is a software firewall that ships with most distributions of Linux. मामले में आप पहले से ही पता नहीं था, iptables एक सॉफ्टवेयर फ़ायरवॉल है कि Linux के सर्वाधिक वितरण के साथ जहाज. It is an extremely useful software and can be used for a lot more than just as a firewall. यह एक बहुत ही उपयोगी सॉफ़्टवेयर है और बहुत से अधिक के लिए सिर्फ एक फ़ायरवॉल के रूप में इस्तेमाल किया जा सकता है. In this exercise we will configure IPTables on a Linux server to redirect all the traffic coming on port 80, (which is the default web server port), to a server with the IP 122.164.34.240 . इस अभ्यास हम configure एक Linux सर्वर पर होगा iptables सभी 80 बंदरगाह पर आ रहा यातायात, अनुप्रेषित करने में (जो कि डिफ़ॉल्ट वेब सर्वर पोर्ट है), आईपी 122.164.34.240 के साथ एक सर्वर से. The first step is to set your Linux box to allow this kind of forwarding to take place. पहले कदम के लिए आपके Linux बॉक्स सेट को अग्रेषण इस तरह की अनुमति देने के लिए जगह नहीं ले रहा है. Open a terminal window, log in as root user and run the following command: एक टर्मिनल विंडो खोलें, में प्रवेश के रूप में जड़ उपयोगकर्ता और निम्न कमांड चलायें:

# echo 1 >/proc/sys/net/ipv4/ip_forward # 1 गूंज> / proc/sys/net/ipv4/ip_forward

The next step is to tell IPTables to redirect the traffic to the new server: अगले कदम के लिए iptables बताने के लिए नए सर्वर पर यातायात पुनर्निर्देशित करना है:

# iptables -t nat -D PREROUTING -p tcp –dport 80 -j DNAT –to-destination 122.164.34.240 Iptables # आयकर नेट डी PREROUTING-p TCP-80-dport जम्मू DNAT को गंतव्य-122.164.34.240

Here's where the IPTables magic happens. यहाँ है जहाँ iptables जादू होता है. With the third and final step we tell IPTables to rewrite the origin of connections to the new server's port 80 to appear to come from the old server. साथ तीसरे और अंतिम कदम हम बता iptables नए सर्वर के 80 बंदरगाह के लिए कनेक्शन के मूल को फिर से लिखना करने के लिए पुराने सर्वर से आते दिखाई देते हैं.

# iptables -t nat -D POSTROUTING -p tcp -d 122.164.34.240 –dport 80 -j MASQUERADE Iptables # आयकर नेट डी टी सी पी POSTROUTING-p-d 122.164.34.240-dport 80 जे बहाना

The final step is required because if we don't tell the web server of the new server that the connections are coming from the client machines, it would think that they are originating from the old server. अंतिम कदम है, क्योंकि अगर हम नए सर्वर के वेब सर्वर है कि कनेक्शन ग्राहक मशीनों से आ रहे हैं बताने की आवश्यकता नहीं है, यह लगता है कि वे पुराने सर्वर से होने वाले हैं.

Related Posts: संबंधित पोस्ट:
  • More on BlogRush अधिक BlogRush पर
  • How to set the date on your Linux machine कैसे आपके Linux मशीन पर स्थापित करने की तारीख
  • How to install applications on your Nokia N95 via Bluetooth कैसे ब्लूटूथ के जरिये आपके नोकिया N95 पर आवेदन पत्र स्थापित करने के लिए
  • How to monitor your Linux machine with netstat कैसे netstat के साथ अपने Linux मशीन पर नजर रखने के लिए
  • 7 plugins to install immediately after WordPress 7 plugins तुरंत बाद WordPress स्थापित करने के लिए
  • Get Simple Help tutorials just like this one in your email inbox every day - for free! बस अपने ईमेल इनबॉक्स के लिए मुफ्त हर दिन - में यह एक तरह सरल सहायता ट्यूटोरियल जाओ! Just enter your email address below: बस नीचे अपना ईमेल पता दर्ज करें:

    You can always opt out of this email subscription at any time. तुम हमेशा इस ईमेल सदस्यता से बाहर किसी भी समय विकल्प चुन सकते हैं.

    { 1 comment… read it below or (1 टिप्पणी ... या नीचे पढ़ें add one एक जोड़ } )

    1 1 cosco 05.29.09 at 3:19 am 05.29.09 cosco 3:19 पर हूँ

    Thanks, I googled a lot before finding your post, without success. धन्यवाद, मैं सफलता के बिना अपनी पोस्ट, खोजने से पहले एक बहुत googled.
    That does exactly what I want. वह है जो मैं करना चाहता हूँ.
    However, there is a typo : हालांकि, वहाँ एक typo है:
    “iptables -t nat -D PREROUTING” should read “iptables -t nat -A PREROUTING” "Iptables-t नेट डी PREROUTING" पढ़ें "iptables चाहिए टी नेट एक PREROUTING"

    Leave a Comment एक टिप्पणी छोड़ दो

    You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> आप ये HTML टैग और विशेषताएँ: <a href="" उपयोग title=""> <abbr title=""> <acronym कर सकते हैं <blockquote title=""> <b> cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>