Linux Router and Bypass Router Deployment Guide: Understanding Kernel-Level Traffic Interception

Compare Linux gateway and bypass-router setups, including DNS, forwarding, transparent proxying, permissions, resource usage, testing, and rollback planning.

At a Glance

This overview is for readers planning to run the V2Ray or Xray core directly on a Linux host and forward LAN traffic through it. The focus is not on copying a rule set, but on defining the roles of the main router, bypass router, DNS, and transparent interception before building a deployment sequence that can be tested, monitored, and rolled back.

What “running the core directly” actually intercepts

Here, “core” means the V2Ray or Xray proxy core running in user space, not proxy functionality compiled into the Linux kernel. The proxy core accepts connections delivered to its inbound ports and uses routing rules to choose direct access, blocking, or a remote outbound. Linux still handles network interfaces, addresses, routing tables, connection tracking, forwarding, and the firewall.

Therefore, a program showing “running” only means that the process has started; it does not mean LAN traffic is passing through it. To take over gateway traffic, packets must first reach the Linux host, where nftables or iptables sends selected traffic to a transparent-proxy inbound. Return traffic must also follow a predictable path back to the original device. Otherwise, connections may drop immediately after being established, some sites may load while other applications time out, and similar symptoms may appear.

Bypass Router Trial Run

Recommended

Keep dialing and DHCP on the existing main router, and point the default gateway and DNS on just one test device to the Linux host. This limits the impact and makes it easier to verify forwarding, DNS, and proxy rules.

Best for: first deployments, device-by-device migration, and quick rollback

Main Router Deployment

The Linux host provides the default gateway, address assignment, and forwarding, so every endpoint passes through it by default. The path is direct, but a configuration mistake can affect the entire LAN.

Best for: well-defined networks with a backup management path

Explicit Proxy

Enter an HTTP or SOCKS address manually on each endpoint without changing its default gateway. This can validate the node and outbound connection, but it does not prove that transparent interception is working.

Best for: validating proxy-core outbound connectivity and isolating firewall variables

Conclusion: start with one test device

Do not change DHCP for the entire network as the first step. Fix the address, gateway, and DNS on one endpoint, verify direct access, proxying, DNS resolution, and rollback, then expand the interception scope.

Roles of the Gateway, DNS, Forwarding, and Proxy Core

The default gateway answers “Where is the next hop for this packet?” DNS answers “What address does this domain resolve to?” Linux forwarding lets packets entering through one interface leave through another, while the proxy core handles only connections actually delivered to its inbound. These four components work together, but any one of them working does not prove that the other three are correctly deployed.

For example, an endpoint may receive the correct address from a DNS service on Linux yet still send packets to the original router. Or the default gateway may already be Linux while IPv4 forwarding is disabled, preventing access to any address outside the LAN. Another common case is that forwarding works and the transparent inbound is listening, but the firewall fails to exclude the gateway itself, the LAN subnet, or the remote server address, creating a loop.

53
Common LAN DNS listening port
12345
Transparent inbound port used in this example
100
Policy-routing table identifier
1
Target value for net.ipv4.ip_forward
Role boundaries in a gateway deployment
Component Primary responsibility What working alone does not prove
Default gateway Send an endpoint’s non-local traffic to the Linux host. It does not prove that Linux is forwarding or proxying the traffic.
DNS Receive queries and return domain-resolution results. It does not prove that subsequent TCP and UDP connections use the same path.
Firewall and policy routing Mark, redirect, or transparently receive selected packets. It does not prove that the proxy core’s outbound parameters work.
V2Ray or Xray core Process inbound connections and apply domain, IP, and protocol routing rules. It does not prove that endpoint traffic has reached the transparent inbound.

Traffic Paths: Main Router vs. Bypass Router

In main-router mode, Linux typically holds both the LAN and upstream interfaces, and endpoints receive it as their default gateway through DHCP. Packets enter through the LAN interface, pass through routing decisions, firewall rules, and proxy rules, then leave through the upstream interface. The path is consistent and split-routing rules are easier to manage centrally, but one error in DHCP, NAT, or forwarding can disconnect the entire network from the outside.

