B
B
Barnie Savington2019-05-23 18:00:04
linux
Barnie Savington, 2019-05-23 18:00:04

How to set up a network if there are 2 network interfaces with the same gateway IP?

Hey!
We have 4 identical Huawei E3533 3g modems, they work in HiLink mode. With HILINK firmware, the modem works in router mode, and is presented to the computer as a network interface (usb-ethernet-rndis). The computer receives network settings from this interface via DHCP, and then goes through it to the Internet, just like through a regular wired LAN. The modem takes care of establishing the connection and maintaining the channel, the computer does not even notice that Internet access is via a cellular network. In this mode, the modem has its own local IP address (usually 192.168.8.1), visible from the computer as a default gateway (default route), as well as an external IP address obtained from the cellular network.
If you connect all 4 modems to a computer, all of them will have the same IP gateway, respectively.
You need to raise the http proxy server.
For example, if a request comes in on port 8001 -> it will go through Modem No. 1, 8002 -> Modem No. 2, and so on.
To do this, you can use the 3proxy utility, which can proxy requests through the desired gateway.
And here the problem is that everyone has the same gateway. As in this case, you can somehow virtually reassign gateways or configure routing.
3proxy config example

proxy -n -a -p8001 -i0.0.0.0 -e192.168.8.100 // 192.168.8.100 выдан модемом, но если сменить, то тоже работает
proxy -n -a -p8002 -i0.0.0.0 -e192.168.8.101

netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         _gateway        0.0.0.0         UG        0 0          0 wlp2s0
default         _gateway        0.0.0.0         UG        0 0          0 enp0s20f0u1u3
default         _gateway        0.0.0.0         UG        0 0          0 enp0s20f0u3
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 wlp2s0
192.168.8.0     0.0.0.0         255.255.255.0   U         0 0          0 enp0s20f0u1u3
192.168.8.0     0.0.0.0         255.255.255.0   U         0 0          0 enp0s20f0u3

ifconfig
enp0s20f0u3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.8.100  netmask 255.255.255.0  broadcast 192.168.8.255
        inet6 fe80::5d7f:ea8a:8b6a:b39d  prefixlen 64  scopeid 0x20<link>
        ether 02:cb:0f:fb:0d:fa  txqueuelen 1000  (Ethernet)
        RX packets 112  bytes 34668 (33.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 105  bytes 11655 (11.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s20f0u1u3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.8.100  netmask 255.255.255.0  broadcast 192.168.8.255
        inet6 fe80::78bd:ac24:6caa:44e3  prefixlen 64  scopeid 0x20<link>
        ether 9a:eb:91:34:dc:25  txqueuelen 1000  (Ethernet)
        RX packets 214  bytes 73288 (71.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 204  bytes 31245 (30.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ivan, 2019-05-23
@Amigo83

If the gateway is one, then it is tied to only one interface? netstat -r says what?

V
Vladimir Dubrovin, 2019-05-23
@z3apa3a

3proxy in the devel version can bind to an interface (-DeINTERFACE), but must be run as root for this

A
AntHTML, 2019-05-24
@anthtml

Chase the rules not by IPs, but by interfaces, almost any proxy can do this.
On the server side, it is only desirable to remove dhcp-client and set static ip.
IP routing is a higher level, so everything should work fine.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question