Route /
Adding a route to hostname.if
Sometimes, it may be necessary to add a default gateway that is not on your subnet.
Suppose for example we have been assigned the following networking values:
- IPv4 address: 198.51.100.2
- IPv4 default gateway: 198.51.100.1
- IPv6 address: 2001:db8:2::/48
- IPv6 default gateway: 2001:db8:1::1
The IPv6 default gateway we are given (2001:db8:1::1) is not part of our IPv6 subnet 2001:db8:2::/48. For this reason, we need to manually add routes in our hostname.if configuration files:
# cat /etc/hostname.vio0 inet 198.51.100.2 0xffffff00 inet6 2001:db8:2::1 48 !route add -inet6 2001:db8:1::1 -cloning -link -iface vio0 !route add -inet6 default 2001:db8:1::1 # cat /etc/mygate 198.51.100.1 2001:db8:1::1
Note the two route lines:
!route add -inet6 2001:db8:1::1 -cloning -link -iface vio0 !route add -inet6 default 2001:db8:1::1
The first adds a route to 2001:db8:1::1 using interface vio0. It marks this route as cloning (a new route is generated upon use). The second command says that the default route for IPv6 packets will be 2001:db8:1::1.