How to create a dummy interface on a machine with mulitple NIC?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 5.4

Issue

  • How to create a dummy interface on a machine with mulitple NIC?

Resolution

Note: Dummy interfaces do not use any physical NIC card from the system by default. If Physical interface is to be used as a dummy, it needs to be alias first. Information about this can be found in the following document: How to make alias TCP/IP addresses to a network card (NIC)?

To create a dummy interface:

# modprobe dummy
# ifconfig dummy0 1.2.3.4 netmask 255.0.0.0

Please note that dummy0 should have a static ip-address (to avoid routing problems). How to achieve this:

  1. Enable routing:

    # echo 1 > /proc/sys/net/ipv4/ip_forward
    # sysctl -w net.ipv4.conf.eth0.forwarding = 1
    
  2. Write an iptables rule to forward/accept all the network I/O from dummy0 [ip-addrs] to eth2 [ip-addrs] (something similar to the following):

    # iptables -t nat -I PREROUTING -s 192.168.1.10 -d 192.168.1.20 -j DNAT --to-destination 10.101.100.30
    

    In this example, dummy0 can be bound to eth2(10.101.100.30).

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments