1. 程式人生 > >伺服器ip配置 & 策略路由配置

伺服器ip配置 & 策略路由配置

新增路由命令:(臨時) ip route add 172.17.0.0/20 via 172.17.0.1 dev em2 ip route add 192.168.13.0/24 via 192.168.1.254 dev eth0 刪除路由: ip route del 192.168.13.0/24 #!/system/bin/sh echo "################ sleep to wait net done! 10 seconds!" sleep 10 echo "start add route" busybox route add -net 192.168.12.0/24 gw 192.168.1.254 #!/system/bin/sh sleep 10 busybox route add -net default gw 192.168.1.254 永久靜態路由需要寫到 /etc/sysconfig/network-scripts/route-interface 檔案中,比如新增兩條靜態路由: [[email protected] ~]# vi /etc/sysconfig/network-scripts/route-enp0s3 10.15.150.0/24 via 192.168.150.253 dev enp0s3 10.25.250.0/24 via 192.168.150.253 dev enp0s3 新增完畢後重啟網路服務生效 service  network restart centos7配置伺服器網路: /etc/sysconfig/network-scirpts/ifcfg-em1 參考範例 =====動態ip========================================================
[[email protected]_1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eno16777984 TYPE=Ethernet BOOTPROTO=dhcp DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_PEERDNS=yes IPV6_PEERROUTES=yes IPV6_FAILURE_FATAL=no NAME=eno16777984 UUID=fb5a7f96-ec24-4663-b852-0df698fa76e5 DEVICE=eno16777984 ONBOOT=no =====靜態ip========================================================= [
[email protected]
network-scripts]# cat ifcfg-eno16777984 TYPE=Ethernet BOOTPROTO=static IPADDR=192.168.1.191 NETMASK=255.255.255.0 GATEWAY=192.168.1.254 NM_CONTROLLED=no DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_PEERDNS=yes IPV6_PEERROUTES=yes IPV6_FAILURE_FATAL=no NAME=eno16777984
UUID=3e6ca510-7e48-48fb-a55a-3d9bb035cd46 DEVICE=eno16777984 ONBOOT=yes ZONE=public