??????? ip ?????????? ? ???? ??????????? ?????? ifconfig, arp ? route,
?????????? ????????? ???????:
ip [?????] ?????? [ ??????? [????????? ???????] ]
??? ????? - ???????????? ?????????, ??????? ?????? ?? ????? ?????? ???????
??? ????? ???????????.
? ????????? ????? ???????? ????????? ?????:
-V, -Version - ??????? ? ??????????? ????? (stdout) ?????? ????????? ip
-s, -stats, -statistic - ??????? ?????????????? ??????????.
-f, - family - ??????????? ????? ??????????????? ?????????, ????? ??? inet
(IPv4), inet6(IPv6) ??? link (??????????). ?????? ??? ?????? ????????
?????????, ???? ???????? ?? ??????, ?? ?? ????????? ???????? ?????????? ??
?????????? ??????.
-4 - ?????? ????????? -family inet
-6 - ?????? ????????? -family inet6
-0 - ?????? ????????? -family link
-o, -oneline - ?????? ?????? ????? ?????????? ?? ????? ??????.
-r - ???????? ?? ????? ????????????? ????? ??????.
?????? - ??? ?????? ??????? ? ????? ???????? ??? ???????? ? ??????? ??????????.
??????? ?????? ??????????:
link - ??????? ??????????
address - IPv4 ??? IPv6 ????? ?? ??????????.
neighbour - ARP ??????
route - ????????????
rule - ???? ?????? ?????? ????????????
madress - Multicast-?????? ???????????? ????? ?????? ?????? ?????????????????
??????? ??????????? ?????????? ? ?????? ?????, ??????? ?? ??????????? ??????
???? ? ??? ?? ????? ???????. ??? ?????? ??????? ??? ??????? ?????????
??????????? ? ?????????????????. ?????????????? ???????, ?? ?? ????? ???????
Ethernet.
mroute - Multicast-???????.
tunnel - ??????? ????? IP.
??????? - ????????? ???????? ??? ????????.
ip link - ???????????? ???????? ??????????
????????? ???????: set ? show (??? list)
ip link set - ????????? ?????????? ???????? ??????????.
?????????:
dev - ??? ?????????? ? ??????? ????? ????????? ?????-?? ???????????.
up (????????) ??? down (?????????) - ???????? ??? ????????? ??????? ?????????.
arp on ??? arp off - ???????? ???????? ????? NOARP ?? ??????????.
multicast on ??? multicast off - ???????? ???? MULTICAST ?? ??????????.
dynamic on ??? dynamic off - ???????? ???? DYNAMIC ?? ??????????.
name - ???????? ??? ??????????
txqueuelen ????? ??? txqlen ????? - ???????? ????? ???????????? ???????.
mtu ????? - ???????? ???????? MTU ?? ??????????.
address ????? - ???????? ????? ?? ??????????.
broadcast ????? ??? brd ????? - ???????? ????????????????? ????? ?? ??????????.
ip link show (list, ls, sh, lst, l)- ?????????? ?????????? ?? ??????? ??????????.
?????????:
dev - ??? ?????????? ? ??????? ????? ????????? ?????-?? ???????????.
up - ???????? ?????? ?????????? ??????????.
???????:
??????? ?????????? ? ????????? ?????????? eth0
# ip link ls dev eth0
? ?????????? ???????:
eth0: mtu 1500 qdisc cbq qlen 100
link/ether 00:04:61:92:21:1d brd ff:ff:ff:ff:ff:ff
??????? ?????????? ?????????? eth0
#ip -s link ls dev eth0
2: eth0: mtu 1500 qdisc cbq qlen 100
link/ether 00:04:61:92:21:1d brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
2891892504 15070935 0 0 0 0
TX: bytes packets errors dropped carrier collsns
3139067270 54387014 0 0 0 132934
ip address - ?????????? ???????? ?? ??????????
??????? address ????? ??? ???????????: addr, a.
?????? address - ??? ????? IPv4 ??? IPv6 ?????????, ????????? ? ?????-??
???????????, ????? ??? ????? ???????? ? ??????? ???????????. ??? ?? ??????
?????????? ????? ????? ????????? IP ???????.
??????? ip address ?????????? ??????, ?? ????????, ? ??? ?? ????????? ?????
??? ??????? ??????.
ip address add - ????????? ????? ?????.
?????????:
dev ??? - ??? ??????????.
local ????? - ????? ??????????.
peer ????? - ????? ????????? ?????? ??? ????????????? ????????? PPP.
broadcast ????? - ????????????????? ????? ?? ??????????.
? ???? ?????? ?? ?????? ???????????? ??????????? ??????? "+" ? "-", ? ????
?????? ????????????????? ????? ?????????? ????? ?????????/?????? ??? ? ?????
?????.
label ????? - ?????? ????? ????? ???? ???????? ???????, ?????? ??????? ???????,
??? ??? ?????? ?????????? ? ????? ??????????, ????? ????? ????????? ???? ????
?????.
??????:
ip addr add 10.0.0.1/24 brd + dev eth0 label eth0:Alias
?????? ??????? ????????? ????? 10.0.0.1/24 ? ?????? ??????? 255.255.255.0 ??
??????????? ????????????????? ??????? ? ?????? eth0:Alias.
ip address delete - ??????? ??????.
??????????:
delete, del, d.
??????:
ip addr del 127.0.0.1/8 dev lo
??????? ????? 127.0.0.1/8 ? ?????????? lo.
ip address show - ??????? ?????????? ?? ??????.
??????????:
show, list, lst, sh, ls, l.
?????????:
dev ??? - ??? ??????????.
to ??????? - ??????? ?????????? ? ??????? ? ???????? ?????????.
label ??? - ??????? ?????????? ?? ??????? ? ???????? ??????.
?????? ?????? ???????:
kuznet@alisa:~ $ ip addr ls eth0
3: eth0: mtu 1500 qdisc cbq qlen 100
link/ether 00:a0:cc:66:18:78 brd ff:ff:ff:ff:ff:ff
inet 193.233.7.90/24 brd 193.233.7.255 scope global eth0
inet6 3ffe:2400:0:1:2a0:ccff:fe66:1878/64 scope global dynamic
valid_lft forever preferred_lft 604746sec
inet6 fe80::2a0:ccff:fe66:1878/10 scope link
kuznet@alisa:~ $
ip route -?????????? ???????? ????????????.
??????????:
route, ro, r.
ip route add - ???????? ????? ???????
ip route change - ???????? ???????
ip route replace - ???????? ???????
??????????:
add, a; change, chg; replace, repl.
?????????:
to - ?????????? ????????.
metric ????? - ??????? ??????? ????????.
table ????????????? ??????? - ??????? ????????? ? ?????????. ???????????????
??????? ????? ???? ????? ??? ?????? ?? ????? /etc/iproute2/rt_tables
dev ??? - ??? ??????????.
via ????? - ????? ???????? ? ?????????? ??????????????
src ????? - ????? ?????????
nexthop NEXTHOP - ????????? ??????? ? ?????? ???? ???????????? ??????????????
?????????????.
via ?????
dev ??? - ??? ??????????.
weight ????? - ??? ????????, ?????????????? ??????? ?????? ??? ????????? .
???????:
????????? ??????? ? ???? 10.0.0/24 ????? 193.233.7.65
ip route add 10.0.0/24 via 193.233.7.65
??????? ???? ?? ????????? ? ?????? ????????????? ???? ??????? ? ??????????? ??
???????? ??????:
ip route add default scope global nexthop dev ppp0
nexthop dev ppp1
ip route delete - ??????? ???????.
??????????:
delete, del, d.
?????????:
????????? ?????? ??????? ? ?????? ? ip route add.
??????:
??????? ??????? ????????? ? ?????????? ???????.
ip route del default scope global nexthop dev ppp0
nexthop dev ppp1
ip rule - ?????????? ????????? ????????????
??????????:
rule, ru
????????????? ????? ????????????? ?? ?????? ? ??????????? ?? ?????? ??????????,
?? ? ?? ?????? ?????????, IP ????????? ? ????????????? ?????????.
?? ????????? ? ?????????? 3 ???????:
??????? Local (ID 255) - ??????????? ??????? ????????????? ? ????? ???????
???????????, ??????? ???????? ??????? ??? ????????? ? ?????????????????
???????.
??????? Main (ID 254) - ??????? ??????? ?????????????.
??????? Default (ID 253) - ?????? ?? ????????? ???????.
ip rule add - ???????? ????? ???????.
Ip rule delete - ??????? ???????.
??????????:
add, a; delete, del, d
?????????:
from - ????? ????????
to - ????? ??????????
iif ??? - ??? ?????????? ? ???????? ????? ??????? ?????
fwmark ????? - ????? ??????, ??????????????? firewall.
table ????????????? ??????? - ??????? ????????? ? ?????????. ???????????????
??????? ????? ???? ????? ??? ?????? ?? ????? /etc/iproute2/rt_tables
priority ?????- ????????? ???????.
???????:
???????????????? ?????? ? ???? 192.203.80.0/24 ???????? ??????? example.
ip ru add from 192.203.80.0/24 table example prio 220
?????????? ??????? ????????????? ????????????? ?? ?????? ??????.
1. ????? ? ??? ???? ??? ?????? ? ????????: ??????? ????? ? IP ???????
212.64.94.251 ????????? PPP c 212.64.94.1 ? ????????? c 212.64.78.148
????????? PPP c 195.96.98.253. ???? ?????? ?????? ???????????? ??????????
????? ????????? ?????. ??? ????? ?????????? ????? ???????:
# echo 200 John >> /etc/iproute2/rt_tables
# ip rule add from 10.0.0.10 table John
# ip rule ls
0: from all lookup local
32765: from 10.0.0.10 lookup John
32766: from all lookup main
32767: from all lookup default
????? ????????? ??? ????? ???????????? ???? ?? ????????? ? ??????? ??? ???????
????????????? ??? ???? ????? ???? ????????? ???????? ? ????????.
# ip route add default via 195.96.98.253 dev ppp2 table John
# ip route flush cache
2. ?????????? ????????? ???? ?????? ?? 80 ???? ????? ????? ????? eth0.
??????? ?????? ?????? ?? 80 ????.
# iptables -A PREROUTING -i eth0 -t mangle -p tcp --dport 80
-j MARK --set-mark 2
???????? ??????? ??? ?????????? ???????.
# echo 202 www.out >> /etc/iproute2/rt_tables
# ip rule add fwmark 2 table www.out
# ip route add default via 10.0.0.2 dev eth0 table www.out
# ip route flush cache
?????? ?????????????? ??????????:
1. IP Command Reference Alexey N. Kuznetsov
2. Linux Advanced Routing & Traffic Control HOWTO
© Vadim Fedorov vadim.org.ua
 |