Eu tenho um FreeBSD VPS que até recentemente tinha atribuído 3 endereços IP públicos em uma sub-rede / 29 . Ao fazer conexões de saída, o endereço IP usado sempre foi o sem alias " .20 ", no entanto, agora eu adicionei outro bloco de 3 endereços IP em um / 29 diferente. sub-rede e o IP de saída alterado para " .44 ".
Abaixo estão as configurações do rc.conf antes e depois de adicionar os segundos aliases da sub-rede.
Antes:
ifconfig_em0="inet 70.70.70.20 netmask 255.255.255.248"
ifconfig_em0_alias0="inet 70.70.70.21 netmask 255.255.255.248"
ifconfig_em0_alias1="inet 70.70.70.22 netmask 255.255.255.248"
defaultrouter="70.70.70.17"
Agora:
ifconfig_em0="inet 70.70.70.20 netmask 255.255.255.248"
ifconfig_em0_alias0="inet 70.70.70.21 netmask 255.255.255.248"
ifconfig_em0_alias1="inet 70.70.70.22 netmask 255.255.255.248"
ifconfig_em0_alias2="inet 60.60.60.44 netmask 255.255.255.248"
ifconfig_em0_alias3="inet 60.60.60.45 netmask 255.255.255.248"
ifconfig_em0_alias4="inet 60.60.60.46 netmask 255.255.255.248"
defaultrouter="70.70.70.17"
Lendo a entrada manual do ifconfig Não tenho certeza da máscara de rede correta para os aliases. A entrada manual diz:
alias Establish an additional network address for this interface. This
is sometimes useful when changing network numbers, and one wishes
to accept packets addressed to the old interface. If the address
is on the same subnet as the first network address for this
interface, a non-conflicting netmask must be given. Usually
0xffffffff is most appropriate.
Pergunta 1: Essa seria a configuração correta? (observe o alias2)
ifconfig_em0="inet 70.70.70.20 netmask 255.255.255.248"
ifconfig_em0_alias0="inet 70.70.70.21 netmask 255.255.255.255"
ifconfig_em0_alias1="inet 70.70.70.22 netmask 255.255.255.255"
ifconfig_em0_alias2="inet 60.60.60.44 netmask 255.255.255.248"
ifconfig_em0_alias3="inet 60.60.60.45 netmask 255.255.255.255"
ifconfig_em0_alias4="inet 60.60.60.46 netmask 255.255.255.255"
defaultrouter="70.70.70.17"
Quando tentei essa abordagem, o endereço IP de saída padrão foi alterado para " .46 ".
Pergunta 2: Como eu posso definir o endereço IP padrão usado para conexões de saída, se por exemplo eu quero que seja 70.70.70.21?
Abaixo estão as tabelas de roteamento e informações de interface:
Tabelas de roteamento
Internet:
Destination Gateway Flags Refs Use Netif Expire
default 70.70.70.17 UGS 0 2000863 em0
60.60.60.40/29 link#1 U 0 12 em0
60.60.60.44 link#1 UHS 0 18291 lo0
60.60.60.45 link#1 UHS 0 0 lo0
60.60.60.46 link#1 UHS 0 5 lo0
70.70.70.16/29 link#1 U 0 0 em0
70.70.70.20 link#1 UHS 0 6 lo0
70.70.70.21 link#1 UHS 0 0 lo0
70.70.70.22 link#1 UHS 0 0 lo0
127.0.0.1 link#3 UH 0 203 lo0
Tabelas de roteamento (com máscara de rede .255)
Internet:
Destination Gateway Flags Refs Use Netif Expire
default 70.70.70.17 UGS 0 2015436 em0
60.60.60.40/29 link#1 U 0 12 em0
60.60.60.44 link#1 UHS 0 18295 lo0
60.60.60.45 link#1 UHS 0 0 lo0 =>
60.60.60.45/32 link#1 U 0 0 em0
60.60.60.46 link#1 UHS 0 9 lo0 =>
60.60.60.46/32 link#1 U 0 0 em0
70.70.70.16/29 link#1 U 0 0 em0
70.70.70.20 link#1 UHS 0 6 lo0
70.70.70.21 link#1 UHS 0 0 lo0 =>
70.70.70.21/32 link#1 U 0 0 em0
70.70.70.22 link#1 UHS 0 0 lo0 =>
70.70.70.22/32 link#1 U 0 0 em0
127.0.0.1 link#3 UH 0 205 lo0
ifconfig em0
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
ether 00:11:22:33:44:55
inet 70.70.70.20 netmask 0xfffffff8 broadcast 70.70.70.23
inet 70.70.70.21 netmask 0xfffffff8 broadcast 70.70.70.23
inet 70.70.70.22 netmask 0xfffffff8 broadcast 70.70.70.23
inet 60.60.60.44 netmask 0xfffffff8 broadcast 60.60.60.47
inet 60.60.60.45 netmask 0xfffffff8 broadcast 60.60.60.47
inet 60.60.60.46 netmask 0xfffffff8 broadcast 60.60.60.47
media: Ethernet autoselect (1000baseT <full-duplex>)
status: active
ifconfig em0 (com máscara de rede .255)
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
ether 00:11:22:33:44:55
inet 70.70.70.20 netmask 0xfffffff8 broadcast 70.70.70.23
inet 60.60.60.44 netmask 0xfffffff8 broadcast 60.60.60.47
inet 70.70.70.21 netmask 0xffffffff broadcast 70.70.70.21
inet 70.70.70.22 netmask 0xffffffff broadcast 70.70.70.22
inet 60.60.60.45 netmask 0xffffffff broadcast 60.60.60.45
inet 60.60.60.46 netmask 0xffffffff broadcast 60.60.60.46
media: Ethernet autoselect (1000baseT <full-duplex>)
status: active
ipfw
00100 allow ip from any to any via lo0
00200 deny ip from any to 127.0.0.0/8
00300 deny ip from 127.0.0.0/8 to any
00400 deny tcp from any to any frag
00500 check-state
00600 allow tcp from any to any established
00700 allow ip from any to any out keep-state
00800 allow icmp from any to any
00900 allow tcp from any to any dst-port 80,443 in
01200 allow tcp from any to any dst-port 20-22,25,80,443 out
01300 allow udp from any to any dst-port 53 out
65535 deny ip from any to any
Agradecemos antecipadamente por qualquer sugestão! :)