Linux Network Configuration-1
Nov. 20th, 2015 04:54 pmLinux Network Configuration
Networking, set-up and administration
This Linux tutorial covers TCP/IP networking, network administration and system configuration basics. Linux can support multiple network devices. The device names are numbered and begin at zero and count upwards. For example, a computer running two ethernet cards will have two devices labeled /dev/eth0 and /dev/eth1. Linux network configuration, management, monitoring and system tools are covered in this tutorial.
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.confRed 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: |
- File: /etc/resolv.conf - host name resolver configuration file
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
Red Hat/Fedora GUI: /usr/sbin/system-config-network (select tab "DNS"). - File: /etc/hosts - locally resolve node names to IP addresses
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)Red Hat/Fedora configuration GUI: /usr/sbin/system-config-network (select tab "Hosts"). - File: /etc/nsswitch.conf - System Databases and Name Service Switch configuration file
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: |
- /etc/sysconfig/network Red Hat network configuration file used by the system during the boot process.
- File: /etc/sysconfig/network-scripts/ifcfg-eth0
Configuration settings for your first ethernet port (0). Your second port is eth1. - File:
- /etc/modprobe.conf (kernel 2.6)
- /etc/modules.conf (kernel 2.4)
- (or for older systems: /etc/conf.modules)
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 assigned 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.
Static IP address assignment:
Choose one of the following methods:
- Command Line:
/sbin/ifconfig eth0 192.168.10.12 netmask 255.255.255.0 broadcast 192.168.10.255
Network address by convention would be the lowest: 192.168.10.0
Broadcast address by convention would be the highest: 192.168.10.255
The gateway can be anything, but following convention: 192.168.10.1Note: the highest and lowest addresses are based on the netmask. The previous example is based on a netmask of 255.255.255.0 - Red Hat / Fedora GUI tools:
- /usr/bin/neat Gnome GUI network administration tool. Handles all interfaces. Configure for Static IP or DHCP client.
(First available with Red Hat 7.2.) - /usr/bin/netcfg (Handles all interfaces) (last available in Red Hat 7.1)
- /usr/bin/neat Gnome GUI network administration tool. Handles all interfaces. Configure for Static IP or DHCP client.
- Red Hat / Fedora Console tools:
- /usr/sbin/system-config-network-tui (Text User Interface)
- /usr/sbin/netconfig (Only seems to work for the first network interface eth0 but not eth1,...)
- Directly edit configuration files/scripts. See format below.
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:
- Network Calculators: Subnet mask calculator, node calculator, mask inverter, ...
- IP subnet calculator
| Command line IP Configuration: ifconfig |
ifconfig interface [aftype] options | address ...
where: - interface: eth0, eth1, eth2 represent the computer ethernet interfaces
- aftype: inet (TCP/IP, default), inet6 (IPv6), ax25 (AMPR Packet Radio), ddp (Appletalk Phase 2), ipx (Novell IPX) or netrom (AMPR Packet radio)
Man page: ifconfigOption 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
- Static IP example:
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.110Dynamic IP (DHCP) example:
Interfaces: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- lo: Loopback interface (network within your system without slowing down for the real ethernet based network)
- eth0: First ethernet interface card
- wlan0: First wireless network interface
Also see "man interfaces"
- /usr/bin/gnome-nettool (apt-get install gnome-nettool)

- /usr/bin/network-admin (apt-get install gnome-network-admin)

http://www.yolinux.com/TUTORIALS/LinuxTutorialNetworking.html

