Linux/ip: Difference between revisions
< Linux
(3 intermediate revisions by the same user not shown) | |||
Line 12: | Line 12: | ||
sudo ip addr del 192.168.1.2/24 dev eth0; | sudo ip addr del 192.168.1.2/24 dev eth0; | ||
== | == Bring interface online == | ||
ip link set dev <interface> up | ip link set dev <interface> up | ||
ip link set dev <interface> down | ip link set dev <interface> down | ||
== Interface Alias == | |||
Change name: (change enp39s0 to eth0) | |||
ip link set enp39s0 name eth0 | |||
Add Alias: (add eth0 to enp39s0) | |||
ip link property add dev enp39s0 altname eth0 | |||
ip link property del dev enp39s0 altname eth0 | |||
== Add Temporary IP to Interface == | |||
ip a add 192.168.178.2/24 dev eth0 | |||
== Route == | |||
Print routes: | |||
ip route | |||
Add default route: | |||
sudo ip route add default via 192.168.1.1 dev eth0; | |||
Add route: | |||
sudo ip route add 172.10.1.0/24 via 192.168.1.1 dev eth0; | |||
== keywords == | == keywords == |
Latest revision as of 20:48, 13 December 2024
Install ip tool
apt install iproute2
Add static IP
sudo ip addr add 192.168.1.2/24 dev eth0; sudo ip route add default via 192.168.1.1 dev eth0;
Remove static IP
sudo ip addr del 192.168.1.2/24 dev eth0;
Bring interface online
ip link set dev <interface> up ip link set dev <interface> down
Interface Alias
Change name: (change enp39s0 to eth0)
ip link set enp39s0 name eth0
Add Alias: (add eth0 to enp39s0)
ip link property add dev enp39s0 altname eth0 ip link property del dev enp39s0 altname eth0
Add Temporary IP to Interface
ip a add 192.168.178.2/24 dev eth0
Route
Print routes:
ip route
Add default route:
sudo ip route add default via 192.168.1.1 dev eth0;
Add route:
sudo ip route add 172.10.1.0/24 via 192.168.1.1 dev eth0;