I have a a Centos PC with 2 IP addresses. One of them is because of a back to back connection with another PC, so both run on different subnets. The eth0 has the 192.xx.xx.xxx address and eth2 has 172.xx.xx.xxx on this PC.
Since 192.xx.xx.xxx is a back to back connection it doesn’t have internet capability, but 172.xx.xx.xxx does. The default is set to 192.xx.xx.xxx, so whenever I do a
yum
update or anything it goes through 192.xx.xx.xxx, it is not able to perform the update or I am not even able to ping www.google.com.Is there a way I can set the default IP address for eth2 to, e.g., 172.xx.xx.xxx?
I have already tried going to the /etc/sysconfig/network and setting the gateway to 172.x.y.z, but it didnt work .
Answer
You need to setup the default gateway….you must know the router address off the 172 network to do this.
Open /etc/sysconfig/network file:
vi /etc/sysconfig/network
Setup GATEWAY={Router-IP}, if router IP is 172.x.y.z, type:
GATEWAY=172.x.y.z
Save and close the file. Here would be the completed file:
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=my.hostname.com
GATEWAY=172.x.y.z
Attribution
Source : Link , Question Author : vadugs , Answer Author : mdpc