Monday, July 27, 2020

Fedora : Assigning static IP address and static route

Enable the network interface
ip link set ens224 up

Assign IP address to the interface
ip address add 172.6.128.8/24 dev ens224


Check IP address is assigned
ip addr show dev ens224


Add static route
ip route add 172.0.0.0/8 via 172.6.128.254 dev ens224


Check route
ip -4 route show

Sample:
[root@localhost ~]# ip link set ens224 up
[root@localhost ~]# ip address add 172.6.128.8/24 dev ens224
[root@localhost ~]# ip addr show dev ens224
3: ens224: mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:50:56:b9:01:a7 brd ff:ff:ff:ff:ff:ff
    altname enp19s0
    inet 172.6.128.8/24 scope global ens224
       valid_lft forever preferred_lft forever
[root@localhost ~]# ip route add 172.0.0.0/8 via 172.6.128.254 dev ens224
[root@localhost ~]# 

[root@localhost ~]# ip -4 route show
default via 100.104.78.254 dev ens192 proto static metric 100
100.104.78.0/24 dev ens192 proto kernel scope link src 100.104.78.195 metric 100
172.0.0.0/8 via 172.6.128.254 dev ens224
172.6.128.0/24 dev ens224 proto kernel scope link src 172.6.128.8
[root@localhost ~]#

No comments: