# Dummy Interfaces in VyOS

> Dummy interfaces in VyOS - virtual loopback adapters for testing routing, blackhole routes, and service IP addresses on network devices

Source: https://opennix.org/en/docs/vyos/interfaces/vyos-dummy/



Dummy interfaces in VyOS are virtual interfaces that are always in the "up" state and are not tied to any physical hardware. They are used for a variety of technical tasks, including testing, routing, and serving as stable endpoints.

## Overview

Dummy interfaces are used for:

- **Testing**: Simulating interfaces without physical hardware
- **Stable endpoint**: An always-available IP for routing protocols
- **Router ID**: A stable identifier for OSPF/BGP (an alternative to loopback)
- **Blackhole routing**: Dropping traffic through a dummy
- **Source address**: A stable source IP for outbound connections
- **Development**: Developing and debugging network configurations

### Dummy vs Loopback

| Characteristic | Dummy | Loopback |
|----------------|-------|----------|
| State | Always up | Always up |
| Use case | Testing, routing, blackhole | Router ID, management |
| Count | Multiple (dum0, dum1, ...) | One (lo) |
| Standardization | Linux-specific | Universal (RFC 1122) |
| Recommendation | For temporary tasks | For production router ID |

**When to use Dummy**:
- Testing configurations
- Temporary endpoints
- Blackhole routing
- Multiple virtual interfaces

**When to use Loopback**:
- Router ID for OSPF/BGP
- Management address
- Production stable endpoint

## Basic Configuration

### Creating a Dummy Interface

```bash
# Create a dummy interface with an IP address
set interfaces dummy dum0 address 192.168.255.1/32

commit
save
```

### Multiple Dummy Interfaces

```bash
# First dummy
set interfaces dummy dum0 address 192.168.255.1/32

# Second dummy
set interfaces dummy dum1 address 192.168.255.2/32

# Third dummy with a description
set interfaces dummy dum2 address 192.168.255.3/32
set interfaces dummy dum2 description 'Test interface for BGP'

commit
save
```

### Multiple IP Addresses on a Dummy

```bash
# Dummy with several addresses
set interfaces dummy dum0 address 192.168.255.1/32
set interfaces dummy dum0 address 10.255.255.1/32
set interfaces dummy dum0 address 172.16.255.1/32

commit
save
```

### IPv6 on a Dummy

```bash
# IPv4 + IPv6
set interfaces dummy dum0 address 192.168.255.1/32
set interfaces dummy dum0 address 2001:db8::1/128

commit
save
```

## Advanced Configuration

### Dummy for Router ID (OSPF/BGP)

```bash
# Dummy interface for the Router ID
set interfaces dummy dum0 address 10.255.255.1/32
set interfaces dummy dum0 description 'Router ID for OSPF/BGP'

# OSPF uses this address as its Router ID
set protocols ospf parameters router-id 10.255.255.1
set protocols ospf area 0 network 10.255.255.1/32

# BGP uses it as well
set protocols bgp local-as 65000
set protocols bgp parameters router-id 10.255.255.1

# Advertise into OSPF (optional)
set protocols ospf area 0 network 10.255.255.1/32

commit
save
```

### Blackhole Routing with a Dummy

Dummy interfaces can be used for blackhole routing - dropping unwanted traffic.

```bash
# Create a dummy for blackhole
set interfaces dummy dum0 address 192.0.2.1/32
set interfaces dummy dum0 description 'Blackhole interface'

# Routes pointing to the dummy (traffic will be dropped)
set protocols static route 10.0.0.0/8 interface dum0
set protocols static route 172.16.0.0/12 interface dum0
set protocols static route 192.168.0.0/16 interface dum0

commit
save
```

Now all traffic to these subnets will be dropped (useful for DDoS protection or for routing bogon prefixes).

### Source Address for Outbound Connections

```bash
# Dummy for a stable source address
set interfaces dummy dum0 address 203.0.113.100/32
set interfaces dummy dum0 description 'Stable source for outgoing connections'

# BGP uses the dummy as its source
set protocols bgp neighbor 198.51.100.1 remote-as 65001
set protocols bgp neighbor 198.51.100.1 update-source dum0

# Static route to make the dummy address reachable
set protocols ospf area 0 network 203.0.113.100/32

commit
save
```

### Dummy for NAT Testing

```bash
# The dummy simulates an internal network
set interfaces dummy dum0 address 192.168.10.1/24
set interfaces dummy dum0 description 'Test internal network'

# NAT for the dummy interface
set nat source rule 100 outbound-interface name eth0
set nat source rule 100 source address 192.168.10.0/24
set nat source rule 100 translation address masquerade

commit
save
```

