Linux Routing table and Naming related commands
To check the routing table :
[root@apps /]# route
or
[root@apps /]# route -n
To add a default route or gateway:
[root@apps /]# route add default gw 192.168.1.254
To delete a default gateway:
[root@apps /]# route del default
To add a route to a network
[root@apps /]# route add –net 192.168.1.0 netmask 255.255.255.0 dev eth0
To delete a network from the routing table
root@apps /]# route del –net 192.168.1.0 netmask 255.255.255.0 dev eth0
To add a host route:
[root@apps /]# route add 192.168.1.1 eth0
To delete a host route
[root@apps /]# route del 192.168.1.1
To trace the path / number of hops to a particular host on the network:
[root@apps /]# traceroute workstation1.mydomain.com
or
[root@apps /]# traceroute www.linux.org
To do tracing of the route and ping at the same time, use mtr:
[root@apps /]# mtr workstation1.mydomain.com
To find a host and/or it's IP on the network use the following commands. These will query your default DNS server of your network:
[root@apps /]# host workstation1.mydomain.com
or
[root@apps /]# nslookup workstation1.mydomain.com
or
[root@apps /]# dig workstation1.mydomain.com
You can use hostname to get the FQDN of the a specific host. But remember that the FQDN hostname must be set in either /etc/sysconfig/network file or must be set manually using the hostname command. It is a good practice to write FQDN of each computer in it's own /etc/sysconfig/network file. The checkis that the command hostname –-fqdn must return the FQDN of your machine. See below.
[root@apps /]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=apps.mydomain.com
[root@apps /]# hostname
apps.mydomain.com
[root@apps /]# hostname --fqdn
apps.mydomain.com
In order to find out the name of your DNS domain, you should not use domainname command without arguments, as it will return you the name of the NIS domain, which in this case is not yet set. You can use -d switch with domainname command or use dnsdomainname command. The domainname -y also returns you the name of NIS domain (equal to ypdomainname command).
[root@apps /]# domainname
(none)
[root@apps /]# domainname -d
mydomain.com
[root@apps /]# dnsdomainname
mydomain.com
[root@apps /]# domainname -y
(none)
[root@apps /]# ypdomainname
(none)
To check the status of a wintendo machine on your network, use:
[root@apps /]# nmblookup -A workstation1.mydomain.com
or
[root@apps /]# nmblookup -A 192.168.1.1
To check for the open ports on a machine on the network (may be the localhost itself):
[root@apps /]# nmap workstation1.mydomain.com
[root@apps /]# route
or
[root@apps /]# route -n
To add a default route or gateway:
[root@apps /]# route add default gw 192.168.1.254
To delete a default gateway:
[root@apps /]# route del default
To add a route to a network
[root@apps /]# route add –net 192.168.1.0 netmask 255.255.255.0 dev eth0
To delete a network from the routing table
root@apps /]# route del –net 192.168.1.0 netmask 255.255.255.0 dev eth0
To add a host route:
[root@apps /]# route add 192.168.1.1 eth0
To delete a host route
[root@apps /]# route del 192.168.1.1
To trace the path / number of hops to a particular host on the network:
[root@apps /]# traceroute workstation1.mydomain.com
or
[root@apps /]# traceroute www.linux.org
To do tracing of the route and ping at the same time, use mtr:
[root@apps /]# mtr workstation1.mydomain.com
To find a host and/or it's IP on the network use the following commands. These will query your default DNS server of your network:
[root@apps /]# host workstation1.mydomain.com
or
[root@apps /]# nslookup workstation1.mydomain.com
or
[root@apps /]# dig workstation1.mydomain.com
You can use hostname to get the FQDN of the a specific host. But remember that the FQDN hostname must be set in either /etc/sysconfig/network file or must be set manually using the hostname command. It is a good practice to write FQDN of each computer in it's own /etc/sysconfig/network file. The checkis that the command hostname –-fqdn must return the FQDN of your machine. See below.
[root@apps /]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=apps.mydomain.com
[root@apps /]# hostname
apps.mydomain.com
[root@apps /]# hostname --fqdn
apps.mydomain.com
In order to find out the name of your DNS domain, you should not use domainname command without arguments, as it will return you the name of the NIS domain, which in this case is not yet set. You can use -d switch with domainname command or use dnsdomainname command. The domainname -y also returns you the name of NIS domain (equal to ypdomainname command).
[root@apps /]# domainname
(none)
[root@apps /]# domainname -d
mydomain.com
[root@apps /]# dnsdomainname
mydomain.com
[root@apps /]# domainname -y
(none)
[root@apps /]# ypdomainname
(none)
To check the status of a wintendo machine on your network, use:
[root@apps /]# nmblookup -A workstation1.mydomain.com
or
[root@apps /]# nmblookup -A 192.168.1.1
To check for the open ports on a machine on the network (may be the localhost itself):
[root@apps /]# nmap workstation1.mydomain.com
Comments
Post a Comment