The "hosts" file in Ubuntu and other operating systems is used to associate host names with IP addresses.
# /etc/hosts (for master AND slave)
192.168.0.1 master
192.168.0.2 slave
what it mean if you on on master server u can ping slave
, u don't have to put 192.168.0.2
how does it work
by ping slave from master u don't have to remember the ip address of slave just ping slave & /etc/hosts file will resolve the with the ip automatically
u can edit the network configuration /etc/network/interfaces
(Master)
auto eth0
iface eth0 inet static
address 192.168.0.1 (or any ip u want )
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1 ( Your gateway , Your router ip )
(Slave)
auto eth0
iface eth0 inet static
address 192.168.0.2 ( or any ip u want )
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1 ( Your gateway , Your router ip )
Now in both edit /etc/hosts file add master slave entries
Now how to find GATEWAY
before doing anything type # route
route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default **192.168.0.1** 0.0.0.0 UG 0 0 0 eth0
OR
route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 **192.168.0.1** 0.0.0.0 UG 0 0 0 eth0
Hope This Will Help You