### Dummy for Policy-Based Routing

```bash
# Dummy for PBR testing
set interfaces dummy dum0 address 192.168.100.1/24

# Policy route for traffic to the dummy
set policy route TEST-ROUTE rule 10 destination address 192.168.100.0/24
set policy route TEST-ROUTE rule 10 set table 100

# Apply to the interface
set interfaces ethernet eth1 policy route TEST-ROUTE

commit
save
```

## Configuration Examples

### Example 1: Router ID for OSPF/BGP

```bash
# Dummy interface for a stable Router ID
set interfaces dummy dum0 address 10.255.255.1/32
set interfaces dummy dum0 description 'Router ID'

# OSPF configuration
set protocols ospf parameters router-id 10.255.255.1
set protocols ospf area 0 network 10.0.0.0/24
set protocols ospf area 0 network 10.255.255.1/32

# BGP configuration
set protocols bgp local-as 65000
set protocols bgp parameters router-id 10.255.255.1
set protocols bgp neighbor 10.0.0.2 remote-as 65001
set protocols bgp neighbor 10.0.0.2 update-source dum0

commit
save
```

### Example 2: Blackhole Routing for Bogon Prefixes

```bash
# Dummy for blackhole
set interfaces dummy dum0 address 192.0.2.1/32
set interfaces dummy dum0 description 'Blackhole for bogon prefixes'

# RFC 1918 private addresses (if they should not be routed to the internet)
set protocols static route 10.0.0.0/8 blackhole distance 254
set protocols static route 172.16.0.0/12 blackhole distance 254
set protocols static route 192.168.0.0/16 blackhole distance 254

# Other bogon prefixes
set protocols static route 0.0.0.0/8 blackhole distance 254
set protocols static route 127.0.0.0/8 blackhole distance 254
set protocols static route 169.254.0.0/16 blackhole distance 254
set protocols static route 224.0.0.0/4 blackhole distance 254
set protocols static route 240.0.0.0/4 blackhole distance 254

commit
save
```

**Note**: `blackhole` is more efficient than a route through a dummy, but a dummy can be used for specific cases.

### Example 3: Test Environment with Multiple Dummies

```bash
# Simulating multiple networks for testing
set interfaces dummy dum0 address 192.168.10.1/24
set interfaces dummy dum0 description 'Test network VLAN 10'

set interfaces dummy dum1 address 192.168.20.1/24
set interfaces dummy dum1 description 'Test network VLAN 20'

set interfaces dummy dum2 address 192.168.30.1/24
set interfaces dummy dum2 description 'Test network VLAN 30'

# OSPF advertises all test networks
set protocols ospf area 0 network 192.168.10.0/24
set protocols ospf area 0 network 192.168.20.0/24
set protocols ospf area 0 network 192.168.30.0/24

commit
save
```

### Example 4: Stable Source for BGP Peering

```bash
# Dummy for BGP peering
set interfaces dummy dum0 address 10.255.0.1/32
set interfaces dummy dum0 description 'BGP peering endpoint'

# Advertise the dummy into the IGP (OSPF)
set protocols ospf area 0 network 10.255.0.1/32

# BGP neighbors use the dummy as update-source
set protocols bgp local-as 65000
set protocols bgp parameters router-id 10.255.0.1

set protocols bgp neighbor 10.255.0.2 remote-as 65000
set protocols bgp neighbor 10.255.0.2 update-source dum0

set protocols bgp neighbor 10.255.0.3 remote-as 65000
set protocols bgp neighbor 10.255.0.3 update-source dum0

commit
save
```

Now BGP peering uses a stable IP that does not depend on the state of the physical interfaces.

### Example 5: Dummy for VRF Testing

```bash
# VRF with a dummy interface
set vrf name TEST-VRF table 100

# Dummy in the VRF
set interfaces dummy dum0 vrf TEST-VRF
set interfaces dummy dum0 address 192.168.100.1/24
set interfaces dummy dum0 description 'Test interface in VRF'

# Static route in the VRF
set protocols vrf TEST-VRF static route 192.168.200.0/24 next-hop 192.168.100.254

commit
save
```

### Example 6: Anycast Address on a Dummy

```bash
# Anycast address for a service (for example, DNS)
set interfaces dummy dum0 address 10.10.10.10/32
set interfaces dummy dum0 description 'Anycast DNS service'

# Advertise into OSPF
set protocols ospf area 0 network 10.10.10.10/32

# Or into BGP
set protocols bgp address-family ipv4-unicast network 10.10.10.10/32

commit
save
```

