Software used
- Red Hat 9 (Shrike) Get RH9
Commands used
ifconfig
route
Configuration files used
/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/resolv.conf
Step 1 - Configure IP Address, Mask and Gateway
Example: Set 172.30.10.101/24 on eth0. Note that /24 is shorthand for specifying a network mask of 255.255.255.0, then set the default gateway to be 172.30.10.1
Method I - Temporary settings (lasts till next restart)
[root@frida root]# ifconfig eth0 172.30.10.101 netmask 255.255.255.0 broadcast 172.30.10.255 [root@frida root]# route add default gw 172.30.10.1
Method II - Permanent settings
[root@frida root]# cat /etc/sysconfig/network NETWORKING=yes HOSTNAME=frida.localdomain GATEWAY=172.30.10.1 [root@frida root]#
[root@frida root]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 BOOTPROTO=static BROADCAST=172.30.10.255 IPADDR=172.30.10.101 NETMASK=255.255.255.0 ONBOOT=yes [root@frida root]#
[root@frida root]# service network restart Shutting down interface eth0: [ OK ] Shutting down loopback interface: [ OK ] Setting network parameters: [ OK ] Bringing up loopback interface: [ OK ] Bringing up interface eth0: [ OK ] [root@frida root]#
Step 2 - Configure DNS server
echo “nameserver 207.62.187.54” > /etc/resolv.conf
Step 3 - Verify settings
Show interfaces and routing table
[root@frida root]# ifconfig eth0 Link encap:Ethernet HWaddr 00:0C:29:7E:C3:EC inet addr:172.30.10.101 Bcast:172.30.10.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1586 errors:0 dropped:0 overruns:0 frame:0 TX packets:1264 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100 RX bytes:181119 (176.8 Kb) TX bytes:193645 (189.1 Kb) Interrupt:9 Base address:0x10a4 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:454110 errors:0 dropped:0 overruns:0 frame:0 TX packets:454110 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:31015690 (29.5 Mb) TX bytes:31015690 (29.5 Mb) [root@frida root]#
[root@frida root]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 172.30.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0 127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo 0.0.0.0 172.30.10.1 0.0.0.0 UG 0 0 0 eth0 [root@frida root]#
Ping the gateway (tests IP and mask settings)
[root@frida root]# ping 172.30.10.1 PING 172.30.10.1 (172.30.10.1) 56(84) bytes of data. 64 bytes from 172.30.10.1: icmp_seq=1 ttl=64 time=0.318 ms 64 bytes from 172.30.10.1: icmp_seq=2 ttl=64 time=0.320 ms 64 bytes from 172.30.10.1: icmp_seq=3 ttl=64 time=0.638 ms --- 172.30.10.1 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2013ms rtt min/avg/max/mdev = 0.318/0.425/0.638/0.151 ms [root@frida root]#
Ping google (tests DNS and default gateway settings)
[root@frida root]# ping google.com PING google.com (64.233.167.99) 56(84) bytes of data. 64 bytes from py-in-f99.google.com (64.233.167.99): icmp_seq=1 ttl=246 time=76.5 ms 64 bytes from py-in-f99.google.com (64.233.167.99): icmp_seq=3 ttl=246 time=75.8 ms 64 bytes from py-in-f99.google.com (64.233.167.99): icmp_seq=4 ttl=246 time=75.9 ms --- google.com ping statistics --- 4 packets transmitted, 3 received, 25% packet loss, time 3051ms rtt min/avg/max/mdev = 75.897/76.106/76.507/0.426 ms [root@frida root]#