Changes between Version 17 and Version 18 of Internal/OpenFlow/miscUnix


Ignore:
Timestamp:
Aug 28, 2012, 7:35:02 PM (12 years ago)
Author:
akoshibe
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Internal/OpenFlow/miscUnix

    v17 v18  
    1 = *Nix related tidbits... =
    2 This is a page on various tools and techniques related to *nix administration, programming, disaster recovery - basically, odds and ends that come in handy once every so often.
     1= *Nix related tidbits. =
     2This is a page on various tools and techniques related to administration, programming, disaster recovery - basically, odds and ends that come in handy once every so often on a UNIX-like system.
    33Anything based on a link is reiterated just for completeness, and just in case a link dies.
    44
    5 This page is a compilation of things done with Ubuntu and FreeBSD; however, general practices do apply to any UNIX-like OS, though syntax will inevitably be different. 
     5This page is a compilation of things done with Ubuntu and FreeBSD; however, general practices should apply to any UNIX-like OS, though syntax will inevitably be different. 
    66
    77[#shell Shell-based] Command-line tools. So far, this section includes:
    8  * extundelete - for file system recovery
    9  * cdrecord - for burning ISO's
    10  * process I/O redirection (gdb)
    11  * fixing garbled text (gcc)
     8 * `extundelete` - Linux file system recovery
     9 * `cdrecord` - burning bootable ISO's
     10 * process I/O redirection (`gdb`)
     11 * fixing garbled text (`gcc`)
    1212[#net Network] Various networking-related things.
    1313 * Disabling SSH timeout
    1414 * NAT boxes
    15   * with `ufw`
    16   * with `pf`
    17 [#print Printing] quick CUPS setup [[BR]]
     15  * with `ufw` (Linux)
     16  * with `pf` (*BSD)
     17[#print Quick Printing] Printing under *nix, relatively quickly
     18 * CUPS
     19 * `lpd`
    1820[#fortune one-liners] miscellaneous single-sentence tips. [[BR]]
    1921----
     
    179181
    180182== NAT boxes. ==
     183NAT boxes are handy if you want to build a gateway. First and foremost, you need to enable IP packet forwarding on your to-be-NAT box. [[BR]]
     184On Linux, the command
     185{{{
     186sudo sysctl -e net.ipv4.ip_forward=1
     187}}}
     188at the shell enables it. For persistence, add the following line to /etc/default/ufw: 
     189{{{
     190net.ipv4.ip_forward=1
     191}}}
     192
     193[[BR]]
     194Similarly for FreeBSD (assuming you have `sudo` installed),
     195{{{
     196sudo sysctl net.inet.ip.forwarding=1
     197}}}
     198enables it, and the following line in /etc/sysctl.conf makes it persistent:
     199{{{
     200net.inet.ip.forwarding=1
     201}}}
     202
    181203=== with `ufw` ===
    182204source: https://nowhere.dk/articles/tip_nat_with_ubuntus_ufw_firewall
     
    187209{{{
    188210DEFAULT_FORWARD_POLICY="ACCEPT"
    189 }}}
    190 and /etc/ufw/sysctl.conf :
    191 {{{
    192 net.ipv4.ip_forward=1
    193211}}}
    194212 2. set up IP masquerading in `ufw`   
     
    230248sudo pfctl -e -f /etc/pf.conf
    231249}}}
    232 If it throws errors, make sure that the kernel module (pf.ko or something similar) is loaded. Also, don't forget that IP forwarding is enabled:
    233 {{{
    234 sudo sysctl net.inet.ip.forwarding=1
    235 }}}
    236 ----
    237 == Printing setup with CUPS. == #print
     250If it throws errors, make sure that the kernel module (pf.ko or something similar) is loaded.
     251
     252----
     253== Quick Printing Setup. == #print
     254This section contains info that should let you get up and printing from a network printer relatively quickly.
     255=== with CUPS ===
    238256 * ref: http://linuxcourse.rutgers.edu/howto/cups_printing.html
    239257CUPS stands for Common UNIX Printing System, and is fairly standard as a means to print from UNIX and UNIX-like things. We'll describe the steps needed for quick CUPS printing setup (bare-bones) in Ubuntu 11.04
     
    248266tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN     
    249267}}}
    250 If you see it, point your browser to localhost:631. You should get a shiny-white welcome page. Yes, it was made by Apple.
     268 If you see it, point your browser to localhost:631. You should get a shiny-white welcome page. Yes, it was made by Apple.
     269
    251270 3. Add your printer from the Administration tab -> Add Printer. It will ask for the root user and password (OK if you are on sudoers). You will be asked to provide info on the printer, and choose the drivers.
    252271[[BR]]
    253 If all goes well, you will be able to see the printer's status with `lpstat`.
     272 If all goes well, you will be able to see the printer's status with `lpstat`.
    254273{{{
    255274$ lpstat -p -d
     
    257276no system default destination
    258277}}}
    259 If you want to print, you can do so by invoking `lp`:
     278 If you want to print, you can do so by invoking `lp`:
    260279{{{
    261280$ lp -o sides=two-sided-long-edge -d Phaser_5500DT [filename]
     281}}}
     282
     283=== with `lpd` ===
     284 * ref: http://www.wonkity.com/~wblock/docs/html/lpdprinting.html
     285`lpd` comes packaged with FreeBSD, and is therefore extensively covered in its handbook. The above link lets you get going relatively quickly; here parts of the link are repeated.
     286
     287 1. (1) set up the spool directory (where printed files go temporarily), with (2) modified perms to keep jobs private:
     288{{{
     289mkdir /var/spool/lpd/lp                      (1)
     290chown daemon:daemon /var/spool/lpd/lp         
     291chmod 770 /var/spool/lpd/lp                  (2)
     292}}}
     293 2. enable `lpd`. Add the following to /etc/rc.conf:
     294{{{
     295lpd_enable="YES"
     296}}}
     297 to make `lpd` start at boot-up. "lpd" at the shell as root will also start it.
     298
     299 3. edit /etc/printcap :
     300{{{
     301lp:\
     302        :lp=9100@192.168.200.32:\
     303        :sh:\
     304        :mx#0:\
     305        :sd=/var/spool/lpd/lp:\
     306        :lf=/var/log/lpd-errs:
     307}}}
     308 * lp : the printer (port@machine IP), specifically Phaser_5500DT (the WINLAB printer in the large cubicle room)
     309 * sh : suppress page header
     310 * mx : maximum file size set to 0 (unlimited)
     311 * sd : spool directory
     312 * lf : file for error logging
     313[[BR]]
     314You can test if your setup works by piping a text string to `lpr`:
     315{{{
     316printf "printer test page\r\n\f" | lpr
     317}}}
     318 You also may have to do some extra work to print certain file formats. The WINLAB printer doesn't support direct printing of PDFs, so a quick work-around is to (1) convert, and (2) print it as a Postscript file:
     319{{{
     320pdf2ps /tmp/myfile.pdf /tmp/myfile.ps       (1)
     321lpr /tmp/myfile.ps                          (2)
    262322}}}
    263323----
     
    271331----
    272332[[BR]]
     333