Linux TCP/IP Network Configuration Files: |
File | Description |
---|---|
/etc/resolve.conf | List DNS servers for internet domain name resolution. Manual page for: /etc/resolv.conf |
/etc/hosts | Lists hosts to be resolved locally (not by DNS). Manual page for: /etc/hosts |
/etc/nsswitch.conf | List order of host name search. Typically look at local files, then NIS server, then DNS server. Manual page for: /etc/nsswitch.conf |
Red Hat/Fedora/CentOS: /etc/sysconfig/network | Specify network configuration. eg. Static IP, DHCP, NIS, etc. |
Red Hat/Fedora/CentOS: /etc/sysconfig/network-scripts/ifcfg-device | Specify TCP network information. |
Ubuntu/Debian: /etc/network/interfaces | Specify network configuration and devices. eg. Static IP and info, DHCP, etc. |
Domain Resolution Configuration Files: |
search name-of-domain.com - Name of your domain or ISP's domain if using their name server nameserver XXX.XXX.XXX.XXX - IP address of primary name server nameserver XXX.XXX.XXX.XXX - IP address of secondary name server |
127.0.0.1 your-node-name.your-domain.com localhost.localdomain localhost XXX.XXX.XXX.XXX node-name |
XXX.XXX.XXX.XXX superserver.yolinux.com superserverThis informs Linux of local systems on the network which are not handled by the DNS server. (or for all systems in your LAN if you are not using DNS or NIS)
The file format for the hosts file is specified by RFC 952.
Red Hat/Fedora configuration GUI: /usr/sbin/system-config-network (select tab "Hosts").
hosts: files dns nisplus nis |
In the past this file has had the following names: /etc/nsswitch.conf, /etc/svc.conf, /etc/netsvc.conf, ... depending on the distribution.
Fedora / Red Hat Network Configuration Files: |
Red Hat network configuration file used by the system during the boot process.
alias eth0 eepro100 |
Fedora / Red Hat Network GUI Configuration Tools: |
The following GUI tools edit the system configuration files. There is no difference in the configuration developed with the GUI tools and that developed by editing system configuration files directly.
TCP/IP ethernet configuration:
|
![]() |
Assigning an IP address: |
Computers may be assiged a static IP address or assigned one dynamically. Typically a server will require a static IP while a workstation will use DHCP (dynamic IP assignment). The Linux server requires a static IP so that those who wish to use its resources can find the system. It is more easily found if the IP address does not change and is static. This is not important for the Linux client workstation and thus it is easier to use an automated Dynamic Host Configuration Protocol (DHCP) for IP address assignment.
Choose one of the following methods:
/sbin/ifconfig eth0 192.168.10.12 netmask 255.255.255.0 broadcast 192.168.10.255Network address by convention would be the lowest: 192.168.10.0
Note: the highest and lowest addresses are based on the netmask. The previous example is based on a netmask of 255.255.255.0
The ifconfig command does NOT store this information permanently. Upon reboot this information is lost. Manually add the network configuration to /etc/sysconfig/network-scripts/ifcfg-eth0 (Red Hat/Fedora/CentOS) for the first NIC, ifcfg-eth1 for the second, etc, or /etc/network/interfaces (Ubuntu) as shown below. Any other commands you may want to add to the system boot sequence can be added to the end of the file /etc/rc.d/rc.local. The commands netcfg and netconfig make permanent changes to system network configuration files located in /etc/sysconfig/network-scripts/, so that this information is retained and used upon system boot.
The IANA has allocated IP addresses in the range of 192.168.0.0 to 192.168.255.255 for private networks.
Helpful tools:
Command line IP Configuration: ifconfig |
ifconfig interface [aftype] options | address ...
where:Option | Description |
---|---|
up | Activate the interface. Implied if IP addresses are specified. |
down | Shut down interface |
arp | Enable ARP protocol on this interface. Allow ARP to detect the addresses of computer hosts attached to the network. |
-arp | Disable ARP protocol on this interface |
promisc | Enable promiscuous mode. Receive all packets on the network not just those destined for this interface. |
-promisc | Disable promiscuous mode. |
mtu ## | Specify the Maximum Transfer Unit (MTU) of the interface. The MTU is the maximum number of octets the interface is able to handle in a single transaction. Defaults: Ethernet: 1500 SLIP: 296 |
broadcast XXX.XXX.XXX.XXX | Set the network broadcast address for this interface. |
netmask XXX.XXX.XXX.XXX | Set the IP network mask for this interface. |
Ubuntu / Debian IP Configuration Files: |
File: /etc/network/interfaces
auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 208.88.34.106 netmask 255.255.255.248 broadcast 208.88.34.111 network 208.88.34.104 gateway 208.88.34.110 |
Dynamic IP (DHCP) example:
auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp auto eth1 iface eth1 inet dhcp auto eth2 iface eth2 inet dhcp auto ath0 iface ath0 inet dhcp auto wlan0 iface wlan0 inet dhcp |
Also see "man interfaces"
Red Hat / Fedora Core IP Configuration Files: |
The Red Hat configuration tools store the configuration information in the file /etc/sysconfig/network.
They will also allow one to configure routing information.
Static IP address Configuration: (Configure gateway address)
NETWORKING=yes =my- - is defined here and by command FORWARD_IPV4=true - True for NAT firewall gateways and linux routers. False for everyone else - desktops and servers. GATEWAY="XXX.XXX.XXX.YYY" - Used if your network is connected to another network or the internet. Static IP configuration. Gateway not defined here for DHCP client. |
NETWORKING=yes =my- - is defined here and by command |
NETWORKING=yes =my- - is defined here and by command NISDOMAIN=NISProject1 - NIS domain to attach |
Static IP address configuration:
DEVICE=eth0 BOOTPROTO=static BROADCAST=XXX.XXX.XXX.255 IPADDR=XXX.XXX.XXX.XXX NETMASK=255.255.255.0 NETWORK=XXX.XXX.XXX.0 ONBOOT=yes |
OR for DHCP client configuration:
DEVICE=eth0 ONBOOT=yes BOOTPROTO=dhcp |
In order for updated information in any of these files to take effect, one must issue the command: service network restart (or: /etc/init.d/network restart)
Network IP aliasing: |
Assign more than one IP address to one ethernet card:
ifconfig eth0 XXX.XXX.XXX.XXX netmask 255.255.255.0 broadcast XXX.XXX.XXX.255 ifconfig eth0:0 192.168.10.12 netmask 255.255.255.0 broadcast 192.168.10.255 ifconfig eth0:1 192.168.10.14 netmask 255.255.255.0 broadcast 192.168.10.255 route add -host XXX.XXX.XXX.XXX dev eth0 route add -host 192.168.10.12 dev eth0 route add -host 192.168.10.14 dev eth0
Config file: /etc/sysconfig/network-scripts/ifcfg-eth0:0
DEVICE=eth0:0 ONBOOT=yes BOOTPROTO=static BROADCAST=192.168.10.255 IPADDR=192.168.10.12 NETMASK=255.255.255.0 NETWORK=192.168.10.0 ONBOOT=yes |
The option during kernel compile is: CONFIG_IP_ALIAS=y (Enabled by default in Redhat)
Note: The Apache web server can be configured so that different IP addresses can be assigned to specific domains being hosted. See Apache configuration and "configuring an IP based virtual host" in the YoLinux Web site configuration tutorial.
DHCP Linux Client: get connection info: /sbin/pump -i eth0 --status
(Red Hat Linux 7.1 and older)
Changing the host name: |
This is a three step process:
The hostname may be changed at runtime using the command: sysctl -w kernel.hostname="superserver"
Note that hostnames may only contain alphanumeric characters, minus signs ("-"), and periods ("."). They must begin with an alphabetic character and end with an alphanumeric character.
Change the host name using GUI tool: /usr/sbin/system-config-network
(Red Hat / Fedora / CentOS)
Hostname entries are made in two places:
![]() |
![]() |
Select the "DNS" tab. | Select the "Devices" tab + "Edit" + the "General" tab. |
Activating and De-Activating your NIC: |
Commands for starting and stopping TCP/IP network services on a Network Interface Card (NIC):
files in /etc/sysconfig/network-scripts/ GUI Interface control/configuration:
|
![]() |
Subnets: |
M A S K |
# OF SUB NETS |
Slash Fmt |
CLASS A HOSTS |
CLASS A MASK |
CLASS B HOSTS |
CLASS B MASK |
CLASS C HOSTS |
CLASS C MASK |
CLASS C SUB HOSTS |
CLASS C SUB MASK |
---|---|---|---|---|---|---|---|---|---|---|
255 | 1 or 256 |
/32 | 16,777,214 | 255.0.0.0 | 65,534 | 255.255.0.0 | 254 | 255.255.255.0 | Invalid 1 address |
255.255.255.255 |
254 | 128 | /31 | 33,554,430 | 254.0.0.0 | 131,070 | 255.254.0.0 | 510 | 255.255.254.0 | Invalid 2 addresses |
255.255.255.254 |
252 | 64 | /30 | 67,108,862 | 252.0.0.0 | 262,142 | 255.252.0.0 | 1,022 | 255.255.252.0 | 2 hosts 4 addresses |
255.255.255.252 |
248 | 32 | /29 | 134,217,726 | 248.0.0.0 | 524,286 | 255.248.0.0 | 2,046 | 255.255.248.0 | 6 hosts 8 addresses |
255.255.255.248 |
240 | 16 | /28 | 268,435,454 | 240.0.0.0 | 1,048,574 | 255.240.0.0 | 4,094 | 255.255.240.0 | 14 hosts 16 addresses |
255.255.255.240 |
224 | 8 | /27 | 536,870,910 | 224.0.0.0 | 2,097,150 | 255.224.0.0 | 8,190 | 255.255.224.0 | 30 hosts 32 addresses |
255.255.255.224 |
192 | 4 | /26 | 1,073,741,822 | 192.0.0.0 | 4,194,302 | 255.192.0.0 | 16,382 | 255.255.192.0 | 62 hosts 64 addresses |
255.255.255.192 |
128 | 2 | /25 | 2,147,483,646 | 128.0.0.0 | 8,388,606 | 255.128.0.0 | 32,766 | 255.255.128.0 | 126 hosts 128 addresses |
255.255.255.128 |
Binary position | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
Value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Example: 192 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
Example 192=128+64
Some addresses are reserved and outside this scope. Loopback (127.0.0.1), reserved class C 192.168.XXX.XXX, reserved class B 172.31.XXX.XXX and reserved class A 10.XXX.XXX.XXX.
Subnet Example:
Links:
Network Classes: |
The concept of network classes is a little obsolete as subnets are now used to define smaller networks using CIDR (Classless Inter-Domain Routing) as detailed above. These subnets may be part of a class A, B, C, etc network. For historical reference the network classes are defined as follows:
Enable Forwarding: |
The bridge configuration will merge two (or several) networks into one single network topology. IpTables firewall rules can be used to filter traffic.
A router configuration can support multicast and basic IP routing using the "route" command. IP masquerading (NAT) can be used to connect private local area networks (LAN) to the internet or load balance servers.
Another method is to alter the Linux kernel config file: /etc/sysctl.conf Set the following value:
net.ipv4.ip_forward = 1 |
See file /etc/sysconfig/network for storing this configuration.
FORWARD_IPV4=true |
All methods will result in a proc file value of "1". Test: cat /proc/sys/net/ipv4/ip_forward
The TCP Man page - Linux Programmer's Manual and /usr/src/linux/Documentation/proc.txt (Kernel 2.2 RH 7.0-) cover /proc/sys/net/ipv4accept_redirects do echo 1 > $f done
Command to view Kernel IP routing cache: /sbin/route -Cn
NOTE: This may leave you vulnerable to hackers as attackers may alter your routes.
Blocking ICMP and look invisible to ping: |
The following firewall rules will drop ICMP requests.
iptables -A OUTPUT -p icmp -d 0/0 -j DROPIpchains:
ipchains -A output -p icmp -d 0/0 -j DENY
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
Network Monitoring Tools: |
Command line option | Description |
---|---|
-c | Exit after receiving count packets. |
-C | Specify size of output dump files. |
-i | Specify interface if multiple exist. Lowest used by default. i.e. eth0 |
-w file-name | Write the raw packets to file rather than parsing and printing them out. They can later be printed with the -r option. |
-n | Improve speed by not performing DNS lookups. Report IP addresses. |
-t | Don't print a timestamp on each dump line. |
primitive | Description |
---|---|
host host-name | If host has multiple IP's, all will be checked. |
net network-number | Network number. |
net network-number mask mask | Network number and netmask specified. |
port port-number | Port number specified. |
tcp | Sniff TCP packets. |
udp | Sniff UDP packets. |
icmp | Sniff icmp packets. |
Examples:
[root]# ifconfig eth0 promisc - Put nic into promiscuous mode to sniff traffic. [root]# tcpdump -n host not XXX.XXX.XXX.XXX | more - Sniff net but ignore IP which is your remote session. [root]# ifconfig eth0 -promisc - Pull nic out of promiscuous mode.
Network Intrusion and Hacker Detection Systems: |
SNORT: Monitor the network, performing real-time traffic analysis and packet logging on IP networks for the detection of an attack or probe.
ARP: Address Resolution Protocol |
Ethernet hosts use the Address Resolution Protocol (ARP) to convert a 32-bit internet IP addresses into a 48-bit Ethernet MAC address used by network hardware. (See: RFC 826) ARP broadcasts are sent to all hosts on the subnet by the data transmitting host to see who replies. The broadcast is ignored by all except the intended receiver which recognizes the IP address as its own. The MAC addresses are remembered (APR cache) for future network communications. Computers on the subnet typically keep a cache of ARP responses. ARP broadcasts are passed on by hubs and switches but are blocked by routers.
Reverse ARP (See: RFC 903) is a bootstrap protocol which allows a client to broadcast requesting a server to reply with its IP address.
View ARP tables:ARP is something that simply works. No Linux system configuration is necessary. It's all part of the ethernet and IP protocol. The aforementioned information is just part of the Linux culture of full visibility into what is going on.
Configuring Linux For Network Multicast: |
Regular network exchanges of data are peer to peer unicast transactions. An HTTP request to a web server (TCP/IP), email SNMP (TCP/IP), DNS (UDP), FTP (TCP/IP), ... are all peer to peer unicast transactions. If one wants to transmit a video, audio or data stream to multiple nodes with one transmission stream instead of multiple individual peer to peer connections, one for each node, one may use multicasting to reduce network load. Note that multicast and a network broadcast are different. Multicast messages are only "heard" by the nodes on the network that have "joined the multicast group" which are those that are interested in the information.
The Linux kernel is Level-2 Multicast-Compliant. It meets all requirements to send, receive and act as a router for multicast datagrams. For a process to receive multicast datagrams it has to request the kernel to join the multicast group and bind the port receiving the datagrams. When a process is no longer interested in the multicast group, a request is made to the kernel to leave the group. It is the kernel/host which joins the multicast group and not the process. Kernel configuration requires "CONFIG_IP_MULTICAST=y". In order for the Linux kernel to support multicast routing, set the following in the kernel config:
The default Red Hat / Fedora kernels are compiled to support multicast.
See the YoLinux tutorial on optimization and rebuilding the Linux kernal.
Note that on multihomed systems (more than one IP address/network card), only one device can be configured to handle multicast.
Class D networks with a range of IP addresses from 224.0.0.0 to 239.255.255.255 (See Network Classes above) have typically been reserved for multicast.
Usefull commands:
Command | Description |
---|---|
cat /proc/net/igmp | List multicast group to which the host is subscribed. Use "Internet Group Management Protocol". (See /usr/src/linux/net/core/igmp.c) |
cat /proc/net/dev_mcast | List multicast interfaces. (See /usr/src/linux/net/core/dev_mcast.c) |
ping 224.0.0.1 | All hosts configured for multicast will respond with their IP addresses |
ping 224.0.0.2 | All routers configured for multicast will respond |
ping 224.0.0.3 | All PIM routers configured for multicast will respond |
ping 224.0.0.4 | All DVMRP routers configured for multicast will respond |
ping 224.0.0.5 | All OSPF routers configured for multicast will respond |
Multicast transmissions are achieved through proper routing, router configuration (if communicating through subnets) and programatically with the use of the following "C" function library calls:
Function Call | Description |
---|---|
setsockopt() | Pass information to the Kernel. |
getsockopt() | Retrieve information broadcast using multicast. |
The multicast application will specify the multicast loopback interface, TTL (network time to live), network interface and the multicast group to add or drop.
Serial Line IP: |
Linux can support IP protocol over serial device interfaces. Over long distances this is typically supported using a modem over telephone lines (POTS: Plain Old Telephone Service) or satellite communications.
PPP: Point-to-Point Protocol |
This is the most common form of IP over serial line and is the most common technique used by telephone dial-up ISPs. The following tutorials use a Hayes command set compatible modem.
SLIP: Serial Line IP (older than PPP and less capable) |
Devices:
Interfaces | Description | |||
---|---|---|---|---|
sl0 | sl1 | sl2 | sl3 | SLIP interfaces. Linux kernel supports up to four. |
COM1 | COM2 | COM3 | COM4 | Serial Ports (RS-232 hardware) |
/dev/ttyS0 | /dev/ttyS1 | /dev/ttyS2 | /dev/ttyS3 | Serial devices (dial in) (virtual terminal consoles) |
/dev/cua0 | /dev/cua1 | /dev/cua2 | /dev/cua3 | Serial devices (dial out) |
4 | 4 | 4 | 4 | Interface major numbers (dial in) |
5 | 5 | 5 | 5 | Interface major numbers (dial out) |
64 | 65 | 66 | 67 | Interface minor numbers |
PLIP: Parallel Line IP |
Point to point serial links (rather than broadcast networks line ethernet), can alsobe supported over parallel printer ports.
An IP network at 10 to 20 kBps over parallel printer ports lp0 or lp1 are much faster than serial. Linux supports mode 0 PLIP transferring half bytes of data at a time. Requires "NULL Printer" or "Turbo Laplink" printer connection. See kernel source drivers/net/Space.c.Interface | I/O Port | IRQ |
---|---|---|
plip0 | 0x3BC | 7 |
plip1 | 0x378 | 7 |
plip2 | 0x278 | 5 |
Serial port related man pages: |
Living in a MS/Windows World: |
Make your life simple and use the GUI/File Manager LinNeighborhood. It uses smbmount, samba and smbclient to give you access to MS/Windows servers and printers.
See the YoLinux tutorial on integrating Linux into a Microsoft network.
Network Definitions: |
OSI Layer | Description | Linux Networking Use |
---|---|---|
7 | Application Layer. The top layer for communications applications like email and the web. |
telnet, web browser, sendmail |
6 | Presentation Layer. Syntax and format of data transfer. |
SMTP, http |
5 | Session Layer. | |
4 | Transport Layer. Connection, acknowledgement and data packet transmission. |
TCP UDP |
3 | Network Layer. | IP ARP |
2 | Data Link Layer. Error control, timing |
Ethernet |
1 | Physical Layer. Electrical characteristics of signal and NIC |
Ethernet |
Related Links: |
Test Internet Bandwidth:
Man Pages: