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-gatewayExample :#route add default gw 192.168.0.1Here 192.168.0.1 is the default gate of my system.Through GUI toolsUse system-config-network in terminal or GUI to set up default gateway. Please visit http://www.linuxnix.com for more linux admin...Read More
Month: July 2010
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-noExample :[[email protected] ~]# cat /etc/sysconfig/networking/devices/ifcfg-eth0# Intel Corporation 82546EB Gigabit Ethernet Controller (Copper)DEVICE=eth0BOOTPROTO=noneHWADDR=00:02:a5:4c:af:99ONBOOT=yesTYPE=EthernetNETMASK=255.255.255.0IPADDR=10.200.0.21GATEWAY=10.200.0.1Through route commandrouteExample:Kernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface192.168.0.0 * 255.255.255.0 U 0 0 0 eth126.96.36.199 * 255.255.255.0 U 0 0 0 eth0169.254.0.0 * 255.255.0.0 U 0 0 0 eth1default 10.200.0.1 0.0.0.0 UG 0 0 0 eth0Through ip route commandip routeExample :[[email protected] ~]# ip route192.168.0.0/24 dev eth1 proto kernel scope link src 192.168.0.110.78.0.0/24 dev eth0 proto kernel scope link src 10.78.0.211188.8.131.52/16 dev eth1 scope linkdefault via 10.200.0.1 dev eth0Through netstat commandnetstat -rExample:[[email protected] ~]# netstat -rKernel IP routing tableDestination Gateway Genmask Flags MSS Window irtt Iface192.168.0.0 * 255.255.255.0 U 0 0 0 eth184.108.40.206 * 255.255.255.0 U 0 0 0 eth0169.254.0.0 * 255.255.0.0 U 0 0 0 eth1default 10.200.0.1 0.0.0.0 UG 0 0 0 eth0Note: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. Please visit http://www.linuxnix.com for more linux admin...Read More
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-nameExample : #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/hostname office-laptop.example.com Save the file and exit Then your hostname is changed permanently to your desired name. Please visit http://www.linuxnix.com for more linux admin...Read More
Get more stuff like this
in your inbox
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Thank you for subscribing.
Something went wrong.
we respect your privacy and take protecting it seriously
My name is Surendra Kumar Anne. I hail from Vijayawada which is cultural capital of south Indian state of Andhra Pradesh. I am a Linux evangelist who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. At present I work at Bank of America as Sr. Analyst Systems and Administration. You can contact me at surendra (@) linuxnix dot com.