Linux/ip: Difference between revisions
< Linux
No edit summary |
|||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Install ip tool == | |||
apt install iproute2 | |||
== Add static IP == | == Add static IP == | ||
Line 4: | Line 8: | ||
sudo ip route add default via 192.168.1.1 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> up | ||
ip link set dev <interface> down | ip link set dev <interface> down | ||
== 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 == |
Latest revision as of 06:12, 31 July 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
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;