我想将网络接口 (enp0s3) 的所有 HTTP 流量重定向到运行于http://*:8080
这些是我的网络接口
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
inet6 fe80::6291:861b:b4x:c9r3 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:fa:5c:69 txqueuelen 1000 (Ethernet)
RX packets 12666 bytes 10589141 (10.5 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 5967 bytes 404489 (404.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 153 bytes 13996 (13.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 153 bytes 13996 (13.9 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
我尝试在 iptables 上分配以下规则,但没有成功:
sudo iptables -t nat -A PREROUTING -i enp0s3 -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo iptables -t nat -A PREROUTING -i enp0s3 -p tcp --dport 443 -j REDIRECT --to-port 8080
有什么帮助吗?
提前致谢。