Linux production Proxy Server

Source: Internet
Author: User
Linux production proxy server-Linux Enterprise Application-Linux server application information. The following is a detailed description. The simplest way to use linux as a proxy server is to use RedHat9.0 as an example.

Take my computer as an example: because I only have one network card, I have edited eth0: 0. In reality, it is best to have two network cards.

Eth0 NIC address settings
[Root @ xiaoye root] # vi/etc/sysconfig/network-scripts/ifcfg-eth0 set according to your own situation can be edited by a save is: wq

DEVICE = eth0
BOOTPROTO = static
BROADCAST = 219.239.174.255
IPADDR = 219.239.174.15
NETMASK = 255.255.255.0
NETWORK = 219.239.174.0
ONBOOT = yes

Edit eth0: 0 as follows (Note: Based on the NIC's own situation
[Root @ xiaoye root] # cat/etc/sysconfig/network-scripts/ifcfg-eth0>/etc/sysconfig/network-scripts/ifcfg-eth0: 0
In this way, the content in eth0: 0 is the same as that in eth0. You only need to change the incorrect content.

DEVICE = eth0: 0
BOOTPROTO = static
BROADCAST = 192.168.0.255
IPADDR = 192.168.0.1
NETMASK = 255.255.255.0
NETWORK = 192.168.0.0
ONBOOT = yes

[Root @ xiaoye root] # ifconfig --- see whether two Nic IP addresses are displayed and whether they match your situation
Change the gateway address
   
HOSTNAME = xiaoye
GATEWAY = 219.239.174.16 by default, this one does not need to be added by yourself
In [root @ xiaoye root] # vi/etc/resolv. conf

Nameserver 202.106.0.20
Run the route command
[Root @ xiaoye root] # route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
219.239.174.0*255.255.255.0 U 0 0 eth0
169.168.0.0*255.255.0.0 U 0 0 0 eth0: 0
127.0.0.0*255.0.0.0 U 0 0 0 lo
Default 219.239.174.16 0.0.0.0 UG 0 0 0 eth0
Edit iptables forwarding rules
[Root @ xiaoye root] # vi/etc/sysctl. conf

It can be written as follows:
Net. ipv4.ip _ forward = 0 ------------ change 0 to 1 to enable the forwarding function (others do not move)
Net. ipv4.conf. default. rp_filter = 1
Kernel. sysrq = 0



[Root @ xiaoye root] # vi/etc/rc. d/rc. local --- this is automatically loaded after the system, which is equivalent to what I understand in WINDOWS :)
Iptables-F disable Firewall
Iptables-F-t create a rule for nat-t followed by a nat mangle filter)
Iptables-t nat-a postrouting-o eth0-s 192.168.0.0/24-j MASQUERADE
To create a nat rule POSTROUTING is to use this function to convert source IP addresses before forwarding packets. -O = output-s = source-j parameter is used to specify the action to be processed. MASQUERADE is rewritten to disguise the original IP address.
Echo 1>/proc/sys/net/ipv4/ip_forward enable ip forwarding.
Finally, reboot
You can try this method.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.