Project

General

Profile

Regression #12821 » pfatt.sh

Kris Phillips, 10/08/2022 08:21 PM

 
1
#!/bin/sh
2
set -e
3

    
4
ONT_IF='igbX'
5
RG_IF='igbX'
6
RG_ETHER_ADDR='XX:XX:XX:XX:XX:XX'
7
LOG=/var/log/pfatt.log
8

    
9
getTimestamp(){
10
    echo `date "+%Y-%m-%d %H:%M:%S :: [pfatt.sh] ::"`
11
}
12

    
13
{
14
    echo "$(getTimestamp) pfSense + AT&T U-verse Residential Gateway for true bridge mode"
15
    echo "$(getTimestamp) Configuration: "
16
    echo "$(getTimestamp)        ONT_IF: $ONT_IF"
17
    echo "$(getTimestamp)         RG_IF: $RG_IF"
18
    echo "$(getTimestamp) RG_ETHER_ADDR: $RG_ETHER_ADDR"
19

    
20
    echo -n "$(getTimestamp) attaching interfaces to ng_ether... "
21
    /usr/local/bin/php -r "function_exists('pfSense_ngctl_attach') && pfSense_ngctl_attach('.', '$ONT_IF');"
22
    /usr/local/bin/php -r "function_exists('pfSense_ngctl_attach') && pfSense_ngctl_attach('.', '$RG_IF');"
23
    echo "OK!"
24

    
25
    echo "$(getTimestamp) building netgraph nodes..."
26

    
27
    echo -n "$(getTimestamp)   creating ng_one2many... "
28
    /usr/sbin/ngctl mkpeer $ONT_IF: one2many lower one
29
    /usr/sbin/ngctl name $ONT_IF:lower o2m
30
    echo "OK!"
31

    
32
    echo -n "$(getTimestamp)   creating vlan node and interface... "
33
    /usr/sbin/ngctl mkpeer o2m: vlan many0 downstream
34
    /usr/sbin/ngctl name o2m:many0 vlan0
35
    /usr/sbin/ngctl mkpeer vlan0: eiface vlan0 ether
36

    
37
    /usr/sbin/ngctl msg vlan0: 'addfilter { vlan=0 hook="vlan0" }'
38
    /usr/sbin/ngctl msg ngeth0: set $RG_ETHER_ADDR
39
    echo "OK!"
40

    
41
    echo -n "$(getTimestamp)   defining etf for $ONT_IF (ONT)... "
42
    /usr/sbin/ngctl mkpeer o2m: etf many1 downstream
43
    /usr/sbin/ngctl name o2m:many1 waneapfilter
44
    /usr/sbin/ngctl connect waneapfilter: $ONT_IF: nomatch upper
45
    echo "OK!"
46

    
47
    echo -n "$(getTimestamp)   defining etf for $RG_IF (RG)... "
48
    /usr/sbin/ngctl mkpeer $RG_IF: etf lower downstream
49
    /usr/sbin/ngctl name $RG_IF:lower laneapfilter
50
    /usr/sbin/ngctl connect laneapfilter: $RG_IF: nomatch upper
51
    echo "OK!"
52

    
53
    echo -n "$(getTimestamp)   bridging etf for $ONT_IF <-> $RG_IF... "
54
    /usr/sbin/ngctl connect waneapfilter: laneapfilter: eapout eapout
55
    echo "OK!"
56

    
57
    echo -n "$(getTimestamp)   defining filters for EAP traffic... "
58
    /usr/sbin/ngctl msg waneapfilter: 'setfilter { matchhook="eapout" ethertype=0x888e }'
59
    /usr/sbin/ngctl msg laneapfilter: 'setfilter { matchhook="eapout" ethertype=0x888e }'
60
    echo "OK!"
61

    
62
    echo -n "$(getTimestamp)   enabling one2many links... "
63
    /usr/sbin/ngctl msg o2m: setconfig "{ xmitAlg=2 failAlg=1 enabledLinks=[ 1 1 ] }"
64
    echo "OK!"
65

    
66
    echo -n "$(getTimestamp)   removing waneapfilter:nomatch hook... "
67
    /usr/sbin/ngctl rmhook waneapfilter: nomatch
68
    echo "OK!"
69

    
70
    echo -n "$(getTimestamp) enabling $RG_IF interface... "
71
    /sbin/ifconfig $RG_IF up
72
    echo "OK!"
73

    
74
    echo -n "$(getTimestamp) enabling $ONT_IF interface... "
75
    /sbin/ifconfig $ONT_IF up
76
    echo "OK!"
77

    
78
    echo -n "$(getTimestamp) enabling promiscuous mode on $RG_IF... "
79
    /sbin/ifconfig $RG_IF promisc
80
    echo "OK!"
81

    
82
    echo -n "$(getTimestamp) enabling promiscuous mode on $ONT_IF... "
83
    /sbin/ifconfig $ONT_IF promisc
84
    echo "OK!"
85

    
86
    echo "Disabling VLAN HW Filter for all interfaces involved"
87
    /sbin/ifconfig $ONT_IF -vlanhwfilter
88
    /sbin/ifconfig $RG_IF -vlanhwfilter
89
    echo "OK!"
90

    
91
    echo "$(getTimestamp) ngeth0 should now be available to configure as your pfSense WAN"
92
    echo "$(getTimestamp) done!"
93
} >> $LOG
(2-2/2)