Now all routers with an identical configuration advertise 10.10.10.10, and clients will be directed to the nearest router.

## Monitoring and Diagnostics

### Viewing Dummy Interfaces

```bash
# Show all dummy interfaces
show interfaces dummy

# Detailed information
show interfaces dummy dum0

# Statistics (usually zero for a dummy)
show interfaces dummy dum0 statistics
```

### Checking the State

```bash
# The dummy should always be up
show interfaces dummy dum0

# Output:
# dum0: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500
#     inet 192.168.255.1/32
```

### Checking Routing

```bash
# Check that the dummy address is in the routing table
show ip route

# Ping the dummy address (from the router itself)
ping 192.168.255.1

# Traceroute (to verify routing)
traceroute 192.168.255.1
```

### Checking in Routing Protocols

```bash
# OSPF - the dummy in the database
show ip ospf database

# BGP - the dummy is advertised
show ip bgp
show ip bgp 192.168.255.1/32

# Neighbors use the dummy
show ip bgp neighbors
```

### Logging

```bash
# Interface logs
show log | match dum0

# Kernel messages
dmesg | grep dum
```

## Troubleshooting

### Problem: The Dummy Interface Is Not Created

**Diagnostics**:

```bash
# Check the configuration
show configuration interfaces dummy

# Check the state
show interfaces dummy
```

**Solution**:

```bash
# Make sure the configuration is applied
commit
save

# Check the kernel module (usually loaded by default)
lsmod | grep dummy

# If it is not - load it (usually not required)
sudo modprobe dummy
```

### Problem: The Dummy Address Is Unreachable from Other Devices

**Cause**: The dummy address is not advertised in a routing protocol.

**Solution**:

```bash
# Add the dummy to OSPF
set protocols ospf area 0 network 192.168.255.1/32

# Or to BGP
set protocols bgp address-family ipv4-unicast network 192.168.255.1/32

# Or a static route on the other routers
set protocols static route 192.168.255.1/32 next-hop 10.0.0.1

commit
save
```

### Problem: BGP Neighbors Do Not Use the Dummy as Source

**Diagnostics**:

```bash
# Check the BGP neighbors
show ip bgp neighbors

# Check the source address in the configuration
show configuration protocols bgp neighbor
```

**Solution**:

```bash
# Explicitly specify update-source
set protocols bgp neighbor 10.0.0.2 update-source dum0

# Make sure the dummy address is reachable through the IGP
set protocols ospf area 0 network 192.168.255.1/32

commit
save
```

### Problem: Blackhole Routing Does Not Work

**Diagnostics**:

```bash
# Check the routes
show ip route 10.0.0.0/8

# Traceroute to verify
traceroute 10.1.1.1
```

**Solution**:

Use `blackhole` instead of a dummy for efficient dropping:

```bash
# Instead of:
# set protocols static route 10.0.0.0/8 interface dum0

# Use:
set protocols static route 10.0.0.0/8 blackhole distance 254

commit
save
```

### Problem: A Dummy in a VRF Does Not Work

**Diagnostics**:

```bash
# Check the VRF
show vrf TEST-VRF

# Check the interface in the VRF
show interfaces dummy dum0
```

**Solution**:

```bash
# Make sure the dummy is bound to the VRF
set interfaces dummy dum0 vrf TEST-VRF

# Check routing in the VRF
show ip route vrf TEST-VRF

commit
save
```

## Best Practices

### 1. Use Loopback for the Production Router ID

For the production router ID, loopback is preferable:

```bash
# Better:
set interfaces loopback lo address 10.255.255.1/32
set protocols ospf parameters router-id 10.255.255.1

# Than:
set interfaces dummy dum0 address 10.255.255.1/32
set protocols ospf parameters router-id 10.255.255.1
```

### 2. Dummy for Temporary/Test Tasks

Use a dummy for testing and temporary configurations:

```bash
set interfaces dummy dum0 address 192.168.100.1/24
set interfaces dummy dum0 description 'TEST - Remove after testing'
```

### 3. Describe the Purpose

Always add a description:

```bash
set interfaces dummy dum0 description 'BGP peering endpoint'
set interfaces dummy dum1 description 'Test network simulation'
```

### 4. Use /32 for Endpoint Addresses

For Router IDs and stable endpoints, use /32:

```bash
set interfaces dummy dum0 address 10.255.0.1/32
```

### 5. Blackhole via the blackhole Keyword

For blackhole routing, use the built-in blackhole:

