Re: netgraph arp issues vs linux veth

2004-05-04 Thread Robin Breathe
David Yeske wrote:
I made another attempt with netgraph and I think I'm almost there, but I'm
still having some issues.  I found a linux solution called veth
http://www.geocities.com/nestorjpg/veth/ which might do the job, but I would
prefer to use netgraph if possible.  Here is some more detailed config
information.
*SNIP*
Any clues or pointers are greatly appreciated and will mean I get to deploy
FreeBSD with netgraph rather than linux with veth.
Regards,
David Yeske
Reading this and your other post, it seems that you're trying to emulate 
multiple distinct physical network interfaces on one physical interface 
with netgraph(4). This is something I've played with myself.

I wrote the attached script, mkbridge.sh, to create an ng_bridge(4) 
attached to the ng_ether(4) node of a particular "real" interface, with 
an arbitrary number of additional ng_eiface(4), each with it's own MAC 
address. You've got this far already, but you (or someone else) might 
find the script useful with some polish.

Now, the part you're getting stuck on is the system spitting response 
packets out of the interface associated with the route to the remote 
host. So, what you need is some policy routing.
A minimal ipf(4) config to achieve this might be:

pass out quick on rl0 to ngeth0 from 192.168.10.3/32 to any
Works here on -CURRENT, YMMV. Something similar with ipfw(4) should be 
equally simple.

I warn you that the mkbridge.sh script *may* panic 5.2.x-RELEASE if you 
try the "stop" target (not happy shutting down an ng_eiface(4) node 
which has had its MAC address changed)... this has been fixed in 
-CURRENT; I don't know about -STABLE.

Regards,
- Robin
--
Robin Breathe  /  [EMAIL PROTECTED]  /  +44-1865-741800
#!/bin/sh -x
# Robin Breathe, 2004

# external interface
bridge_iface="em0"
# the name of our ng_bridge(4)
bridge="bridge0"
# number of ng_eiface(4) virtual ethernet interfaces to create
nvif="2"

case $1 in

start)
# ensure all necessary modules are loaded
for module in ng_ether ng_bridge ng_eiface; do
kldstat -v | grep -qw ${module} || kldload ${module}.ko || exit 1
done

# attach the external interface to the new bridge 
ngctl mkpeer  ${bridge_iface}: bridge lower link0
ngctl name${bridge_iface}:lower ${bridge}
ngctl connect ${bridge_iface}: ${bridge}: upper link1

# stop external interface modifying IEEE 802.3 source address on outbound 
frames
ngctl msg ${bridge_iface}: setautosrc 0
ngctl msg ${bridge_iface}: setpromisc 1

# setup and attach each tap(4) virtual ethernet device
for i in $(jot ${nvif:-1} 0); do
# create and attach the ng_eiface(4) to the ng_bridge(4)
ngctl mkpeer ${bridge}: eiface link$((i+2)) ether
# name it vif#
ngctl name ${bridge}:link$((i+2)) vif$i
# give it a MAC address: 00:be:YY:MM:DD:##
link_addr=$(printf "00:be:%s:%02x" $(date +%y:%m:%d) $((i+1)))
ifconfig ngeth$i ether ${link_addr}
done
;;

stop)
ngctl shutdown ${bridge}:
for i in $(jot ${nvif:-1} 0); do
ngctl shutdown vif$((i)):
done
ngctl msg ${bridge_iface}: setautosrc 1
ngctl msg ${bridge_iface}: setpromisc 0
;;

*)
echo "USAGE: `basename $0` {start|stop}" >&2
exit 64
;;

esac
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


netgraph arp issues vs linux veth

2004-04-27 Thread David Yeske
I made another attempt with netgraph and I think I'm almost there, but I'm
still having some issues.  I found a linux solution called veth
http://www.geocities.com/nestorjpg/veth/ which might do the job, but I would
prefer to use netgraph if possible.  Here is some more detailed config
information.

I ran this on the spoof machine

# ngctl mkpeer . eiface hook ether
# ifconfig ngeth0 link 00:bd:03:12:12:12
# ifconfig ngeth0 192.168.10.3 netmask 255.255.255.0

# ngctl mkpeer ngeth0: bridge lower link0
# ngctl name ngeth0:lower broken
# ngctl connect fxp0: broken: lower link1
# ngctl connect fxp0: broken: upper link2
# ngctl connect ngeth0: broken: upper link3
# ngctl msg ngeth0: setpromisc 1
# ngctl msg ngeth0: setautosrc 0
# ngctl msg fxp0: setpromisc 1
# ngctl msg fxp0: setautosrc 0

# ngctl show broken:
  Name: broken  Type: bridge  ID: 0046   Num hooks: 4
  Local hook  Peer name   Peer typePeer ID Peer hook
  --  -   ---- -
  link3   ngeth0  ether0005upper
  link2   fxp0ether0004upper
  link1   fxp0ether0004lower
  link0   ngeth0  ether0005lower

on the remote machine an arp -a lists this
? (192.168.10.3) at 00:bd:03:12:12:12 on rl0 [ethernet] 
? (192.168.10.1) at 00:00:e8:5b:13:44 on rl0 permanent [ethernet]

on the spoof machine an arp -a lists this
? (192.168.10.1) at (incomplete) on ngeth0 [ethernet]
? (192.168.10.3) at 00:bd:03:12:12:12 on ngeth0 permanent [ethernet]

a sniff on the spoof machine listed this while pinging the remote machine

# tcpdump -i ngeth0 'ether host 00:00:e8:5b:13:44'
tcpdump: listening on ngeth0
14:03:30.519263 arp reply 192.168.10.1 is-at 0:0:e8:5b:13:44
14:03:33.416568 192.168.10.1 > 192.168.10.3: icmp: echo request
14:03:40.530562 arp reply 192.168.10.1 is-at 0:0:e8:5b:13:44
14:03:43.427175 192.168.10.1 > 192.168.10.3: icmp: echo request
14:03:50.540805 arp reply 192.168.10.1 is-at 0:0:e8:5b:13:44
14:03:53.437845 192.168.10.1 > 192.168.10.3: icmp: echo request
14:04:00.550960 arp reply 192.168.10.1 is-at 0:0:e8:5b:13:44
14:04:03.448383 192.168.10.1 > 192.168.10.3: icmp: echo request

a sniff on the remote machine listed this while pinging the spoof machine

# tcpdump -i rl0 'ether host 00:bd:03:12:12:12'
tcpdump: listening on rl0
14:02:24.918804 192.168.10.1 > 192.168.10.3: icmp: echo request
14:02:29.179263 arp reply 192.168.10.1 is-at 0:0:e8:5b:13:44
14:02:34.929051 192.168.10.1 > 192.168.10.3: icmp: echo request
14:02:44.939136 192.168.10.1 > 192.168.10.3: icmp: echo request
14:02:52.052260 arp reply 192.168.10.1 is-at 0:0:e8:5b:13:44
14:02:54.949402 192.168.10.1 > 192.168.10.3: icmp: echo request
14:03:02.063079 arp reply 192.168.10.1 is-at 0:0:e8:5b:13:44
14:03:04.959534 192.168.10.1 > 192.168.10.3: icmp: echo request
14:03:12.072830 arp reply 192.168.10.1 is-at 0:0:e8:5b:13:44

Any clues or pointers are greatly appreciated and will mean I get to deploy
FreeBSD with netgraph rather than linux with veth.

Regards,
David Yeske

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"