|
Linux servers. Network basic configuration. ifconfig, route. |
Network basic configuration
The basic commands used in Linux are common to every distro:
ifconfig - Configures and displays the IP parameters of a network interface route - Used to set static routes and view the routing table hostname - Necessary for viewing and setting the hostname of the system netstat - Flexible command for viewing information about network statistics, current connections, listeing ports arp - Shows and manages the arp table mii-tool - Used to set the interface parameters at data link layer (half/full duplex, interface speed, autonegotiation...)
Many distro are now including the iproute2 tools with enhanced routing and networking tools: ip - Multi purpose command for viewing and setting TCP/IP parameters and routes. tc Traffic control command, used for classifying, prioritizing, sharing, and limiting both inbound and outbound traffic.
Every distro has its own configuration tool that operate on variously defined configuration files. Some of them are common: /etc/resolv.conf, /etc/nsswitch.conf, /etc/hosts - The main purpose of this file is to resolve hostnames that cannot be resolved any other way. It can also be used to resolve hostnames on small networks with no DNS server. Regardless of the type of network the computer is on, this file should contain a line specifying the IP address of the loopback device (127.0.0.1) as localhost.localdomain. For more information, see the hosts man page. /etc/services - Internet network services list. It associates port numbers with names of services. The file contains three fields which are name, port/protocol, and aliases with an optional comment. /etc/protocols - Describes DARPA internet protocols available from the TCP/IP subsystem. Maps protocol ID numbers to protocol names. It includes protocol name, number, and aliases. The protocol file on my system:
Some, typically the ones where are defined IP addresses and routes, change. Here are some relevant files for various distro, their syntax may vary according the scripts used to handle them:
Debian /etc/network/interfaces - Interfaces and network parameters
Fedora or RedHat Graphical interface: redhat-config-network /etc/sysconfig/network-scripts/ifcfg-* - Configuration files for each interface. The same file can be found, divided per profile, in /etc/sysconfig/networking/devices/* /etc/sysconfig/network - Hostname, default gateway, general configuration /etc/sysconfig/static-routes - Static routes (if any)
SlackWare Graphical interface: Netconfig /etc/rc.d/rc.inet1 - IP and network parameters /etc/rc.d/rc.inet2 - Network Services configuration
Mandrake Graphical interface: Drakconnect /etc/sysconfig/network-scripts/ifcfg-* - Configuration files for each interface. The same file can be found, divided per profile, in /etc/sysconfig/networking/devices/* /etc/sysconfig/network - Hostname, default gateway, general configuration /etc/sysconfig/static-routes - Static routes (if any)
Gentoo /etc/conf.d/net - Ip network and interfaces parameters /etc/conf.d/routes - Static routes
SUSE Graphical interface: Yest2 /etc/sysconfig/network/ifcfg-* - Configuration files for each interface. /etc/sysconfig/network/config - General network configuration.
To enable networking, you must configure your network interface card or cards with an IP address and netmask. If you want to configure your network card to act as more than one IP address, issue the following command: ifconfig eth0 192.168.1.102 netmask 255.255.255.0/etc/resolv.conf - Specifies the domain to be searched for host names to connect to, the nameserver address, and the search order for the nameservers: domain mycompany.com search mycompany.com mynet.net nameserver 192.168.1.100 nameserver 192.168.199.1 nameserver 192.168.1.10Routes: route add default gw 192.168.1.254 or route add default gw 192.168.1.254 eth2
|