No mesmo servidor, no root, estou obtendo o ip da Internet correto da interface
root@server:~# curl -s --interface ppp0 ipcheck.com
111.111.111.111root@server:~#
No entanto ...
Se não for superusuário, recebo o ip da rota padrão / interface eth0 ou eth1 ip da internet ao invés do ip da internet do ppp0 e não é isso que eu espero.
matrix@server:~$ curl -s --interface ppp0 ipcheck.com
222.222.222.222matrix@server:~$
Minha pergunta é por que diferentes usuários obtêm diferentes IP / Rota? É o mesmo aplicativo, mesma interface que eu configurei a rota corretamente ...
Em / etc / iproute2 / rt_tables, adicionei
20 isp1
30 isp2
40 ppp0
50 ppp1
60 ppp2
primeiras 3 linhas do ip route:
default
nexthop via 222.222.222.1 dev eth0 weight 1
nexthop via 222.222.222.2 dev eth1 weight 1
10.200.20.1 dev ppp0 proto kernel scope link src 10.200.21.4
10.200.20.1 dev ppp1 proto kernel scope link src 10.200.21.9
10.200.20.1 dev ppp2 proto kernel scope link src 10.200.21.7
regra ip:
0: from all lookup local
32761: from all fwmark 0x60 lookup ppp2
32762: from all fwmark 0x50 lookup ppp1
32763: from all fwmark 0x40 lookup ppp0
32764: from all fwmark 0x30 lookup ISP2
32765: from all fwmark 0x20 lookup ISP1
32766: from all lookup main
32767: from all lookup default
iptables:
-A PREROUTING -t mangle -i eth0 -m state --state NEW,RELATED,ESTABLISHED -d 222.222.222.222 -j CONNMARK --set-mark 0x20
-A PREROUTING -t mangle -i eth1 -m state --state NEW,RELATED,ESTABLISHED -d 222.222.222.223 -j CONNMARK --set-mark 0x30
-A PREROUTING -t mangle -i br0 -m connmark --mark 0x20 -j CONNMARK --restore-mark
-A PREROUTING -t mangle -i br0 -m connmark --mark 0x30 -j CONNMARK --restore-mark
-A OUTPUT -t mangle -m state --state ESTABLISHED,RELATED -j CONNMARK --restore-mark
-A PREROUTING -t mangle -i ppp0 -m state --state NEW,RELATED,ESTABLISHED -d 10.200.21.4 -j CONNMARK --set-mark 0x40
-A PREROUTING -t mangle -i br0 -m connmark --mark 0x40 -j CONNMARK --restore-mark
-A PREROUTING -t mangle -i ppp1 -m state --state NEW,RELATED,ESTABLISHED -d 10.200.21.9 -j CONNMARK --set-mark 0x50
-A PREROUTING -t mangle -i br0 -m connmark --mark 0x50 -j CONNMARK --restore-mark
-A PREROUTING -t mangle -i ppp2 -m state --state NEW,RELATED,ESTABLISHED -d 10.200.21.7 -j CONNMARK --set-mark 0x60
-A PREROUTING -t mangle -i br0 -m connmark --mark 0x60 -j CONNMARK --restore-mark
-A OUTPUT -t mangle -m state --state ESTABLISHED,RELATED -j CONNMARK --restore-mark
-A POSTROUTING -t nat -o eth0 -j MASQUERADE
-A POSTROUTING -t nat -o eth1 -j MASQUERADE
-A POSTROUTING -t nat -o ppp+ -j MASQUERADE
-A FORWARD -i br0 -o eth0 -j ACCEPT
-A FORWARD -i br0 -o eth1 -j ACCEPT
-A FORWARD -i br0 -o ppp+ -j ACCEPT
-A FORWARD -m state -i eth0 -o br0 --state ESTABLISHED,RELATED -j ACCEPT
-A FORWARD -m state -i eth1 -o br0 --state ESTABLISHED,RELATED -j ACCEPT
-A FORWARD -m state -i ppp+ -o br0 --state ESTABLISHED,RELATED -j ACCEPT
-A FORWARD -i br0 -o br0 -j ACCEPT