Jump to content
  • 0

IPTABLES PROXY CONNECTION GUIDE ON APACHE WEBSERVER/ DEBIAN OR ANY0


gamingmagic

Question


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  11
  • Reputation:   3
  • Joined:  08/23/17
  • Last Seen:  

HI I ALWAYS FORGOT THE CONFIGURATION AND ALWAYS NEED TO CONVERT WITH IPTABLES THE GUIDE IN RATHENA.

 

IN THIS REGARDS I JUST WANNA SHARE SO WHEN I GOOGLE IT I WILL NOT FORGET ABOUT IT.

 

sysctl net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -j MASQUERADE
iptables -t nat -A PREROUTING -p tcp --dport 6121 -j DNAT --to-destination XXX.XXX.XXX.XXX:6121
iptables -t nat -A PREROUTING -p tcp --dport 5121 -j DNAT --to-destination XXX.XXX.XXX.XXX:5121
iptables -t nat -A PREROUTING -p tcp --dport 6900 -j DNAT --to-destination XXX.XXX.XXX.XXX:6900


iptables-save > /etc/iptables_rules

iptables-save > /etc/iptables_rules   
iptables -A INPUT -p tcp --dport 6900 -m state --state NEW -j ACCEPT
iptables -A INPUT -p tcp --dport 6121 -m state --state NEW -j ACCEPT
iptables -A INPUT -p tcp --dport 5121 -m state --state NEW -j ACCEPT

iptables -A INPUT -p udp --dport 6900 -m state --state NEW -j ACCEPT
iptables -A INPUT -p udp --dport 6121 -m state --state NEW -j ACCEPT
iptables -A INPUT -p udp --dport 5121 -m state --state NEW -j ACCEPT

  • Love 1
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  44
  • Topics Per Day:  0.01
  • Content Count:  895
  • Reputation:   117
  • Joined:  05/23/12
  • Last Seen:  

I would prefer ufw for it. But it's only my personal opinion.

 

Rynbef~

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  11
  • Reputation:   3
  • Joined:  08/23/17
  • Last Seen:  

On 8/22/2023 at 12:47 AM, Rynbef said:

I would prefer ufw for it. But it's only my personal opinion.

 

Rynbef~

Yeah even python is possible. If you say something, you better share the code.

 

import socket
import threading

# Configuration for login-server
LOGIN_SERVER_PROXY_HOST = '45.118.132.189'
LOGIN_SERVER_PROXY_PORT = 6050
LOGIN_SERVER_TARGET_HOST = 'xx.xx.xx.xx'
LOGIN_SERVER_TARGET_PORT = 6050

# Configuration for char-server
CHAR_SERVER_PROXY_HOST = '45.118.132.189'
CHAR_SERVER_PROXY_PORT = 6051
CHAR_SERVER_TARGET_HOST = 'xx.xx.xx.xx'
CHAR_SERVER_TARGET_PORT = 6051

# Configuration for map-server
MAP_SERVER_PROXY_HOST = '45.118.132.189'
MAP_SERVER_PROXY_PORT = 6052
MAP_SERVER_TARGET_HOST = 'xx.xx.xx.xx'
MAP_SERVER_TARGET_PORT = 6052

# Forward traffic between source and destination sockets
def forward_traffic(source_socket, destination_socket):
    while True:
        data = source_socket.recv(4096)
        if len(data) == 0:
            break
        destination_socket.sendall(data)

# Main proxy server loop
def proxy_server(proxy_host, proxy_port, target_host, target_port):
    proxy_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    proxy_socket.bind((proxy_host, proxy_port))
    proxy_socket.listen(5)

    print(f"Proxy server is listening on {proxy_host}:{proxy_port}")

    while True:
        client_socket, addr = proxy_socket.accept()
        client_ip = addr[0]
        print(f"Accepted connection from {client_ip}:{addr[1]}")

        # Start a new thread to handle the client
        client_thread = threading.Thread(target=handle_client, args=(client_socket, client_ip, target_host, target_port))
        client_thread.start()

# Handle client requests
def handle_client(client_socket, client_ip, target_host, target_port):
    # Connect to the target server
    target_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    target_socket.connect((target_host, target_port))

    # Forward client IP to the target server
    target_socket.sendall(client_ip.encode())

    # Forward traffic between client and target server
    client_to_target_thread = threading.Thread(target=forward_traffic, args=(client_socket, target_socket))
    target_to_client_thread = threading.Thread(target=forward_traffic, args=(target_socket, client_socket))

    client_to_target_thread.start()
    target_to_client_thread.start()

    # Wait for the threads to complete
    client_to_target_thread.join()
    target_to_client_thread.join()

    # Close the sockets
    client_socket.close()
    target_socket.close()

# Start the proxy servers
def start_proxy_servers():
    # Start login-server proxy
    login_server_thread = threading.Thread(target=proxy_server, args=(LOGIN_SERVER_PROXY_HOST, LOGIN_SERVER_PROXY_PORT, LOGIN_SERVER_TARGET_HOST, LOGIN_SERVER_TARGET_PORT))
    login_server_thread.start()

    # Start char-server proxy
    char_server_thread = threading.Thread(target=proxy_server, args=(CHAR_SERVER_PROXY_HOST, CHAR_SERVER_PROXY_PORT, CHAR_SERVER_TARGET_HOST, CHAR_SERVER_TARGET_PORT))
    char_server_thread.start()

    # Start map-server proxy
    map_server_thread = threading.Thread(target=proxy_server, args=(MAP_SERVER_PROXY_HOST, MAP_SERVER_PROXY_PORT, MAP_SERVER_TARGET_HOST, MAP_SERVER_TARGET_PORT
 

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  44
  • Topics Per Day:  0.01
  • Content Count:  895
  • Reputation:   117
  • Joined:  05/23/12
  • Last Seen:  

Ufw is a packet u can install it with apt-get or yum. Not a code.

 

Rynbef~

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...