In bypass-router mode, the original router still handles Internet access and address assignment, while the Linux host sits on the same LAN. Only endpoints whose default gateway explicitly points to the bypass router pass through it. If an endpoint still uses the original router as its gateway and only changes DNS to the bypass router, the bypass router will usually see DNS queries but not subsequent connections, so transparent proxy rules will not match.

The return path also needs checking. After the bypass router forwards packets to the original router, that router must know how to return responses to the endpoint. Common approaches are source NAT on the bypass router’s exit or a static route on the original router pointing to the test subnet. The former is simpler, but the original router sees the bypass router’s address; the latter preserves source addresses but requires clear routing support on the network equipment.

Conclusion: DNS cannot replace the default gateway

If the goal is transparent interception, the test endpoint’s default gateway must actually point to the Linux host. Changing only DNS is useful for validating resolution, but it is not enough to verify traffic interception.

Deploy in a Rollback-Friendly Order

Test node availability and gateway interception separately. First use an explicit proxy to validate the core configuration and remote connection, then enable Linux forwarding and transparent rules. If something fails, this makes it easier to tell whether the issue is with proxy outbound connectivity or the local network path.

  1. Record the original network settings

    Save the test endpoint’s original IP address, subnet mask, default gateway, and DNS settings. Give the bypass router a fixed LAN address as well, so a changed DHCP lease does not remove your management access.

  2. Validate core outbound connectivity

    First have V2Ray or Xray listen on an HTTP/SOCKS port reserved for testing, such as 10808, and enter that address explicitly in one application. Do not enable transparent forwarding yet.

  3. Confirm the core type

    If you use a Windows test endpoint to cross-check the same node parameters, open “Settings” → “Parameter settings” → “Core type” in v2rayN and confirm that the selected core matches the protocol configuration.

  4. Enable system forwarding

    Check whether net.ipv4.ip_forward is set to 1, then confirm that the FORWARD chain permits the test subnet. Keep ordinary routing available at first; do not rush to add transparent rules.

  5. Connect the transparent inbound

    Configure packet marks, policy routing, and a local routing table for TProxy. Send selected TCP/UDP traffic to 12345, excluding the LAN, multicast, broadcast, the gateway itself, and remote server addresses.

  6. Expand the scope gradually

    Test one fixed IP first, then expand by device group. Change only one item at a time in the gateway, DNS, or rules, and keep a management path that can restore ordinary forwarding after transparent rules are disabled.

The commands below inspect status; they do not generate firewall rules for you. In the output, focus on whether the forwarding value, policy rules, routing table, and listening ports match your configuration. If the system uses nftables, inspect the actual ruleset directly rather than relying only on what the compatibility layer displays.

sysctl net.ipv4.ip_forward
ip rule show
ip route show table 100
nft list ruleset
ss -lntup | grep -E '(:53|:10808|:12345)'

Choosing Between TProxy, Redirect, and TUN

Transparent interception has more than one implementation. TCP redirect rules are easy to understand, but the original destination and UDP support depend on the implementation. TProxy can receive TCP and UDP while preserving destination information, making it better suited to gateways that combine domain, IP, and transport-layer routing. It also depends on firewall marks, policy routing, and a transparent inbound configured in the proxy core, so troubleshooting takes more steps.

TUN has the proxy core create a virtual network interface that receives traffic at the routing layer. This can reduce some firewall-redirection logic, but routes, DNS, interface permissions, and bypass rules must still be configured correctly. If the default route is mistakenly sent back to TUN, connections to remote servers may also be redirected to the proxy itself, creating a loop.

Deployment Priorities for Three Interception Methods
Method Best suited for Key checks
TCP Redirect Start by validating TCP web access and basic split routing. Redirect chain, destination port, and exclusions for LAN and reserved addresses.
TProxy Cases that require TCP and UDP together while preserving the original destination. Packet marks, policy rules, table 100, local routes, and inbound permissions.
TUN Cases where a virtual interface should handle routed traffic uniformly. Interface permissions, default route, MTU, DNS, and remote-address bypass rules.

Do not stack TProxy and TUN during the initial deployment. When both interception chains are active, the same connection may be processed twice; logs may show repeated reconnects without making it clear where the loop occurs. Get TCP, UDP, and DNS working with one method first, then decide whether a switching plan is necessary.

Validate DNS and Traffic Routing Separately

Domain-based routing requires a reliable source of domain information. The proxy core may obtain a domain from the inbound protocol, DNS results, or traffic inspection, but these sources are not always equivalent. If the endpoint has already resolved the domain to an IP address before the traffic enters the gateway transparently, the core may see only the destination IP, so a domain-only rule may not match.

DNS must also avoid looping back into itself. For example, a local DNS service on Linux may forward queries to the proxy core, while the upstream domain configured for the core also requires that same local DNS. Queries then repeatedly return to the original entry point. A safer approach is to distinguish the LAN listening address, the core’s internal queries, and the upstream resolution path, then confirm in the logs that each query has an understandable request and response.

The bypass router resolves domains, but webpages still connect directly?

Check the test endpoint’s default gateway first. If it is still the original router, only DNS queries are passing through the bypass router. Change the default gateway on one test device to the Linux address, then check whether the transparent inbound counter increases.

Do all connections time out after enabling the rules?

Disable the transparent rules first and confirm that ordinary forwarding returns. Then check whether the remote server address, Linux host traffic, and LAN subnet are excluded. Finally, verify that port 12345 is actually listening.

TCP works, but UDP does not?

Confirm that the transparent inbound has UDP enabled, that the firewall rules match UDP, and that the TProxy marks and local route in table 100 are correct. TCP redirect alone does not automatically intercept UDP.

Do the logs show repeated reconnects?

Check whether the proxy’s remote connection is entering the transparent inbound again. Temporarily exclude the remote server IP and inspect the routing table to confirm that the core’s own outbound traffic is not pointing back to the TUN or TProxy chain.

Does the entire network become inaccessible when the core stops?

This means the firewall is still sending traffic to a closed inbound. During rollback, remove the transparent rules and policy routes together, then restore ordinary FORWARD and the original DNS; stopping the process alone is not enough.

Resource Usage, Acceptance Metrics, and Rollback Planning

Gateway load cannot be judged by idle memory alone. The number of encrypted connections, UDP sessions, log level, DNS cache, and rule-set size all affect resource usage. Also monitor soft interrupts, per-core utilization, and network throughput, because low-power hardware may already have one saturated core even when total CPU usage looks modest.

One measured baseline environment used a four-core N5105, 4 GB of memory, Linux 6.1, and a gigabit wired interface. A single endpoint sustained 500 Mbps with about 800 active connections. After transparent proxying was enabled, the proxy core used about 118 MB of resident memory and total system CPU varied between 18% and 27%. This result illustrates the recording method only; protocol, encryption, rule count, and hardware will all change the figures.

500 Mbps
Baseline sustained throughput
800
Approximate concurrent connections during testing
118 MB
Approximate proxy-core resident memory
18–27%
Test system total CPU range

For acceptance testing, record at least three result sets: direct-connection baseline, explicit proxy, and transparent interception. Test first-lookup latency, sustained throughput, connection establishment, UDP, and rule hits separately. If transparent interception is noticeably slower than an explicit proxy, check MTU, duplicate interception, DNS wait time, and per-core bottlenecks before changing the protocol name.

  1. Back up the routing table, firewall rules, DNS configuration, and system forwarding value before enabling anything.
  2. Prepare a command or service operation that removes the transparent rules and policy routes together.
  3. Keep the original main router’s DHCP configuration; do not remove it immediately during the bypass-router trial.
  4. Configure log rotation so that debug logs do not eventually fill the disk.
  5. Repeat acceptance testing after rebooting the Linux host and confirm that rules load only after network interfaces are ready.

Final Pre-Deployment Assessment

If only a few applications need proxy access, an explicit proxy is usually easier to observe and does not require changing the path for the entire LAN. If the goal is to cover TVs, terminal tools, or devices that are difficult to configure individually, gateway mode offers clear advantages, but it requires maintaining routing, DNS, the firewall, and the proxy core together.

For a first deployment, start with a bypass router and one test endpoint: validate the explicit proxy on 10808, enable system forwarding, and finally connect the transparent inbound on 12345. Only after confirming rule hits, the DNS path, TCP, UDP, IPv4, and rollback procedures should you consider migrating DHCP or making Linux the main router.

Client and Installation Resources

When you need to validate node parameters on a desktop device first, visit the download page and choose v2rayN. After establishing a basic connection, follow the guide to check imports, the core type, and whether the proxy is active.

Download v2rayN