```bash
# Preferred:
set protocols static route 10.0.0.0/8 blackhole distance 254

# Instead of:
set protocols static route 10.0.0.0/8 interface dum0
```

### 6. Document Test Dummies

Document all dummy interfaces:

```bash
# /config/dummy-interfaces.txt
# dum0: BGP peering endpoint (10.255.0.1/32)
# dum1: Test VLAN 10 simulation (192.168.10.1/24)
# dum2: Anycast DNS service (10.10.10.10/32)
```

### 7. Remove Unused Dummies

Clean up old dummies from the configuration:

```bash
# Remove an unused dummy
delete interfaces dummy dum5
commit
save
```

### 8. Use Consistent Naming

Use a consistent naming scheme:

```bash
# dum0 - Router ID / BGP endpoint
# dum1-dum9 - Test networks
# dum10+ - Special purposes
```

### 9. Monitor Dummy Usage

Track which dummies are in use:

```bash
show interfaces dummy
show configuration interfaces dummy
```

### 10. Security

For dummies with real IPs, do not forget the firewall:

```bash
set firewall ipv4 name LOCAL_IN rule 100 action accept
set firewall ipv4 name LOCAL_IN rule 100 destination address 192.168.255.1
set firewall ipv4 name LOCAL_IN rule 100 protocol tcp
set firewall ipv4 name LOCAL_IN rule 100 destination port 179  # BGP
```

## Useful Commands

```bash
# Show all dummy interfaces
show interfaces dummy

# Details of a specific dummy
show interfaces dummy dum0

# Configuration
show configuration interfaces dummy

# Create a dummy
set interfaces dummy dum0 address 192.168.255.1/32

# Add a description
set interfaces dummy dum0 description 'My description'

# Delete a dummy
delete interfaces dummy dum0

# Check the state
show interfaces dummy dum0

# Ping the dummy address
ping 192.168.255.1

# Check in the routing table
show ip route 192.168.255.1

# OSPF database
show ip ospf database | match 192.168.255.1

# BGP routes
show ip bgp 192.168.255.1/32

# Kernel interface details
ip addr show dum0

# Logs
show log | match dum
```

## Real-World Use Cases

### Anycast DNS with a Dummy

Several routers advertise the same IP for a DNS service:

**Router 1**:
```bash
set interfaces dummy dum0 address 10.10.10.10/32
set protocols ospf area 0 network 10.10.10.10/32

# The DNS server listens on this IP
# (configure the DNS server separately)
```

**Router 2** (identical configuration):
```bash
set interfaces dummy dum0 address 10.10.10.10/32
set protocols ospf area 0 network 10.10.10.10/32
```

Clients are directed to the nearest router based on the OSPF metric.

### Testing Firewall Rules

```bash
# The dummy simulates the protected network
set interfaces dummy dum0 address 192.168.50.1/24
set interfaces dummy dum0 description 'Firewall test network'

# Firewall rules for the dummy
set firewall ipv4 name DUMMY_IN default-action drop
set firewall ipv4 name DUMMY_IN rule 10 action accept
set firewall ipv4 name DUMMY_IN rule 10 state established
set firewall ipv4 name DUMMY_IN rule 10 state related

set interfaces dummy dum0 firewall in name DUMMY_IN

# Testing from another interface
# ping 192.168.50.1
```

### Development and Debugging

```bash
# Multiple dummies for development
set interfaces dummy dum0 address 172.16.0.1/24
set interfaces dummy dum0 description 'Dev: Frontend network'

set interfaces dummy dum1 address 172.16.1.1/24
set interfaces dummy dum1 description 'Dev: Backend network'

set interfaces dummy dum2 address 172.16.2.1/24
set interfaces dummy dum2 description 'Dev: Database network'

# Now you can test routing between the "networks"
set protocols static route 172.16.1.0/24 next-hop 172.16.0.254
```

## Conclusion

Dummy interfaces in VyOS are a versatile tool for a wide range of tasks, from testing to production routing. They provide stable, always-available interfaces that are not tied to physical hardware.

Key advantages of dummy interfaces:
- Always in the "up" state
- Do not require physical hardware
- Flexible in use (Router ID, BGP endpoint, blackhole, testing)
- Easy to configure
- VRF support

Recommendations:
- Use Loopback for the production Router ID
- Use Dummy for testing and special tasks
- Always add a description
- Document the purpose of each dummy
- Remove unused dummies
- Use /32 for endpoint addresses
- Prefer the blackhole keyword for blackhole routing

Dummy interfaces are a powerful tool in a network engineer's arsenal, providing flexibility and reliability across a variety of scenarios, from development to production environments.

