8. Network Administration
ifconfig is used to configure network interfaces.
ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up
This configures interface eth0 with an IP of 192.168.1.10/255.255.255.0. Note that “up” is assumed if left off. A default network mask will also be determined by the IP if it is not specified.
route is used configure routing information.
route add -net 10.20.30.40 netmask 255.255.255.248 eth0
route add -net 10.20.30.48 netmask 255.255.255.248 gw 10.20.30.41
The first line states that the route to network 10.20.30.40/255.255.255.248 is through our local interface eth0. The second line states that the route to network 10.20.30.48/255.255.255.248 is through gateway 10.20.30.41
arp is used to administer the arp cache. It can view, add, and delete entries in the cache.
o View arp cache:
This will display something like:
Address HWtype HWaddress Flags Mask Iface
192.168.1.1 ether 00:60:08:27:CE:A2 C eth0
192.168.1.12 ether 00:80:5F:01:74:13 C eth0
192.168.1.15 ether 00:60:08:27:CE:B2 CM eth0
192.168.1.20 ether 00:A0:CC:25:9F:4C C eth0
The “C” flag means it’s a complete entry. The “M” flag indicates it’s an entry added manually and it is permanent.
o Add an entry:
arp -s 192.168.33.15 00:60:08:27:CE:B2
o Delete an entry:
arp -d 192.168.33.15
ping is used to troubleshoot network/host connectivity. It uses ICMP echo request and echo reply to test the connectivity. If a host doesn’t respond, it could be for any number of reasons:
o The remote host is down.
o The remote host is filtering ICMP packets.
o Some point in the network in-between the two hosts is down.
o A device in-between the two hosts is filtering ICMP packets.
ping -b 192.168.1.0
The first line pings a single host, 192.168.1.12. The second line performs a broadcast ping to all hosts on the 192.168.1.0 network.
traceroute is also used to test network/host connectivity. However, it displays each hop along the way from the source to the destination. It can help you determine if the problem is with the remote host itself, or some point in-between the hosts.
This will print a line for each hop in-between the local and remote host (192.168.10.100) as well as a line for the final destination up to a maximum of 30 hops.
netstat provides a lot of useful information, including:
o Routing tables.
o Interface statistics (dropped packets, buffer overruns, etc.)
o Network connections.
o Multicast memberships.
netstat -i # Display interface statistics
netstat -lpe # Display all listening sockets and the programs that own them
netstat -r # Display routing information
netstat -ape # Show all listening and non-listening sockets
o TUI based.
o Used to configure network interface.
o Used by text based installation methods.
This is a GUI administration tool that allows you to configure several aspects of your networking: interfaces, boot protocols, host resolution, routing, and more.
9. ifup / ifdown
These shell script wrappers allow you to bring an interface up and take it down. They use the configuration information in the /etc/sysconfig directory to configure the interface specified.
For example, to bring up interface eth0, simply type:
8.2 Configuring Interfaces
1. Configuration files
The configuration files for network interfaces all reside in /etc/sysconfig. For a complete description of these configuration files, see /usr/share/doc/initscripts-X.XX/sysconfig.txt where X.XX is the version of initscripts that you have installed.
The first option enables networking, and the second sets the host name. A default gateway can also be specified here using the “GATEWAY=” option, but it is usually specified in the “ifcfg-
This contains the configuration options for a single interface.
1. For a device that uses DHCP, it may look like:
4. ONBOOT=yes # Start at boot up?
14. USERCTL=no # Allow users to control this interface?
17. PEERDNS=no # Should we modify /etc/resolv.conf if using DHCP or BOOTP?
Most of the items above should be self explanatory. The only required options for a client using DHCP are “DEVICE” and “BOOTPROTO”.
19. For a device using a statically assigned IP, it will look similar to this.
22. ONBOOT=yes # Start at boot up?
32. USERCTL=no # Allow users to control this interface?
35. PEERDNS=no # Should we modify /etc/resolv.conf if using msdns?
37. GATEWAY=192.168.33.1 # Default Gateway
The only required options are “DEVICE” and “IPADDR”. Most of the other options can be derived from the IPADDR if your network is configured based on network classes. If you aren’t subnetting on an octet, a netmask is required.
2. Manual Configuration
One way to configure an interface is to edit the above files directly with a text editor. After you are done editing them, execute an “ifdown” followed by an “ifup”. This should reset your interfaces to the new values you’ve specified.
3. GUI Configuration
You can also use the “redhat-config-network” tool to configure your interfaces.
8.3 Configuring Routes
1. Configuration files
The configuration files for routing are also located under /etc/sysconfig.
This file contains static routing information that should be added to the routing tables when interfaces are brought up. It has the following format:
eth0 net 10.20.30.0 netmask 255.0.0.0 gw 192.168.1.50
Adds a route to network 10.20.30.0/255.0.0.0 using the gateway at 192.168.1.50 to device eth0.
For devices with static IPs, this file is typically used to specify the default gateway for the device (see Interface Configuration above).
2. Manual Configuration
Same as “Interface Manual Configuration” above.
3. GUI Configuration
Same as “Interface GUI Configuration” above.
8.4 Host Resolution
Host names can be resolved using DNS or through a local lookup file /etc/hosts. By default, /etc/hosts is consulted before performing a DNS lookup. However, the resolution order can be changed by modifying /etc/nsswitch.conf.
o /etc/hosts format:
o IP address Host Name Aliases
192.168.1.1 gateway.somedomain.com gateway gate gw
192.168.1.20 somehost.somedomain.com somehost some
192.168.1.25 otherhost.somedomain.com otherhost
This contains the ip addresses of up to 3 DNS servers that will be consulted when trying to perform host name lookups.
search somedomain.com otherdomain.com
The “domain” options specifies the local domain. If a host lookup is performed and a FQDN isn’t specified, this domain is appended to the host name to create the FQDN. The “search” options specifies the order in which the domains should be queried if a host lookup is requested without specifying a FQDN. The “domain” and “search” options are mutually exclusive. If both are specified, the last one given is used.