Skip to content

Instantly share code, notes, and snippets.

@ChoiZ
Created August 26, 2017 21:09
Show Gist options
  • Save ChoiZ/32add22a2addcb00c1b07c8a453a5902 to your computer and use it in GitHub Desktop.
Save ChoiZ/32add22a2addcb00c1b07c8a453a5902 to your computer and use it in GitHub Desktop.
Remplacer sa livebox par un USG 3 d'Ubiquiti
firewall {
all-ping enable
broadcast-ping disable
ip-src-route disable
log-martians enable
name WAN_IN {
default-action drop
description "WAN to internal"
rule 10 {
action accept
description "Allow established/related"
log disable
protocol all
state {
established enable
invalid disable
new disable
related enable
}
}
rule 20 {
action drop
description "Drop invalid state"
log disable
protocol all
state {
established disable
invalid enable
new disable
related disable
}
}
}
name WAN_LOCAL {
default-action drop
description "WAN to router"
rule 1 {
action accept
description "Allow established/related"
state {
established enable
related enable
}
}
rule 3 {
action drop
description "Drop invalid state"
log disable
state {
invalid enable
}
}
}
receive-redirects disable
send-redirects enable
source-validation disable
syn-cookies enable
}
interfaces {
ethernet eth0 {
description ISP
duplex auto
speed auto
vif 832 {
address dhcp
description ISP_DATA
dhcp-options {
client-option "send vendor-class-identifier "sagem";"
client-option "send user-class "\053FSVDSL_livebox.Internet.softathome.Livebox4";"
client-option "send rfc3118-auth 00:00:00:00:00:00:00:00:00:00:00:66:74:69:2f:61:62:63:31:64:32:65;"
client-option "request subnet-mask, routers, domain-name-servers, domain-name, broadcast-address, dhcp-lease-time, dhcp-renewal-time, dhcp-rebinding-time, rfc3118-auth;"
default-route update
default-route-distance 210
name-server update
}
egress-qos "0:0 1:0 2:0 3:0 4:0 5:0 6:6 7:0"
firewall {
in {
name WAN_IN
}
local {
name WAN_LOCAL
}
}
}
vif 838 {
address dhcp
description ISP_TV_VOD
dhcp-options {
client-option "send vendor-class-identifier "sagem";"
client-option "send user-class "\047FSVDSL_livebox.MLTV.softathome.Livebox4";"
client-option "send dhcp-client-identifier 1:AA:BB:CC:DD:EE:FF;"
client-option "request subnet-mask, routers, rfc3442-classless-static-routes;"
default-route no-update
default-route-distance 210
name-server update
}
egress-qos "0:4 1:4 2:4 3:4 4:4 5:4 6:4 7:4"
}
vif 840 {
address 192.168.255.254/32
description ISP_TV_STREAM
egress-qos "0:5 1:5 2:5 3:5 4:5 5:5 6:5 7:5"
}
}
ethernet eth1 {
description LAN_ETH1
address 192.168.1.1/24
duplex auto
speed auto
}
ethernet eth2 {
address 192.168.2.1/24
description LAN_ETH2
duplex auto
speed auto
}
loopback lo {
}
}
protocols {
igmp-proxy {
interface eth0 {
role disabled
threshold 1
}
interface eth0.832 {
role disabled
threshold 1
}
interface eth0.838 {
role disabled
threshold 1
}
interface eth0.840 {
alt-subnet 0.0.0.0/0
role upstream
threshold 1
}
interface eth1 {
role disabled
threshold 1
}
interface eth2 {
alt-subnet 0.0.0.0/0
role downstream
threshold 1
}
}
}
service {
dhcp-server {
disabled false
hostfile-update disable
shared-network-name LAN_ETH1_DHCP {
authoritative enable
subnet 192.168.1.0/24 {
default-router 192.168.1.1
dns-server 192.168.1.1
lease 86400
ntp-server 192.168.1.1
start 192.168.1.100 {
stop 192.168.1.200
}
}
}
shared-network-name LAN_ETH2_DHCP {
authoritative enable
subnet 192.168.2.0/24 {
default-router 192.168.2.1
dns-server 192.168.2.1
lease 86400
ntp-server 192.168.2.1
start 192.168.2.100 {
stop 192.168.2.200
}
}
}
use-dnsmasq disable
}
dns {
forwarding {
cache-size 1024
listen-on lo
listen-on eth1
listen-on eth2
name-server 80.10.246.3
name-server 81.253.149.10
}
}
gui {
http-port 80
https-port 443
listen-address 192.168.1.1
listen-address 192.168.2.1
older-ciphers disable
}
nat {
rule 5001 {
description "MASQ: WAN"
log disable
outbound-interface eth0.832
protocol all
type masquerade
}
rule 5002 {
description "MASQ: ORANGE"
log disable
outbound-interface eth0.838
protocol all
type masquerade
}
}
ssh {
listen-address 192.168.1.1
listen-address 192.168.2.1
port 22
protocol-version v2
}
upnp2 {
listen-on eth1
nat-pmp enable
port 34651
secure-mode enable
wan eth0.832
}
}
system {
config-management {
commit-revisions 5
}
conntrack {
expect-table-size 4096
hash-size 4096
table-size 32768
tcp {
half-open-connections 512
loose disable
max-retrans 3
}
}
login {
user ubnt {
authentication {
encrypted-password $1$zKNoUbAo$gomzUbYvgyUMcD436Wo66.
}
level admin
}
}
name-server 127.0.0.1
ntp {
server 0.ubnt.pool.ntp.org {
}
server 1.ubnt.pool.ntp.org {
}
server 2.ubnt.pool.ntp.org {
}
server 3.ubnt.pool.ntp.org {
}
}
offload {
hwnat disable
ipsec enable
ipv4 {
forwarding enable
gre enable
vlan enable
}
ipv6 {
forwarding enable
vlan enable
}
}
syslog {
global {
facility all {
level notice
}
facility protocols {
level warning
}
}
}
time-zone Europe/Paris
traffic-analysis {
dpi disable
export disable
}
}
/* Warning: Do not remove the following line. */
/* === vyatta-config-version: "config-management@1:conntrack@1:cron@1:dhcp-relay@1:dhcp-server@4:firewall@5:ipsec@5:nat@3:qos@1:quagga@2:system@4:ubnt-pptp@1:ubnt-util@1:vrrp@1:webgui@1:webproxy@1:zone-policy@1" === */
/* Release version: v1.9.1.4939093.161214.0705 */
# set classless routes based on the format specified in RFC3442
# e.g.:
# new_rfc3442_classless_static_routes='24 192 168 10 192 168 1 1 8 10 10 17 66 41'
# specifies the routes:
# 192.168.10.0/24 via 192.168.1.1
# 10.0.0.0/8 via 10.10.17.66.41
RUN="yes"
if [ "$RUN" = "yes" ]; then
if [ -n "$new_rfc3442_classless_static_routes" ]; then
if [ "$reason" = "BOUND" ] || [ "$reason" = "REBOOT" ]; then
set -- $new_rfc3442_classless_static_routes
while [ $# -gt 0 ]; do
net_length=$1
via_arg=''
case $net_length in
32|31|30|29|28|27|26|25)
net_address="${2}.${3}.${4}.${5}"
gateway="${6}.${7}.${8}.${9}"
shift 9
;;
24|23|22|21|20|19|18|17)
net_address="${2}.${3}.${4}.0"
gateway="${5}.${6}.${7}.${8}"
shift 8
;;
16|15|14|13|12|11|10|9)
net_address="${2}.${3}.0.0"
gateway="${4}.${5}.${6}.${7}"
shift 7
;;
8|7|6|5|4|3|2|1)
net_address="${2}.0.0.0"
gateway="${3}.${4}.${5}.${6}"
shift 6
;;
0) # default route
net_address="0.0.0.0"
gateway="${2}.${3}.${4}.${5}"
shift 5
;;
*) # error
return 1
;;
esac
# take care of link-local routes
if [ "${gateway}" != '0.0.0.0' ]; then
via_arg="via ${gateway}"
fi
# set route (ip detects host routes automatically)
ip -4 route add "${net_address}/${net_length}" \
${via_arg} dev "${interface}" >/dev/null 2>&1
done
fi
fi
fi
#!/bin/vbash
source /opt/vyatta/etc/functions/script-template
configure
set interfaces ethernet eth0 vif 832 dhcp-options client-option "send vendor-class-identifier "sagem";"
set interfaces ethernet eth0 vif 832 dhcp-options client-option "send user-class "\053FSVDSL_livebox.Internet.softathome.Livebox4";"
set interfaces ethernet eth0 vif 832 dhcp-options client-option "send rfc3118-auth 00:00:00:00:00:00:00:00:00:00:00:66:74:69:2f:61:62:63:31:64:32:65;" /* Identifiant FTI généré */
set interfaces ethernet eth0 vif 832 dhcp-options client-option "request subnet-mask, routers, domain-name-servers, domain-name, broadcast-address, dhcp-lease-time, dhcp-renewal-time, dhcp-rebinding-time, rfc3118-auth;"
set interfaces ethernet eth0 vif 832 egress-qos "0:0 1:0 2:0 3:0 4:0 5:0 6:6 7:0"
set interfaces ethernet eth0 vif 838 address dhcp
set interfaces ethernet eth0 vif 838 dhcp-options client-option "send vendor-class-identifier "sagem";"
set interfaces ethernet eth0 vif 838 dhcp-options client-option "send user-class "\047FSVDSL_livebox.MLTV.softathome.Livebox4";"
set interfaces ethernet eth0 vif 838 dhcp-options client-option "send dhcp-client-identifier 1:AA:BB:CC:DD:EE:FF;" /* MAC Livebox modem précédé de 1: */
set interfaces ethernet eth0 vif 838 dhcp-options client-option "request subnet-mask, routers, rfc3442-classless-static-routes;"
set interfaces ethernet eth0 vif 838 dhcp-options default-route no-update
set interfaces ethernet eth0 vif 838 dhcp-options default-route-distance 210
set interfaces ethernet eth0 vif 838 dhcp-options name-server update
set interfaces ethernet eth0 vif 838 egress-qos "0:4 1:4 2:4 3:4 4:4 5:4 6:4 7:4"
set interfaces ethernet eth0 vif 840 address 192.168.255.254/24
set interfaces ethernet eth0 vif 840 egress-qos "0:5 1:5 2:5 3:5 4:5 5:5 6:5 7:5"
set protocols igmp-proxy disable-quickleave
set protocols igmp-proxy interface eth0 role disabled
set protocols igmp-proxy interface eth0 threshold 1
set protocols igmp-proxy interface eth0.832 role disabled
set protocols igmp-proxy interface eth0.832 threshold 1
set protocols igmp-proxy interface eth0.838 role disabled
set protocols igmp-proxy interface eth0.838 threshold 1
set protocols igmp-proxy interface eth0.840 alt-subnet 0.0.0.0/0
set protocols igmp-proxy interface eth0.840 role upstream
set protocols igmp-proxy interface eth0.840 threshold 1
set protocols igmp-proxy interface eth1 role disabled
set protocols igmp-proxy interface eth1 threshold 1
set protocols igmp-proxy interface eth1.10 alt-subnet 0.0.0.0/0
set protocols igmp-proxy interface eth1.10 role downstream
set protocols igmp-proxy interface eth1.10 threshold 1
set protocols igmp-proxy interface eth2 role disabled
set protocols igmp-proxy interface eth2 threshold 1
set service dhcp-server global-parameters "option rfc3118-auth code 90 = string;"
set service dhcp-server global-parameters "option SIP code 120 = string;"
set service nat rule 6004 description "MASQ LiveboxTV to WAN"
set service nat rule 6004 log disable
set service nat rule 6004 outbound-interface eth0.838
set service nat rule 6004 protocol all
set service nat rule 6004 source group network-group corporate_network
set service nat rule 6004 type masquerade
commit
save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment