Transcript Linux

Linux
Setting up your network
Basic Approaches
• Configure during installation
– Disadvantage -> not able to redo easily
– Advantage-> holds your hand
• Configure after installation
– Disadvantage -> collision with other config tools
– Advantage-> fairly easy to use (99.5% coverage)
• Access files directly
– Disadvantage -> more details to know
– Advantage-> access to everything and a deeper
understanding
Access Files Directly
• Most of the files are in /etc
• Use installation to recognize NIC cards
• /etc/sysconfig to specify setup
• /etc/modules.conf to recognize cards
• /etc/rc.d/init.d to restart network
after configuring
• Add manual routes to static-routes
/etc
• Tons of configuration information
• Very small amount related to the
configuration of the network
• Focus on /etc/sysconfig first
• Use the installation process to recognize the
NIC cards.
• Edit sysconfig files afterwards if errors
occur.
Recognizing cards
• Installation is reasonably sophisticated.
• Most cards will be recognized either with a
generic driver or the real one.
• Use ifconfig to determine if card is
recognized. (see next overhead)
• For older cards use
/etc/modules.conf
ifconfig->
eth0 Link encap:Ethernet HWaddr 00:E0:7D:7A:AE:2C
inet addr:192.168.1.77 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:107551 errors:0 dropped:0 overruns:0 frame:0
TX packets:146864 errors:0 dropped:0 overruns:0 carrier:0
collisions:6947 txqueuelen:100
RX bytes:12906086 (12.3 Mb) TX bytes:27598982 (26.3 Mb)
Interrupt:5 Base address:0xe000
lo
Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1269 errors:0 dropped:0 overruns:0 frame:0
TX packets:1269 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:111800 (109.1 Kb) TX bytes:111800 (109.1 Kb)
Cards Recognized .. Next?
• Check the configuration of the network
• Use netstat to check the routing tables
• Be sure the cards are connected to the right
network if multiple cards (router)
• Use ping to check for connectivity.
netstat -nr
[root@testmachine]#netstat -nr
Kernel IP routing table
Destination
Gateway
192.168.1.0
0.0.0.0
127.0.0.0
0.0.0.0
0.0.0.0
192.168.1.1
Genmask
255.255.255.0
255.0.0.0
0.0.0.0
Flags
U
U
UG
MSS
40
40
40
Window
0
0
0
irtt
0
0
0
Iface
eth0
lo
eth0
Problems? General Networking
• Examine the network configuration files
/
etc
sysconfig
network
…
[prompt]# cat network
NETWORKING=yes
FORWARD_IPV4=false
HOSTNAME=testserver
DOMAINNAME=localdomain
GATEWAY=192.168.1.1
[prompt]#
Red Hat Fedora exception
to network file
• Format is same but…
• FORWARD_IPV4 flag is overridden by an
entry in a kernel configuration file named
/etc/sysctl.conf
• net.ipv4.ip_forward = 1
Each Device
/
etc
…
sysconfig
network
network-scripts
ifcfg-eth0
…
[prompt]#cat ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.1.77
NETMASK=255.255.255.0
NETWORK=192.168.1.0
BROADCAST=192.168.1.255
ONBOOT=yes
[prompt]#
Recognizing a NIC
/etc/modules.conf
alias eth0 ne2k-pci
alias eth1 3c5x9
options ne2k-pci irq=5
•Forces the boot programs to examine additional
“modules” for support in recognizing devices.
•Modules do other things and generally add
functionality to the kernel.
•Odd format, but says to probe for a device using the
ne2000 probe and name it eth0.
•Lets you control naming and also deal with two cards with
identical type (not plug and play)
•Lets you add other info to help the probe software detect
the device (specifying interrupt and i/o settings)
Other issues in recognizing
• Two cards of the same type are problematic
if using older ISA cards
– Most plug and play work fine
– Is same and older
• May need to use separate software to set I/O
• And to set INTERRUPT
• Then use modules.conf to convey setting to boot.
• Look online for details for setting modules
for specific network card types.
Restarting the network
/
etc
rc.d
init.d
network
…
This is a script used during the boot process to
start up the network.
Don’t change it!
Restart the network by
1. cding to the /etc/rc.d/init.d
directory
2. ./network restart
3. /sbin/service network restart
ping
•Don’t forget to use ping to test connectivity
•Use the lights to be sure interfaces are connected
•Use ifconfig to track the progress of communications
through each interface
•“inch” your way out (pinging) if outside connection fails
•Be sure to configure forwarding on your router in the
/etc/sysconfig/network file
static routes
• Used to add routes not obvious (most)
• Almost anything other than default gateway
• file is /etc/sysconfig/static-routes
• Example configuration line
any net 137.155.17.0 netmask 255.255.255.0 gw 137.155.15.4
• See /etc/init.d/network script on next page
– Shows file being read
– Shows how the file adds static routes
/etc/init.d/network snapshot
# Add non interface-specific static-routes.
if [ -f /etc/sysconfig/static-routes ]; then
grep "^any" /etc/sysconfig/static-routes | while
read ignore args ; do
/sbin/route add -$args
done
fi
First line – names the file being read
Second line – shows the file being filtered to look for lines
beginning with “any”
Third line – shows how to build the line on the file and how it as
used with the route command