$ vim /etc/sysconfig/network-scripts/route-eth1 ADDRESS0=192.168.0.0 NETMASK0=255.255.255.0 GATEWAY0=192.168.0.1
0表示第一条静态路由。配置完成后重启网络:systemctl restart network
ipv6
1 2
ip -6 route add default via fe80::290:4cff:fe88:8888 dev eth1 # 配置默认网关 ip -6 route add 2001:db8:3333::/64 via fe80::ca3a:35ff:fe09:efa1 dev eth1 # 添加目的网络为2001:db8:3333::/64,下一跳网关为fe80::ca3a:35ff:fe09:efa1的静态路由
查看路由表
1 2 3 4
route -n route -4 -n route -6 -n ip -6 route show default # 查看默认路由网关
# 添加IPv4地址 ifconfig eth1 192.168.1.200 netmask 255.255.255.0 ip addr add 192.168.1.200/24 dev eth1 # 添加IPv6地址 ip -6 addr add 2001:db8:1111::20 dev eth1 # 删除IPv6地址 ip -6 addr del 2001:db8:1111::20 dev eth1 ip addr del 192.168.1.200/24 dev eth1