Skip to content

Instantly share code, notes, and snippets.

@vchimishuk
Created January 30, 2025 10:42
Show Gist options
  • Save vchimishuk/44331eda16a00da98fff47123422f42f to your computer and use it in GitHub Desktop.
Save vchimishuk/44331eda16a00da98fff47123422f42f to your computer and use it in GitHub Desktop.

Revisions

  1. vchimishuk created this gist Jan 30, 2025.
    66 changes: 66 additions & 0 deletions openbsd-routing
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,66 @@
    +--------+ +---------+
    | | em1:192.168.1.1 192.168.1.10 | |
    | =------------------------------------= client1 |
    | | em2:192.168.2.1 | |
    = router =-------------------+ +---------+
    | | |
    | =-------------- | +---------+
    | | | 192.168.2.10 | |
    +--------+ +----------------= client2 |
    | |
    +---------+


    [router] $ ifconfig em
    em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    lladdr 00:0d:b9:5e:a9:80
    index 1 priority 0 llprio 3
    groups: egress
    media: Ethernet autoselect (1000baseT full-duplex,rxpause,txpause)
    status: active
    inet 192.168.242.88 netmask 0xffffff00 broadcast 192.168.242.255
    em1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    lladdr 00:0d:b9:5e:a9:81
    index 2 priority 0 llprio 3
    media: Ethernet autoselect (100baseTX full-duplex,rxpause,txpause)
    status: active
    inet 192.168.1.1 netmask 0xffffff00 broadcast 192.168.1.255
    em2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    lladdr 00:0d:b9:5e:a9:82
    index 3 priority 0 llprio 3
    media: Ethernet autoselect (1000baseT full-duplex,rxpause,txpause)
    status: active
    inet 192.168.2.1 netmask 0xffffff00 broadcast 192.168.2.255
    em3: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    lladdr 00:0d:b9:5e:a9:83
    index 4 priority 0 llprio 3
    media: Ethernet autoselect (none)
    status: no carrier
    inet 192.168.3.1 netmask 0xffffff00 broadcast 192.168.3.255


    [router] $ sysctl net.inet.ip.forwarding
    net.inet.ip.forwarding=1


    [router] $ doas pfctl -s rules
    pass out all flags S/SA
    pass in all flags S/SA


    [router] $ ping -c 1 192.168.2.10
    PING 192.168.2.10 (192.168.2.10): 56 data bytes
    64 bytes from 192.168.2.10: icmp_seq=0 ttl=255 time=0.709 ms

    --- 192.168.2.10 ping statistics ---
    1 packets transmitted, 1 packets received, 0.0% packet loss
    round-trip min/avg/max/std-dev = 0.709/0.709/0.709/0.000 ms


    [router] $ telnet 192.168.2.10 22
    Trying 192.168.2.10...
    Connected to 192.168.2.10.
    Escape character is '^]'.
    SSH-2.0-OpenSSH_9.5
    ^C
    Connection closed by foreign host.