File:  [NetBSD Developer Wiki] / wikisrc / users / imil / cheatsheet.mdwn
Revision 1.8: download - view: text, annotated - select for diffs
Wed Jul 25 21:32:43 2012 UTC (9 years, 6 months ago) by imil
Branches: MAIN
CVS tags: HEAD
simple NAT example

    1: # My NetBSD cheat sheet
    2: 
    3: Various tasks I use to do on my NetBSD systems.
    4: 
    5: ## Specify an IP address for your NIC
    6: 
    7: [[!template  id=programlisting text="""
    8: $ cat /etc/ifconfig.fxp0
    9: up
   10: inet 192.168.0.1 netmask 0xffffff00
   11: """]]
   12: 
   13: ## Add an IP alias on a NIC
   14: 
   15: [[!template  id=programlisting text="""
   16: $ cat /etc/ifconfig.fxp0
   17: up
   18: inet 192.168.0.1 netmask 0xffffff00
   19: inet 172.16.0.1 netmask 0xffffffff alias
   20: """]]
   21: 
   22: ## NIC will retrieve its IP address via DHCP
   23: 
   24: [[!template  id=programlisting text="""
   25: $ cat /etc/ifconfig.re0
   26: !dhcpcd $int
   27: """]]
   28: 
   29: ## Add a static route when bringing up NIC
   30: 
   31: [[!template  id=programlisting text="""
   32: $ cat /etc/ifconfig.re0
   33: up
   34: !dhcpcd $int
   35: !route -n add -net 10.0.0.0/8 192.168.0.254
   36: """]]
   37: 
   38: ## Specify a media type for a NIC
   39: 
   40: [[!template  id=programlisting text="""
   41: $ cat /etc/ifconfig.re0
   42: media 100baseTX up
   43: !dhcpcd $int
   44: """]]
   45: 
   46: ## Add an IPv6 address to a NIC
   47: 
   48: [[!template  id=programlisting text="""
   49: $ cat /etc/ifconfig.re0
   50: media 100baseTX up
   51: !dhcpcd $int
   52: inet6 2001:dead:beef:1::1 prefixlen 64
   53: """]]
   54: 
   55: ## Very basic pf rules for NAT and firewalling
   56: 
   57: [[!template  id=programlisting text="""
   58: $ cat /etc/pf.conf
   59: ext_if="sip0"
   60: int_if="re0"
   61: 
   62: nat on $ext_if from !($ext_if) -> ($ext_if:0)
   63: 
   64: # allow outgoing traffic (S/A is implied)
   65: pass out on $ext_if
   66: # block all incoming traffic
   67: block in log on $ext_if
   68: """]]
   69: 
   70: ## Upgrade the system with binaries
   71: 
   72: [[!template  id=programlisting text="""
   73: # cp /netbsd /netbsd.old
   74: # tar zxvfp kern-MONOLITHIC.tgz -C /
   75: # sync; sync
   76: # shutdown -r now
   77: # for i in base comp games man misc modules tests text xbase xcomp xetc xfont xserver; do tar zxvfp $i.tgz -C /;done
   78: # mkdir /tmp/temproot
   79: # tar zxvfp etc.tgz -C /tmp/temproot
   80: # postinstall -s /tmp/tmproot check
   81: # # copy postinstall's requirements
   82: # etcupdate -s /tmp/tmproot
   83: # shutdown -r now
   84: """]]
   85: 
   86: ## Upgrade the system with sources
   87: 
   88: * Build the userland
   89: 
   90: [[!template  id=programlisting text="""
   91: # cd /usr/src
   92: # ./build.sh -O ../obj -T ../tools -j#jobs -U distribution
   93: """]]
   94: 
   95: * Build the kernel
   96: 
   97: [[!template  id=programlisting text="""
   98: # cd /usr/src
   99: # ./build.sh -O ../obj -T ../tools -j#jobs kernel=YOUR_KERNEL
  100: """]]
  101: 
  102: * Install the new kernel
  103: 
  104: [[!template  id=programlisting text="""
  105: # cd /usr/src
  106: # cp /netbsd /netbsd.old
  107: # cp /usr/obj/sys/arch/YOUR_ARCH/compile/YOUR_KERNEL/netbsd /
  108: # shutdown -r now
  109: # cd /usr/src
  110: # ./build.sh -O ../obj -T ../tools -U install=/
  111: # /usr/sbin/etcupdate -s /usr/src
  112: """]]
  113: 
  114: ## Adobe Flash
  115: 
  116: [[!template  id=programlisting text="""
  117: # echo "procfs /emul/linux/proc procfs ro,linux" >> /etc/fstab
  118: # mount /emul/linux/proc
  119: # cd /usr/pkgsrc/www/nspluginwrapper
  120: # make install
  121: # cd /usr/pkgsrc/multimedia/ns-flash
  122: # make install
  123: $ nspluginwrapper -i /usr/pkg/lib/netscape/plugins/libflashplayer.so
  124: """]]
  125: 

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb