Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19
Two IP addresses on one nic
Results 1 to 10 of 10

Thread: Two IP addresses on one nic

  1. #1
    kyiu
    Guest

    Two IP addresses on one nic

    Can I assign two ip addresses (in a different subnet) on a single NIC?

    Ken

  2. #2
    JimH
    Guest

    Re:Two IP addresses on one nic

    OK, forget my brief lapse of stupidity earlier. : I just needed someone to remind me I already knew how to do this. :P

    Example:

    ifconfig eth0:0 192.168.10.1 netmask 255.255.255.0 up
    route add -net 192.168.10.0 netmask 255.255.255.0 eth0:0

    If you want it permanent, just copy your current /etc/sysconfig/network-scripts/ifcfg-eth0 to /etc/sysconfig/network-scripts/ifcfg-eth0:0 and edit the setting as required.

    Jim H

  3. #3
    kyiu
    Guest

    Re:Two IP addresses on one nic

    That's great. Thanks! The sample you gave have the IP addresses in the same subnet. Is it a must? Can they be any different addresses?

    Ken

  4. #4
    JimH
    Guest

    Re:Two IP addresses on one nic

    I was taking into account that you already had eth0 configured for one ip.

    Example:

    Current settings for eth0 were:

    ifconfig eth0 192.168.1.1 netmask 255.255.255.0 up
    route add -net 192.168.1.0 netmask 255.255.255.0 eth0

    I was just adding the other ip before with these.

    ifconfig eth0:0 192.168.10.1 netmask 255.255.255.0 up
    route add -net 192.168.10.0 netmask 255.255.255.0 eth0:0

    Someone else who's knows alot more then I do, sent a couple e-mails on this. I will post them later. I Have to go out right now.

    Jim H

  5. #5
    JimH
    Guest

    Re:Two IP addresses on one nic

    <-- begin forwarded message -->

    Linux is totally flexable with how networking can be set up, and
    there is usually more than one way to do it. What you want to do is
    trivial.

    Ok, say you have eth0 with an address of 192.168.1.1/24, then the
    kernel will automatically add a route to the 192.168.1.0/24 subnet.
    The same thing happens if you add a second address to that
    interface...

    /sbin/ip address add 10.10.10.10/24 dev eth0 label eth0:0

    You don't actually need to use the "label" parameter, but that
    will do that same as creating an aliased interface:

    /sbin/ifconfig eth0:0 10.10.10.10 netmask 255.255.255.0

    Giving alias names to interface IPs isn't necessary, but it does
    allow /sbin/ifconfig to see them. ie, you can add as many IPs to
    an interface as you like with /sbin/ip.

    But ifconfig is the old, obselete networking tool. Use /sbin/ip
    instead -- it does a LOT more than ifconfig.

    Ok, if you want to add new routes...

    /sbin/ip route add 172.16.18.0/24 via 192.168.1.12 dev eth0

    Or, doing it the old way with /sbin/route...

    /sbin/route add -net 172.16.18.0 netmask 255.255.255.0 gw 192.168.1.12 eth0

    That sets things up manually. But you want to set things up so that
    this is preserved through reboots into that same configuration.

    There's a file you can create to do this: /etc/sysconfig/static-routes

    When the networking for an interface is brought up (eg, with
    "ifup"), one of the scripts that is run is
    /etc/sysconfig/network-scripts/ifup-routes

    Read this script, by default it runs /sbin/route using wnatever you
    have set up in the static-routes file. The syntax of that file is
    easy to figure out.

    However, it uses /sbin/route, yuk. I have modified ifup-routes like
    this:

    [ ... ]
    DEVICE=$1
    #note the trailing space in the grep gets rid of aliases
    grep "^$DEVICE " /etc/sysconfig/static-routes &#124; while read device args; do
    # /sbin/route add -$args $device
    /sbin/ip route replace $args
    done
    grep "^any " /etc/sysconfig/static-routes &#124; while read ignore args ; do
    # /sbin/route add -$args
    /sbin/ip route replace $args
    done

    This demands that static-routes is in a format that /sbin/ip
    understands (not /sbin/route), but there is a huge advantage with
    flexability if you do it like that. (I'm not sure why redhat
    haven't adapdted this to use /sbin/ip here, they are using it just
    about everywhere else instead of ifconfig).

    Using the examples above, this is what would go into static-routes:

    eth0 172.16.18.0/24 via 192.168.1.12 dev eth0

    Add as many new routes as you like.

    If you haven't discovered the /sbin/ip command, I strongly urge you
    to get to know it well. The advanced routing howto gives many
    examples of its use.

    Cheers
    Tony

    ---*#*=-=*#*=-=*#*=-=*#*=-=*#*=-=*#*=---
    Tony Nugent <Tony@e-mail left out>
    LinuxWorks - Gold Coast Qld Australia

    <-- end forwarded message -->


  6. #6
    JimH
    Guest

    Re:Two IP addresses on one nic

    <-- begin forwarded message -->

    It is a VERY powerful command - it is the NEW interface into the
    totally re-writted networking (netlink) code introduced into the
    2.4.x kernels.

    For example, you can do route-NAT with it (different, and currently
    inccmpatable with netfilter/ipchains), create multiple routing
    tables, do source routing and so on.

    An example:

    ip address add 192.168.1.1/14 dev eth0
    ip address add 192.168.2.1/14 dev eth0 # example, see below
    ip address add 172.16.16.1/14 dev eth1
    ip route add 192.168.0.0/16 dev eth0 src 192.168.1.1
    ip route add default via eth0 src 172.16.16.1

    What that does is make the router talk to all hosts on eth1 via a
    source address of that on eth0.

    Why would you want to do that? Well, we have a network with lots of
    routers on private IP addresses on all the internet gateway interfaces,
    and one "public" ip on one of the other interfaces. (There are
    reasons for doing it like that).

    In order to make the routers talk to the world, eg, with icmp
    messages, with an IP address that can be reached (eg, with ping and
    traceroutes), the gateway interface is configured to make the source
    address of these packets appear to come from the IP on another
    interface, not necessarily the IP on the actual interface that the
    packet leaves from.

    (Yes, I know, 172.16.0.0/12 are private IPs, I'm just demonstrating
    how it works).

    It really is very powerful.

    Ok, do this:

    - set up some src routing something like that example above (doesn't
    need to be real, just test it. "insmod dummy" and use dummy0 as a
    virtual interface if you like).

    - look at the IP configuration with /sbin/ifconfig
    - it will NOT show the 192.168.2.1/24 interface, ifconfig has big
    limitations.

    - look at the routing table with /sbin/route or /bin/netstat -nr
    - once again, neither of these commands are smart enough to know
    about src routing.

    - now look at the IP configuration and routing table with /sbin/ip
    /sbin/ip address (or "ip a", or "ip -o a &#124; grep inet")
    /sbin/ip route (or "ip r")

    - and NOW you will see the true state of your network configuration

    This only touches on what it can do.

    Check out "ip rule" -- it will blow your mind... with it you can set
    up routing decisions according to properties such as source address,
    TOS and so on. For example:

    ip rule add from 172.16.17.0/24 dev eth0 table 8
    ip route add table 8 default via 192.168.2.17 dev eth0

    This forces all traffic from 172.16.17.0/24 to be sent to another
    router at 192.168.2.17

    Way cool, no? It gets better... set up iptables (or ipchains) to
    fwmark particular packets, eg, port 25 (email) or port 80 (web).
    Now you can create ip policy rules to route according to the fwmark!

    Totally amazing stuff. Linux is the most capable router in
    existance, no other OS has this sort of capability.

    Cheers
    Tony

    ---*#*=-=*#*=-=*#*=-=*#*=-=*#*=-=*#*=---
    Tony Nugent <Tony@e-mail left out>
    LinuxWorks - Gold Coast Qld Australia

    <-- end forwarded message -->

    Maybe I can talk him into doing a Linux routing OMP for the site. ;D

    Jim H

  7. #7

    Re:Two IP addresses on one nic

    Quote Originally Posted by JimH
    Maybe I can talk him into doing a Linux routing OMP for the site. ;D

    Jim H
    If you do I'll give ya a big sloppy :-*.................................

    not really, ur not my type! :P

    Aragorn
    If you give a man a fire he'll be warm, if you light the man on fire he'll be warm for life.

  8. #8
    kyiu
    Guest

    Re:Two IP addresses on one nic

    :-* wahoo, you guys are the best. Even although just wanted to create a subnet in a local network. 8) I'm sure this will impress my friend.

    Ken

  9. #9
    kyiu
    Guest

    Re:Two IP addresses on one nic

    I did it. It works. Now, the can have a 2nd subnet on my LAN. One thing I found on the RH7.2, the network-config in the GUI configuration, it doesn't allow me to setup the 2nd IP address. It gave me error, it wouldn't let me close the window to complete the set up. I had to use the linuxconf to get the job done. I checked with my home linux box (RH7.1) the network-configure there do allow me to configure the multi IP, no problem.

    I'm beginning to wonder if RH7.2 is a very buggy version, is it?

    Ken

  10. #10
    JimH
    Guest

    Re:Two IP addresses on one nic

    I don't think 7.2 is excessively buggy compared to other releases. I don't use NEAT, the GUI network config, possible their could be a bug in it.

    Jim H

Similar Threads

  1. Banning IP Addresses Permanently
    By beezlebubsbum in forum Linux - Hardware, Networking & Security
    Replies: 14
    Last Post: 01-19-2010, 01:46 AM
  2. Trace IP Addresses
    By Davio in forum General Chat
    Replies: 2
    Last Post: 12-12-2007, 11:58 PM
  3. Router for a lan with public ip addresses
    By maybemedic in forum Linux - Hardware, Networking & Security
    Replies: 3
    Last Post: 01-14-2007, 09:00 AM
  4. Renew and Release IP Addresses
    By regix in forum Windows - General Topics
    Replies: 0
    Last Post: 01-30-2005, 12:50 AM
  5. ljr email addresses?
    By ndogg in forum Announcements and Suggestions
    Replies: 1
    Last Post: 05-14-2002, 10:56 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •