How to Assign Default gateway in linux?
Ans : In linux Default gateway is set through route command or GUI tools.
Through Route command
#route add default gw default-gateway
Example :
#route add default gw 192.168.0.1
Here 192.168.0.1 is the default gate of my system.
Through GUI tools
Use system-config-network in terminal or GUI to set up default gateway.
How To Assign Default Gateway In Linux?
0 comments 7/09/2010 07:38:00 AM Posted by Meghana M BhombhoreLabels: Basics, General, How-To's
How To View Default Gateway In Linux?
0 comments 7/07/2010 09:11:00 AM Posted by Meghana M BhombhoreLabels: Basics, How-To's
This is asked in some of the interviews. We can get default gateway information in linux in many ways. Such as viewing network card file or executing a command.
To see default gateway by view network interface card file content.
#cat /etc/sysconfig/networking/devices/interface-no
Example :
[root@example ~]# cat /etc/sysconfig/networking/devices/ifcfg-eth0
# Intel Corporation 82546EB Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:02:a5:4c:af:99
ONBOOT=yes
TYPE=Ethernet
NETMASK=255.255.255.0
IPADDR=10.200.0.21
GATEWAY=10.200.0.1
Through route command
route
Example:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 * 255.255.255.0 U 0 0 0 eth1
10.78.0.0 * 255.255.255.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth1
default 10.200.0.1 0.0.0.0 UG 0 0 0 eth0
Through ip route command
ip route
Example :
[root@example ~]# ip route
192.168.0.0/24 dev eth1 proto kernel scope link src 192.168.0.1
10.78.0.0/24 dev eth0 proto kernel scope link src 10.78.0.21
169.254.0.0/16 dev eth1 scope link
default via 10.200.0.1 dev eth0
Through netstat command
netstat -r
Example:
[root@example ~]# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.0.0 * 255.255.255.0 U 0 0 0 eth1
10.78.0.0 * 255.255.255.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth1
default 10.200.0.1 0.0.0.0 UG 0 0 0 eth0
Note:For any system/server there will be only one default gateway, if suppose if you assign two default gateways to your machine, your system will not come to know where to send the packets.
How To Assign Or Change Hostname In Linux?
0 comments 7/05/2010 07:46:00 AM Posted by Meghana M BhombhoreLabels: How-To's
Computers are assigned with a name as we do for humans beings. This is called hostname in computer world. So how to assign a hostname to a Linux system? Its very much simple. Before doing this we should know every task in Linux can be done in two ways :
1. Temporary way(once you boot your system the changes made in this way will go away)
2. Permanent way(Changes made in this way will be retained even after rebooting of the system).
Before changing the hostname, check what is your present system name by using hostname command
#hostname
This command will show present system name.
Now we will see how to assign a host name to a linux machine in both(temporary as well as permanent) ways.
Temporary way : Use hostname command to change the host name
#hostname your-system-name
Example : #hostname office-laptop.example.com
Permanent way : Change hostname in Redhat/CentOS/Fedora :
Edit /etc/sysconfig/network file, use HOSTNAME variable in that file to denote hostname.
#vi /etc/sysconfig/network
HOSTNAME=office-laptop.example.com
Save the file and exit
Then your hostname is changed permanently to your desired name.
Change hostname in Ubuntu/Debian : Edit /etc/hostname, just write down what is your hostname in to that file.
#vi /etc/hostnameoffice-laptop.example.com
Save the file and exit
Then your hostname is changed permanently to your desired name.