#Dica - Alterando o gateway default no Oracle Linux


Para realizarmos a alteração do gateway default em um ambiente Oracle Linux devemos alterar o arquivo de configuração da interface de rede.

É possível consultar o gateway default em uso através do comando route.

[root@lamimtst files]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         172.22.0.3      0.0.0.0         UG    0      0        0 em1
172.22.0.0      *               255.255.254.0   U     0      0        0 em1
No exemplo abaixo, estaremos alterado o default gateway de 172.22.0.3 para 172.22.0.2 da interface de rede em1.
[root@lamimtst files]# ifconfig
em1       Link encap:Ethernet  HWaddr 18:66:DA:99:2C:42
          inet addr:172.22.0.20  Bcast:172.22.1.255  Mask:255.255.254.0
          inet6 addr: fe80::1a66:daff:fe99:2c42/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:20138355375 errors:0 dropped:2593782 overruns:27391 frame:0
          TX packets:20880226435 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3410493372618 (3.1 TiB)  TX bytes:6995001982923 (6.3 TiB)
          Memory:91c00000-91cfffff

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:41663998 errors:0 dropped:0 overruns:0 frame:0
          TX packets:41663998 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:10264674852 (9.5 GiB)  TX bytes:10264674852 (9.5 GiB)

[root@lamimtst files]# cat /etc/sysconfig/network-scripts/ifcfg-em1
DEVICE=em1
TYPE=Ethernet
UUID=6ee8aafe-4256-4179-b8bb-80f0415bcad6
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
HWADDR=18:66:DA:99:2C:42
IPADDR=172.22.0.20
PREFIX=23
GATEWAY=172.22.0.3
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System em1"
DNS1=172.22.0.3
Para isso basta alterar o GATEWAY de 172.22.0.3 para 172.22.0.2 e realizar um restart da interface de rede para que a alteração seja aplicada.
[root@lamimtst files]# service network restart
Shutting down interface em1:                               [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface em1:  Determining if ip address 172.22.0.20 is already in use for device em1...
                                                           [  OK  ]
[root@lamimtst files]#
[root@lamimtst files]#
[root@lamimtst files]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         172.22.0.2      0.0.0.0         UG    0      0        0 em1
172.22.0.0      *               255.255.254.0   U     0      0        0 em1
Caso não exista um GATEWAY definido para a interface de rede específica, o ambiente pode estar utilizando um gateway "global" que é configurado em /etc/sysconfig/network.
SHARE

Jhonata Lamim

  • Image
  • Image
  • Image
  • Image
  • Image