1
Practical Networking
Based on Elisheva Alexander (eli7@cs.huji.ac.il) tirgul from sysp2001
Network Interfaces & ifconfig
- what is a network interface?
- Associated with a hardware device
– device fxp0 - Intel EtherExpress Pro
- Sometimes not
– loopback interface lo0 - pseudo-device
- Interfaces are handled by device drivers
- In FreeBSD interfaces are named after their device
drivers
– fxp0, fxp1, fxp2 - handled by fxp(4) driver – em0 - handled by the em(4) driver
- User interface:
– ioctl(2) to sockets in the PF_LINK domain – ifconfig(8) – may be configured at boot time by BOOTP/DHCP
Ifconfig(8)
- Can display current configuration for the network interface
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 inet 132.65.16.100 netmask 0xffff0000 broadcast 132.65.255.255 inet6 fe80::202:b3ff:fe97:8e09%em0 prefixlen 64 scopeid 0x1 ether 00:02:b3:97:8e:09 media: Ethernet autoselect (1000baseTX <full-duplex>) status: active fxp0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500 ether 00:b0:d0:b0:70:c3 media: Ethernet autoselect (none) status: no carrier lp0: flags=8810<POINTOPOINT,SIMPLEX,MULTICAST> mtu 1500 sl0: flags=c010<POINTOPOINT,LINK2,MULTICAST> mtu 552 faith0: flags=8002<BROADCAST,MULTICAST> mtu 1500 lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x6 inet 127.0.0.1 netmask 0xff000000 ppp0: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
The loopback device
- lo0 is the loopback device
- sends the packet back to our own host
- lo0 has IP 127.0.0.1 (aka localhost)
- telnet 127.0.0.1
- useful for debugging!
- run your server and client locally to assure reliable
connection
- saves time writing applications. for example: syslog
– can send log messages to a remote host – can save log messages locally. – no need to write different code for local and remote messages
Configuring with ifconfig(8)
ifconfig <interface> [address[dest_address]] [parameters]
- examples:
- ifconfig ppp0 up
– ifconfig em0 down – ifconfig vl0 mtu 1496
- Note the configuration differences between ppp
and ethernet devices:
– ifconfig ppp0 192.168.7.1 192.168.7.2 – ifconfig em0 192.168.0.1 netmask 255.255.255.0
Why is ifconfig different between ethernet and PPP
- ethernet
– unique MAC address (hardware address, ethernet address) – It's a broadcast network – IP network part - segment of IPs that can hear us – has a netmask to define the host part and network part – has a broadcast address - to talk to everyone
- PPP