Перейти до вмісту

DIY Proxy Farm: How to Build and Configure

Гайды
DIY Proxy Farm: How to Build and Configure

Building a DIY proxy farm involves assembling a dedicated hardware stack—typically composed of 4G/LTE modems or single-board computers—and configuring specialized software to route traffic through multiple network interfaces. This setup provides a private infrastructure for high-volume web scraping, social media automation, and ad verification, offering complete control over IP rotation and data privacy.

Hardware Requirements for a Mobile Proxy Farm

The most effective DIY proxy farms leverage mobile networks because 4G/LTE IP addresses are shared among thousands of real users, making them highly resistant to blacklisting. To build a 20-channel mobile proxy farm, you need a specific set of hardware components designed for 24/7 stability.

  • Single Board Computer (SBC): A Raspberry Pi 4 (8GB RAM) is the industry standard. It handles the Linux environment and manages the USB bus efficiently. For larger farms (50+ modems), a dedicated x86 server or an Intel NUC is preferred to avoid CPU bottlenecks.
  • USB 4G Modems: Huawei E3372 (specifically the non-HiLink versions for better control) or ZTE MF833V are the most compatible. These modems allow for direct serial communication via AT commands to trigger IP rotations.
  • Powered USB Hubs: Standard passive hubs will fail. Each 4G modem can pull up to 500mA to 1A during peak data transmission. You require industrial-grade, powered USB hubs (e.g., Orico or TP-Link) with at least 60W to 100W of dedicated power for every 10 modems.
  • Cooling System: Modems generate significant heat under load. Use a 120mm USB fan or a rack-mounted cooling solution to prevent thermal throttling, which causes connection drops.

For those who find the hardware overhead and maintenance too demanding, GProxy offers enterprise-grade mobile and residential proxies that provide the same level of trust and anonymity without the physical infrastructure costs.

DIY Proxy Farm: How to Build and Configure

Operating System and Network Configuration

Ubuntu Server 22.04 LTS is the recommended OS due to its extensive driver support for USB modems and networking stacks. Once the OS is installed, the primary challenge is preventing the system from treating every modem as a default gateway, which would cause routing conflicts.

Disabling Modem Auto-Configuration

Modern Linux distributions use NetworkManager, which often tries to manage USB modems automatically. For a proxy farm, you must disable this to maintain manual control via configuration files or custom scripts.

sudo systemctl stop NetworkManager
sudo systemctl disable NetworkManager

The Role of usb_modeswitch

Most USB modems initially mount as a virtual CD-ROM to install drivers. You must use the usb_modeswitch utility to flip them into "modem mode" so the system recognizes them as network interfaces (e.g., eth1, wwan0).

Component DIY Approach Commercial Alternative (GProxy)
Setup Time 10–20 Hours Instant Activation
Upfront Cost $500 - $2,000 (Hardware) $0 (Pay-as-you-go)
Maintenance Manual hardware/software fixes Managed by provider
IP Pool Size Limited to SIM cards owned Millions of rotating IPs

Configuring the Proxy Server Software

After the hardware is recognized as network interfaces, you need a proxy server to handle incoming requests and route them through specific modems. 3proxy is the most lightweight and flexible tool for this purpose.

3proxy Configuration Example

Create a 3proxy.cfg file. This configuration sets up two different proxy ports (3128 and 3129), each tied to a specific network interface (eth1 and eth2).

daemon
nserver 8.8.8.8
nserver 8.8.4.4
nscache 65536
timeouts 1 5 30 60 180 1800 15 60

# Authentication
users "admin:CL:strongpassword123"
auth strong

# Route Port 3128 through Modem 1
external 192.168.8.100
internal 0.0.0.0
proxy -p3128

# Route Port 3129 through Modem 2
flush
external 192.168.9.100
internal 0.0.0.0
proxy -p3129

In this setup, 192.168.8.100 and 192.168.9.100 are the static IPs assigned to your USB modems. Each port on your Raspberry Pi now acts as a gateway to a different mobile IP address.

DIY Proxy Farm: How to Build and Configure

