Archive for FreeBSD

Resize a FreeBSD Disk Running Under VMware

I have a FreeBSD guest as a VM under VMware Fusion on my MacBook Air. It was built before my disk went from 250g to 500g, so was small. A research software build blew the 8g boundary. So, what worked was as follows

boot from a FreeBSD-9.0-RELEASE-amd64-bootonly.iso image
gpart delete -i 3 da0 (the swap)
gpart resize -i 2 -s 24g da0
gpart add -t freebsd-swap da0
growfs /da0p2

I see no reason this would not apply to vmware esxi on the servers

Comments off

DynaMIPS on FreeBSD on VMware ESXi

The simple approach to running DynaMIPS on FreeBSD guest under VMware did not work at all. No packets from the LAN reached the DynaMIPS ether interface.

24 hours later, and with the help of Iain and Rob, it was sorted.

It required two hacks as follows:

The first hack was running em1, the interface dynamips was using, through a custom vswitch that had promiscuous mode enabled.

The problem here was that this let packets through so well that it looped and multiplied them. Pings from the same ether LAN had TTLs as low as 220, delays of many seconds, and massive duplication of packets.

The second hack was running it through a bridge/tap interface on FreeBSD. In /etc/rc.conf lingo, that’s

   cloned_interfaces="bridge0 tap0"
   ifconfig_bridge0="addm em1 addm tap0"
   ifconfig_em1=up
   ifconfig_tap0=up

and then the dynagen conf file used

   fa0/0 = NIO_tap:/dev/tap0

Either hack alone did not work. It took both and one or more rubber chickens. The result looked like the following:

 
    .--------------------------.
    |                          |
    | .----------------------. |
    | |                      | |
    | | .------------------. | |
    | | |                  | | |
    | | |     DynaMIPS     | | |
    | | |                  | | |
    | | |                  | | |
    | | |           fa 0/0 | | |
    | | `--------------|---' | |
    | |                |     | |
    | |              tap0    | |
    | |  FreeBSD       |     | |
    | |             bridge0  | |
    | |                |     | |
    | |  em0          em1    | |
    | `---|------------|-----' |
    |     |            |       |
    |  vswitch      vswitch    |
    |     |            |       |
    |     `------------'       |
    |            |             |
    |  ESXi      |             |
    `------------|-------------'
                 |
        /--~~-----------~~--/
                LAN

The DynaGen configuration then looked like

  [localhost]
    [[7200]]
      model = 7200
      image = images/c7200-adventk9-mz-rpki26-v152_1_s_xe35_tr-bl30.unzip
      ram = 2048
      npe = npe-400
      idlepc = 0x6204bd2c
      ghostios = True
    [[router r0]]
      console = 2001
      aux = 3001
      fa0/0 = NIO_tap:/dev/tap0

Comments off

Freebsd-9 Configuration for Tunneling IPv6 to IIJ over IPv4 PPoE on B-Flets

With the generous help of Sato san, I managed to get IPv6 back working on my Tokyo home Soekris gateway to IIJ.

This is the simple view, pretty much focused on IPv4

               .-------------------------.
               |                         |
               |                b --wlan0|
               |                r        | 192.168.0.0/24
    WAN IIJ    |                i --- vr1| LAN hosts,
    PPP/NAT ---|vr0[PPPoE]tun0--d        | DHCP Clients
210.138.216.50 |                g --- vr2| ...
               |                e        |
               |                0 --- vr3|
               |                         |
               `-------------------------'

Here is the /etc/rc.conf

# User ppp configuration.
ppp_enable=YES
ppp_mode=dedicated
ppp_profile=iij

# IPv4 internal LAN
wlans_ath0=wlan0
create_args_wlan0="wlanmode ap mode 11g channel 11 up"
cloned_interfaces=bridge0
ifconfig_bridge0="192.168.0.1 addm vr1 addm vr2 addm vr3 addm wlan0 up"
ifconfig_vr1=up
ifconfig_vr2=up
ifconfig_vr3=up

gateway_enable=YES
hostapd_enable=YES # Run hostap daemon.

# IPv6 internal LAN
ifconfig_bridge0_ipv6="inet6 fe80::0452:fdff:fe5d:b500/64"
ifconfig_bridge0_alias0="inet6 2001:240:6a8::1/64"

# IPv6 options
ipv6_activate_all_interfaces=YES
ipv6_gateway_enable=YES
route6d_enable=YES
route6d_flags="-A 2001:240:6a8::/48,gif0 -O 2001:240:6a8::/48,gif0"
rtsold_enable=YES
rtadvd_enable=YES
rtadvd_interfaces="vr0 bridge0"
gif_interfaces=gif0
gifconfig_gif0="210.138.216.50 210.138.77.245"
ipv6_static_routes=gif
ipv6_route_gif="default -interface gif0"

and the /etc/ppp/ppp.conf

default:
set log Phase Chat LCP IPCP CCP tun command
ident user-ppp VERSION (built 2008.04.01)
disable ipv6cp

iij:
set device PPPoE:vr0
set MRU 1454 # NTT suggests this value
set MTU 1454
accept CHAP
enable lqr
add default HISADDR
nat enable yes
set authname <user>@bnf1.iij.ad.jp
set authkey <password>

Comments off