router-id 172.16.44.44 AS 65044 network 192.168.44.0/24 network 192.168.172.0/24 network 2a01:490:19:d02c::/64 network 2a01:490:19:d12c::/64 network 2a01:490:19:d22c::/64 neighbor 172.16.0.1 { descr "backbone-router-v4" remote-as 65000 announce self } neighbor 2a01:490:19:d000::1 { descr "backbone-router-v6" remote-as 65000 announce self } allow from any allow from any prefix 0.0.0.0/0 allow from any prefix ::/0
sysctl net.inet.ip.forwarding=1 sysctl net.inet6.ip6.forwarding=1
sysctl -w net.ipv{4,6}.ip_forward=1 echo 1 > /proc/sys/net/ipv{4,6}/ip_forward
# ifconfig # ifconfig fxp0 # ifconfig vic0 192.0.2.23/24 # ifconfig vic0 192.0.2.23 netmask 255.255.255.0
# ifconfig vic0 alias 10.0.0.1/24 # ifconfig vic0 -alias 192.0.2.23 # ifconfig vlan1 create vlan 1 vlandev em0 # ifconfig vlan1 lladdr 10:22:33:44:55:FF # ifconfig vlan1 destroy # ifconfig trunk0 create trunkproto lacp trunkport em2 trunkport em3 trunkport xl0 # ifconfig ath0 nwid wifina-domaci nwkey 0x2233445566 # ifconfig ath0 -nwkey # ifconfig athn0 up nwid moje-wifina wpa wpakey moje-wpa-passphrase [wpaakms psk] # ifconfig athn0 up nwid eduroam wpa wpaakms 802.1x && wpa_supplicant -Dopenbsd -iathn0 -c/etc/wpa_supplicant.conf # ifconfig bridge0 add em2 add vlan4 # ifconfig em2 group troubove # ifconfig vlan4 group troubove # ifconfig troubove
# POZOR! Ultra-nepřehledné! # ifconfig eth0:1 10.0.0.1/24 # Lepší: # ip a a 10.0.0.1/24 dev eth0 # ip a d 192.0.2.23/24 dev eth0
# route add default 192.0.2.254 # route add -inet6 default fe80::200:5eff:fe00:1ff%vic0 # route delete default
# route add default gw 192.0.2.254 # ip r a default via 192.0.2.254
# brctl show # brctl addbr br0 # brctl addif br0 eth0 # brctl addif br0 eth1 # vconfig add eth0 5 # ifconfig eth0.5
Závisí na startovacích skriptech ve Vašem systému.
# cat /etc/hostname.vic0 inet 172.16.NN.254 255.255.0.0 NONE inet6 2002:c371:1236:1::NN:XXXX 64 ## <<< mezera místo lomítka description "Backbone - smer internet" # cat /etc/hostname.em0 dhcp rtsol up # cat /etc/mygate 172.16.0.1 fe80::200:5eff:fe00:1ff%vic0 # cat /etc/resolv.conf nameserver 172.16.0.1 (spustí všechny)# sh /etc/netstart (nebo jen jeden)# sh /etc/netstart vic0
dospat
# cat /etc/conf.d/net modules="iproute2" config_eth0="2a00::1/64 192.0.2.1/24" # RFC 3330 routes_eth0="default via fe80::200:5eff:fe00:1ff%eth0 default via 192.0.2.254" dns_servers_eth0="::1" mtu_eth1="4088" # cd /etc/init.d # ln -s net.lo net.eth0 # /etc/init.d/net.eth0 start
# cat /etc/sysconfig/network-scripts/ifcfg-MojeSuperSit # Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) DEVICE=eth0 BOOTPROTO=none ONBOOT=yes HWADDR=00:50:DE:AD:BE:EF NETMASK=255.255.255.0 IPADDR=192.0.2.100 GATEWAY=192.0.2.1 IPV6INIT=yes IPV6ADDR=2a2a:feed:beef::dead IPV6_DEFAULTGW=fe80::200:5eff:fe00:1ff%eth0 TYPE=Ethernet # /etc/init.d/network restart # # -- nebo # yum install system-config-network-tui # system-config-network
$ route -n get nix.cz route to: 195.47.235.3 destination: <vybraná cesta> mask: <její maska> gateway: <další hop> interface: carp98 if address: <lokální adresa> priority: 8 (static) flags:use mtu expire 84351445570 0 0
$ arp -n 10.0.0.10 $ arp -an
OS | L4 | L3 | jaký program? |
---|---|---|---|
-p {tcp,udp} | -f inet | fstat(1) | |
-{t,u} | -A inet | -p |
Detaily až na zvláštní přednášce; NAT zapnete takto:
# echo "match out on egress all nat-to (egress)" > /etc/pf.conf # echo "pass" >> /etc/pf.conf # pfctl -f /etc/pf.conf
# iptables -t nat -A POSTROUTING -o $ext -j MASQUERADE # iptables -P FORWARD ACCEPT # /etc/init.d/iptables save
# tcpdump -ni em0 ## To, na jakém interface sledujete, je pro ladění # tcpdump -nei pflog0 ## problémů se sítí naprosto zásadní informace. # tcpdump -vvni vlan3 ## Provoz například odněkud přichází, ale # tcpdump -Xni em2 ## jinam už z nějakého důvodu neodchází
# tcpdump -ni em0 host not 192.0.2.14 # tcpdump -ni em0 ether dst 00:11:22:33:44:55 # tcpdump -ni em0 host moje_brana and not tcp dst port 22 # tcpdump 'ether[0] & 1 = 0 and ip[16] >= 224'
# tcpdump -ni em0 -s1500 -w zaznam.pcap # tcpdump -ner zaznam.pcap
(potažmo)# nc -l 80 (ausfahrt)$ nc potažmo 80
nc -z potažmo 5900-5910
$ telnet nix.cz 80 Trying 2a02:38::1001... Connected to nix.cz. Escape character is '^]'. GET / HTTP/1.0 <prazdny radek - dejte Enter> HTTP/1.1 400 Bad Request Date: Tue, 18 Oct 2011 20:06:09 GMT Server: Apache Content-Length: 226 Connection: close Content-Type: text/html; charset=iso-8859-1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html> ... bla bla bla ... </html> Connection closed by foreign host.