[root@lasertools-serv lsts]# /sbin/route del default
[root@lasertools-serv lsts]# /sbin/route add default eth1
[root@lasertools-serv lsts]# /sbin/route add default gw 192.168.172.1
[root@lasertools-serv lsts]# /etc/init.d/network restart
Shutting down interface eth0: [ OK ]
Shutting down interface eth1: [ OK ]
Shutting down loopback interface: [ OK ]
Disabling IPv4 packet forwarding: [ OK ]
Setting network parameters: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]
Bringing up interface eth1: [ OK ]
[root@lasertools-serv lsts]# /sbin/route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.172.0 * 255.255.255.0 U 0 0 0 eth0
192.168.172.0 * 255.255.255.0 U 0 0 0 eth1
169.254.0.0 * 255.255.0.0 U 0 0 0 eth1
default 192.168.172.1 0.0.0.0 UG 0 0 0 eth0
Pelo o que me parece é que ele usa o endereço 192.168.172.1 como gateway na eth0 mas eu adicionei o gateway 192.168.172.1 na eth1.
O que há de errado?
Agora vejam isso:
[root@lasertools-serv network-scripts]# cat ifcfg-eth0
BOOTPROTO=none
PEERDNS=no
IPV6INIT=no
TYPE=Ethernet
HWADDR=00:07:E9:19:EB:AA
DEVICE=eth0
MTU=""
NETMASK=255.255.255.0
BROADCAST=192.168.172.255
IPADDR=192.168.172.4
NETWORK=192.168.172.0
USERCTL=no
ONBOOT=yes
You have new mail in /var/spool/mail/henrique
[root@lasertools-serv network-scripts]# cat ifcfg-eth1
GATEWAY=192.168.172.1
BOOTPROTO=none
PEERDNS=no
HWADDR=00:0BB:8E:98:9B
TYPE=Ethernet
IPV6INIT=no
DEVICE=eth1
MTU=""
NETMASK=255.255.255.0
BROADCAST=192.168.172.255
IPADDR=192.168.172.2
NETWORK=192.168.172.0
ONBOOT=yes
USERCTL=no
O gateway esta na interface eth1 mas o comando route me mostra na eth0. O que faço agora?
Minhas linhas de nat.
iptables=/sbin/iptables
#
IF_EXTERNA=eth1
IF_INTERNA=eth0
#
#Habilita (NAT)
$iptables -t nat -A POSTROUTING -o $IF_EXTERNA -j MASQUERADE
#
#Redireciona Todas as portas para a 8080 (http) (Squid)
$iptables -t nat -A PREROUTING -s 192.168.172.0/24 -p tcp --dport 80 -j REDIRECT --to 8080
$iptables -t nat -A PREROUTING -s 192.168.172.0/24 -p udp --dport 80 -j REDIRECT --to 8080
$iptables -t nat -A PREROUTING -s localhost -p tcp --dport 80 -j REDIRECT --to 8080
$iptables -t nat -A PREROUTING -s localhost -p udp --dport 80 -j REDIRECT --to 8080