Automating IP Rotation with Python

One of the main advantages of a mobile proxy farm is the ability to change the IP address on demand by reconnecting the modem to the cellular network. This is achieved by sending AT commands to the modem's serial port.

The following Python script demonstrates how to trigger a reconnection for a Huawei modem, which forces the ISP to assign a new IP address to the device.

import serial
import time

def rotate_ip(port='/dev/ttyUSB0'):
    try:
        ser = serial.Serial(port, 115200, timeout=1)
        # Check connection
        ser.write(b'AT\r\n')
        time.sleep(1)
        
        # Disconnect from the network
        ser.write(b'AT^NDISDUP=1,0\r\n')
        print(f"Disconnecting {port}...")
        time.sleep(5)
        
        # Reconnect to the network
        ser.write(b'AT^NDISDUP=1,1,"internet"\r\n')
        print(f"Reconnecting {port} for new IP...")
        time.sleep(10)
        
        ser.close()
    except Exception as e:
        print(f"Error: {e}")

if __name__ == "__main__":
    # Example: Rotate IP for the first modem
    rotate_ip('/dev/ttyUSB0')

Integrating this script with a web API allows you to rotate IPs via a simple HTTP request, mimicking the "Rotation API" features found in professional services like GProxy.

Scaling and Performance Optimization

As you scale beyond 10 modems, you will encounter Linux kernel limitations and power delivery issues. Optimizing the system for high concurrency is mandatory for a stable farm.

Kernel Tuning

Modify /etc/sysctl.conf to handle a higher number of simultaneous connections and reduce time-wait states. These settings prevent the "Too many open files" or "Connection refused" errors common in heavy scraping tasks.

  • net.ipv4.ip_local_port_range = 1024 65535 — Increases the available port range.
  • net.core.somaxconn = 1024 — Increases the queue size for incoming connections.
  • fs.file-max = 1000000 — Raises the limit for open file descriptors.
  • net.ipv4.tcp_tw_reuse = 1 — Allows the kernel to reuse sockets in TIME_WAIT state.

Bandwidth Management

Mobile networks are asymmetrical. While you may have 50 Mbps download, your upload might be capped at 5 Mbps. If you are running 20 modems on a single Raspberry Pi, the USB 2.0/3.0 bus bandwidth can become a bottleneck. Distributing modems across multiple SBCs and linking them via a Gigabit switch is the professional way to scale.

Security and Remote Management

A DIY farm is a gateway into your local network. Leaving it unprotected is a significant risk. You must implement strict firewall rules using iptables or nftables to ensure that only authorized IPs can access your proxy ports.

Furthermore, because mobile IPs are dynamic, you need a way to track the health of each modem. Implementing a simple monitoring dashboard using Prometheus and Grafana can help you visualize latency, packet loss, and data consumption for each SIM card. This allows you to identify failing modems or throttled SIMs before they impact your operations.

If the complexity of managing hardware, cooling, SIM card subscriptions, and kernel tuning becomes a distraction from your core business, GProxy provides a seamless transition to a managed environment. With GProxy, you gain access to high-speed, diverse IP pools with 99.9% uptime, eliminating the need for physical hardware maintenance.

Key Takeaways

Building a DIY proxy farm is a complex but rewarding technical project that offers unmatched control over your digital footprint. You have learned the essential hardware requirements, the software configuration using 3proxy, and how to automate IP rotation via Python scripts.

  • Prioritize Power: Always use industrial-grade powered USB hubs; insufficient power is the #1 cause of modem instability.
  • Monitor Heat: Active cooling is mandatory for 24/7 operations to prevent hardware degradation and connection drops.
  • Software Flexibility: Use 3proxy for its low resource footprint and ability to map specific ports to specific network interfaces.
  • Evaluate ROI: DIY farms are cost-effective for static, long-term projects, but for massive scale and diverse geolocations, professional services like GProxy offer better reliability and lower operational overhead.
support_agent
GProxy Support
Usually replies within minutes
Hi there!
Send us a message and we'll reply as soon as possible.