Linux Networking
Total Page:16
File Type:pdf, Size:1020Kb
Linux Networking This tutorial covers TCP/IP networking 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. Tutorial Contents: Other YoLinux Networking Tutorials: l # Configuration files l Setting up an internet gateway for home or office l # Red Hat Linux network GUI using iptables configuration tools. l Load balancing servers using LVS (Linux Virtual l # Assigning an IP address Server) l # Activating and DeActivating your NIC l Modem dialup: l # Subnets ¡ Configuring PPP dial up connections to an l # Enable Forwarding ISP l # Adding a network interface card (NIC) ¡ Dialing Compuserve l # Route ¡ Dialing AOL l # VPN, Tunneling ¡ Configuring PPP dialin connections l # Usefull Linux networking commands l DNS Name server configuration l # inetd/xinetd: Network Socket l DHCP server configuration: Dynamic Host Listener Daemons Configuration Protocol # rwhod: Remote Who Daemon l l NIS authentication configuration: Server and Client # RPC: Remote Procedure Call. l l Internet/Network Security (portmapper) l Security Tools and Hacker Tools l # PAM: Network Wrappers. l YoLinux Tutorials Index l # ICMP protocol. l # Network Monitoring Tools l # IDS: Intruder Detection System SNORT l # ARP: Address Resolution Protocol l # Configuring Linux For Network Multicast l # Living in a MS/Windows world l # Network Definitions l # Related Links TCP/IP Network Configuration Files: l File: /etc/resolv.conf host name resolver configuration file search nameofdomain.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 This configures Linux so that it knows which DNS server will be resolving domain names into IP addresses. If using DHCP client, this will automatically be sent to you by the ISP and loaded into this file as part of the DHCP protocol. If using a static IP address, ask the ISP or check another machine on your network. Red Hat/Fedora GUI: /usr/sbin/systemconfignetwork (select tab "DNS". l File: /etc/hosts locally resolve node names to IP addresses 127.0.0.1 yournodename.yourdomain.com localhost.localdomain localhost XXX.XXX.XXX.XXX nodename Note when adding hosts to this file, place the fully qualified name first. (It helps sendmail identify your server correctly) i.e.: XXX.XXX.XXX.XXX superserver.yolinux.com superserver This 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 GUI: /usr/sbin/systemconfignetwork (select tab "Hosts". l File: /etc/nsswitch.conf System Databases and Name Service Switch configuration file hosts: files dns nisplus nis This example tells Linux to first resolve a host name by looking at the local hosts file(/etc/hosts), then if the name is not found look to your DNS server as defined by /etc/resolv.conf and if not found there look to your NIS server. In the past this file has had the following names: /etc/nsswitch.conf, /etc/svc.conf, /etc/netsvc.conf, ... depending on the distribution. Free Information Technology Magazine Fedora / Red Hat Network Configuration Files: Subscriptions and Document l /etc/sysconfig/network Downloads Red Hat network configuration file used by the system during the boot process. l File: /etc/sysconfig/networkscripts/ifcfgeth0 Configuration settings for your first ethernet port (0). Your second port is eth1. l File: ¡ /etc/modprobe.conf (kernel 2.6) ¡ /etc/modules.conf (kernel 2.4) ¡ (or for older systems: /etc/conf.modules) Example statement for Intel ethernet card: alias eth0 eepro100 Modules for other devices on the system will also be listed. This tells the kernel which device driver to use if configured as a loadable module. (default for Red Hat) 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: l Network configuration: /usr/sbin/systemconfignetwork (FC2/3) GUI shown here > /usr/bin/redhatconfignetwork (/usr/bin/neat) (RH 7.2+ FC1) l Text console configuration tool: /usr/sbin/systemconfignetworktui (Text User Interface (TUI) for Fedora Core 2/3) /usr/bin/redhatconfignetworktui (RH 9.0 FC1) l Text console network configuration tool. First interface only eth0: /usr/sbin/netconfig l /usr/bin/netcfg (GUI) (last available with RH 7.1) Gnome Desktop: l Gnome Desktop Network Configuration /usr/bin/gnomenetworkpreferences (RH 9.0 FC3) Proxy configuration. Choose one of three options: 1. Direct internet connection 2. Manual proxy configuration (specify proxy and port) 3. Automatic proxy configuration (give URL) Assigning an IP address: Computers may be assiged a static IP address or assigned one dynamically. Static IP address assignment: Choose one of the following methods: l 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.1 Note: the highest and lowest addresses are based on the netmask. The previous example is based on a netmask of 255.255.255.0 l 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) l Red Hat / Fedora Console tools: ¡ /usr/sbin/systemconfignetworktui (Text User Interface) ¡ /usr/sbin/netconfig (Only seems to work for the first network interface eth0 but not eth1,...) l 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 commands to the end of the file /etc/rc.d/rc.local to execute them upon boot.) The commands netcfg and netconfig make permanent changes to system network configuration files located in /etc/sysconfig/networkscripts/, so that this information is retained. The IANA has allocated IP addresses in the range of 192.168.0.0 to 192.168.255.255 for private networks. Helpful tools: l Network Calculators: Subnet mask calculator, node calculator, mask inverter, ... l IP subnet calculator 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.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 Interfaces: l lo: Loopback interface (network within your system without slowing down for the real ethernet based network) l eth0: First ethernet interface card l wlan0: First wireless network interface 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. l File: /etc/sysconfig/network Static IP address Configuration: (Configure gateway address) NETWORKING=yes HOSTNAME=myhostname Hostname is defined here and by command hostname 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. OR for DHCP client configuration: NETWORKING=yes HOSTNAME=myhostname Hostname is defined here and by command hostname (Gateway is assigned by DHCP server.) OR for NIS client configuration: NETWORKING=yes HOSTNAME=myhostname Hostname is defined here and by command hostname NISDOMAIN=NISProject1 NIS domain to attach l File (Red Hat/Fedora): /etc/sysconfig/networkscripts/ifcfgeth0 (S.u.s.e.: /etc/sysconfig/network/ifcfgethidXX:XX:XX:XX:XX) This file used by the command scripts ifup and ifdown 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 Will activate upon system boot RHEL4/FC3 additions: l TYPE=Ethernet l HWADDR=XX:XX:XX:XX:XX:XX l GATEWAY=XXX.XXX.XXX.XXX OR for DHCP client configuration: DEVICE=eth0 ONBOOT=yes BOOTPROTO=dhcp RHEL4/FC3 additions: l IPV6INIT=no l USERCTL=no l PEERDNS=yes l TYPE=Ethernet l HWADDR=XX:XX:XX:XX:XX:XX (Used by script /etc/sysconfig/networkscripts/ifup to bring the various network interfaces online) To disable DHCP change BOOTPROTO=dhcp to BOOTPROTO=none 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) Changing the host name: This is a three step process: 1. Issue the command: hostname newhostname 2. Change network configuration file: /etc/sysconfig/network Edit entry: HOSTNAME=newhostname 3.