How to configure a static IP for clients using Linux slackware

AJKConcepts
AJKConcepts used Ask the Experts™
on
We provide T1 access to customers in our building, and one of our clients is requesting 3-5 static IPs.  Our traffic is routed through a server running Linux Slackware (used as a firewall).  There are 6 NIC cards installed on this server, 3 of which can be used to assign static IPs (there is a direct cat5 line from the card to the client).  What do I need to do to configure one of these cards to provide a static IP?  I know that it is eth4 that will be used, but I can't figure out how to access the configuration files and make changes, nor do I know what other steps are necessary (restarting services, etc.).  Any help is appreciated.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2006
Commented:
Hi AJKConcepts,

/sbin/ifconfig eth4 address <IP address> netmask <netmask> up
man ifconfig for details

IP address and other interface related information is commonly stored in  /etc/sysconfig/network-scripts/ifcfg-eth4

Cheers!
sunnycoder

Author

Commented:
how do i assign multiple IPs to a single NIC?  
Top Expert 2006

Commented:
cd /etc/sysconfig/network-scripts

Make a copy of ifcfg-eth4 to ifcfg-eth4:0
cp ifcfg-eth4 ifcfg-eth4:0

Edit ifcfg-eth4:0 and change DEVICE to eth4:0 and change the IPADDR to new IP
use eth0:0 eth0:1

note the colon (:) and digit (0,1) after the eth0 referred to as sub-interfaces

for example

/sbin/ifconfig eth4:0 address <IP address> netmask <netmask> up
/etc/sysconfig/network-scripts/ifcfg-eth4 is the path to the <i>Red Hat</i> bootscripts.

For Slackware, you should probably use the netconfig utility, or you should be able to find the config files for network interfaces at

/etc/rc.d/rc.inet1 (IP and network parameters)
/etc/rc.d/rc.inet2 (Network Services configuration)

This page is from the Slackware book and details exactly what you need to change and how:

http://slackbook.org/html/network-configuration-tcpip.html
I am assuming that the card that has a cable running to a switch for your client has an IP address.  That IP address is in a subnet that you have created for your client.  Depending on the subnet mask that you assigned to that card you will be able to assign a number of IP addresses for nodes on that network.  You can dish them out using DHCP or, in this case, give them 3-5 static IPs for that subnet and then ensure that your DHCP server does not give those out to nodes on the network.  Hope this helps because I interpreted your question differently.

Commented:
Here is my "/etc/network/interfaces" file. Take a look how to assign multiple IP's.

eth0 is the first interface and has 3 IP's 10.52.9.10 , 10.52.9.20 and 10.52.9.21
eth1 is the second interface and has 2 IP's 192.168.8.6 and 192.168.8.16

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
      address 10.52.9.10
      netmask 255.255.252.0
      network 10.52.9.0
      broadcast 10.52.9.255
      gateway 10.52.8.200
      # dns-* options are implemented by the resolvconf package, if installed
      dns-nameservers 10.52.8.1
      dns-search domain.extension

auto eth0:20
iface eth0:20 inet static
        address 10.52.9.20
        netmask 255.255.252.0
        network 10.52.9.0
        broadcast 10.52.9.255
        dns-nameservers 10.52.8.1
        dns-search domain.extension

auto eth0:21
iface eth0:21 inet static
        address 10.52.9.21
      netmask 255.255.252.0
        network 10.52.9.0
        broadcast 10.52.9.255
        dns-nameservers 10.52.8.1
        dns-search domain.extension

auto eth1
iface eth1 inet static
      address 192.168.8.6
      netmask 255.255.255.0
      network 192.168.8.0
      broadcast 192.168.8.255

auto eth1:1
iface eth1:1 inet static
      address 192.168.8.16
      netmask 255.255.255.0
      network 192.168.8.0
      broadcast 192.168.8.255

What are you using on the client end to provide them service?  What is the purpose of configuring a card with multiple IP addresses on the same subnet on the Slackware box?  How are they getting IP's on your network as present?  Is it a DHCP server at this time?
To add a card to /etc/network/interfaces:

auto = declares it to be automatically called up at boot time.

eth4 = device name of the NIC you want to configure

The following are probably self-explanatory;  it's important to note that the only two *required* fields are "address" and "netmask":

address = address you want to assign

netmask = the netmask representing the LAN configuration you are using

network = network prefix for your LAN  (shouldn't be necessary on a standard LAN with a properly configured netmask)

broadcast = broadcast address for your card (qualified same as "network", above)

gateway = address to your LAN's gateway.

What's odd, though, is that /etc/network/interfaces is a *Debian* configuration file -- not Slackware;  in fact, the /etc/network directory shouldn't even exist on a Slackware distribution (for an example, see here:  http://www.linuxforums.org/forum/slackware-linux-help/63049-detecting-network-card.html).  The Slackware configuration file should be as i noted above:  /etc/rc.d/rc.inet1.


Are you sure you're not working with a Debian distribution?  If you're not sure, you should check /proc/version:

$ cat /proc/version
Also, this page describes the differences between the file systems:

http://www.physics.nmt.edu/~rsonnenf/research/LinuxCourse/bigpicture.rs

Scroll down to section IV, "Linux Network Configuration," or something like that.
Anyway, to do what you want is rather simple:

auto iface eth4 inet static
  address <assign the IP address here>
  netmask <255.255.255.0 or 255.255.252.0>
  network <indicate which network the card will participate in:  192.168.8.0 or 10.52.9.0>
  broadcast <indicate which network the card will broadcast on: 192.168.8.255 or 10.52.9.255>
  <dns-nameservers 10.52.8.1, if necessary>
  <dns-search domain.extension, if necessary>

But like i said:  this is a Debian config file, not Slackware.
To restart a Debian system, you simply do this:

/etc/init.d/networking restart

For Slackware, it should be something like this:

$ ifconfig eth4 down
$ /etc/rc.d/rc.inet1 restart

Although I haven't tried it myself, in principle this alone should work:

$ /etc/rc.d/rc.inet1 restart

If you're not sure, you can check it like this:

$ /etc/rc.d/rc.inet1 stop      // Should stop all interfaces, except for maybe the loopback, which you shouldn't need to stop
$ ifconfig -a                        // Will return the status of all interfaces.
$ /etc/rc.d/rc.inet1 start     // Will start up all interfaces
$ ifconfig -a
Finally, there are some more tweaks you might need, depending on the distribution you're using.  So we really need to get that settled first.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial