# Linux Routing

##### Routing

View routes

ip route

```shell
ip route
```

Adding a route

```shell
ip addr add 192.168.1.100/24 dev eth0
```

Add a gateway

```shell
ip route add default via 192.168.1.1 dev eth0
```

Add a route of a subnet to a gateway

```
ip route add 10.1.2.0/24 via 10.1.2.1 dev eth0
```

null route (blackhole)

```shell
ip route add blackhole 10.1.2.130 # For an IP
ip route add blackhole 10.1.2.10/24 # For a subnet
ip route del blackhole 10.1.2.130 # Remove from blackhole
```

null route an ip list

```shell
for string in $(cat ips.txt); do ip route add blackhole $string; done
```