Linux network ip + routes

Date: 2017-12-04
# use variable for device
dev=enp2s0

# enable device
ip link set dev $dev up
# disable device
ip link set dev $dev down
# show device status
ip link show $dev

# ipv4:
# add an ip address to an device
ip addr add 10.0.0.2 dev $dev
# route network through device
ip route add 10.0.0.0/24 dev $dev
# add default route for network
ip route add default via 10.0.0.1
# show device address info
ip addr show $dev
# clear all device settings
ip addr flush dev $dev

# same way for ipv6
ip -6 addr show $dev
ip -6 addr flush dev $dev
# ipv6:
ip -6 addr add fc00::2 dev $dev
ip -6 route add fc00::0/64 dev $dev
ip -6 route add default via fc00::1

# to add a metric
ip -6 route add default via fc00::1 metric 200
9520cookie-checkLinux network ip + routes